Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EasterTheBunny committed Jan 9, 2025
1 parent 0e9ad4a commit 87696ba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions pkg/codec/encodings/type_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,25 @@ func TestCodecFromTypeCodecs(t *testing.T) {
})

t.Run("CreateType works for nested struct values", func(t *testing.T) {
itemType := strings.Join([]string{TestItemType, "NestedDynamicStruct", "Inner", "S"}, ".")
itemType := strings.Join([]string{TestItemType, "AccountStruct", "Account"}, ".")
ts := CreateTestStruct(0, biit)
c := biit.GetCodec(t)

encoded, err := c.Encode(tests.Context(t), ts, itemType)
encoded, err := c.Encode(tests.Context(t), ts.AccountStruct.Account, itemType)
require.NoError(t, err)

var actual []byte
require.NoError(t, c.Decode(tests.Context(t), encoded, &actual, itemType))

assert.Equal(t, ts.AccountStruct.Account, actual)
})

t.Run("CreateType works for nested struct values and modifiers", func(t *testing.T) {
itemType := strings.Join([]string{TestItemWithConfigExtra, "NestedDynamicStruct", "Inner", "S"}, ".")
ts := CreateTestStruct(0, biit)
c := biit.GetCodec(t)

encoded, err := c.Encode(tests.Context(t), ts.NestedDynamicStruct.Inner.S, itemType)
require.NoError(t, err)

var actual string
Expand Down
2 changes: 1 addition & 1 deletion pkg/codec/modifier_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type modifierBase[T any] struct {
addFieldForInput func(pkgPath, name string, change T) reflect.StructField
}

func (m *modifierBase[T]) RetypeToOffChain(onChainType reflect.Type, itemType string) (tpe reflect.Type, err error) {
func (m *modifierBase[T]) RetypeToOffChain(onChainType reflect.Type, _ string) (tpe reflect.Type, err error) {
defer func() {
// StructOf can panic if the fields are not valid
if r := recover(); r != nil {
Expand Down

0 comments on commit 87696ba

Please sign in to comment.