From 87696ba88b0b99ab0db4b7f866875bb6f814a947 Mon Sep 17 00:00:00 2001 From: Awbrey Hughlett Date: Thu, 9 Jan 2025 10:13:55 -0600 Subject: [PATCH] fix tests --- pkg/codec/encodings/type_codec_test.go | 18 ++++++++++++++++-- pkg/codec/modifier_base.go | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/codec/encodings/type_codec_test.go b/pkg/codec/encodings/type_codec_test.go index 35e942c52..47b21b162 100644 --- a/pkg/codec/encodings/type_codec_test.go +++ b/pkg/codec/encodings/type_codec_test.go @@ -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 diff --git a/pkg/codec/modifier_base.go b/pkg/codec/modifier_base.go index 8a092fe9b..4e156a063 100644 --- a/pkg/codec/modifier_base.go +++ b/pkg/codec/modifier_base.go @@ -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 {