forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x/params/types: make KeyTable.RegisterType fully dereference pointers (…
…cosmos#6915) Use a for loop to correctly and fully dereference and extract the type for the type of ParamSetPair.Value. Fixes cosmos#6785 Co-authored-by: Alexander Bezobchuk <[email protected]>
- Loading branch information
1 parent
c7c66f8
commit 10d330e
Showing
2 changed files
with
28 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package types | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestKeyTableUnfurlsPointers(t *testing.T) { | ||
tbl := NewKeyTable() | ||
validator := func(_ interface{}) error { | ||
return nil | ||
} | ||
tbl = tbl.RegisterType(ParamSetPair{ | ||
Key: []byte("key"), | ||
Value: (*****string)(nil), | ||
ValidatorFn: validator, | ||
}) | ||
|
||
got := tbl.m["key"] | ||
want := attribute{ | ||
vfn: validator, | ||
ty: reflect.ValueOf("").Type(), | ||
} | ||
require.Equal(t, got.ty, want.ty) | ||
} |
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