-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[On-Chain] Refactor
grace_period_end_offset_blocks
as a shared
mo…
…dule param (#628)
- Loading branch information
1 parent
d1f4f42
commit e208b42
Showing
29 changed files
with
491 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package keeper | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// AssertDefaultParamsEqualExceptFields asserts that the expectedParams and | ||
// actualParams are equal except for the fields specified in exceptFields. | ||
// expectedParams and actualParams MUST be reference types (e.g. pionters). | ||
func AssertDefaultParamsEqualExceptFields[P any]( | ||
t *testing.T, | ||
expectedParams P, | ||
actualParams P, | ||
exceptFields ...string, | ||
) { | ||
expectedParamsValue := reflect.ValueOf(expectedParams).Elem() | ||
actualParamsValue := reflect.ValueOf(actualParams).Elem() | ||
|
||
for fieldIdx := 0; fieldIdx < expectedParamsValue.NumField(); fieldIdx++ { | ||
fieldName := expectedParamsValue.Type().Field(fieldIdx).Name | ||
// Skip all fields in the exceptFields list. | ||
if isFieldException(fieldName, exceptFields) { | ||
continue | ||
} | ||
|
||
require.Equal(t, | ||
expectedParamsValue.FieldByName(fieldName).Interface(), | ||
actualParamsValue.FieldByName(fieldName).Interface(), | ||
) | ||
} | ||
} | ||
|
||
func isFieldException(fieldName string, exceptFields []string) bool { | ||
for _, exceptField := range exceptFields { | ||
if exceptField == fieldName { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tools/scripts/params/shared_grace_period_end_offset_blocks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"body": { | ||
"messages": [ | ||
{ | ||
"@type": "/poktroll.shared.MsgUpdateParam", | ||
"authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", | ||
"name": "grace_period_end_offset_blocks", | ||
"as_int64": "1" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.