diff --git a/tests/tsdk/codec.go b/tests/tsdk/codec.go index 6ced34ca40..75eab15991 100644 --- a/tests/tsdk/codec.go +++ b/tests/tsdk/codec.go @@ -11,7 +11,7 @@ import ( // typically a RegisterInterfaces function in Cosmos SDK modules) func NewCodec(registrars ...func(types.InterfaceRegistry)) codec.Codec { interfaceRegistry := types.NewInterfaceRegistry() - std.RegisterInterfaces(interfaceRegistry) + std.RegisterInterfaces(interfaceRegistry) // register SDK interfaces for _, f := range registrars { f(interfaceRegistry) } diff --git a/x/uibc/uics20/ibc_module.go b/x/uibc/uics20/ibc_module.go index 6063de3ba1..ee5babed79 100644 --- a/x/uibc/uics20/ibc_module.go +++ b/x/uibc/uics20/ibc_module.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" - gogoproto "github.com/cosmos/gogoproto/proto" "github.com/umee-network/umee/v6/x/uibc" "github.com/umee-network/umee/v6/x/uibc/quota" @@ -50,7 +49,7 @@ func (im ICS20Module) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, } if ftData.Memo != "" { - msgs, err := deserializeMemoMsgs(im.cdc, []byte(ftData.Memo)) + msgs, err := DeserializeMemoMsgs(im.cdc, []byte(ftData.Memo)) if err != nil { // TODO: need to verify if we want to stop the handle the error or revert the ibc transerf ctx.Logger().Error("can't JSON deserialize ftData Memo, expecting list of Msg", "err", err) @@ -120,7 +119,7 @@ func deserializeFTData(cdc codec.JSONCodec, packet channeltypes.Packet, return } -func deserializeMemoMsgs(cdc codec.JSONCodec, data []byte) ([]sdk.Msg, error) { +func DeserializeMemoMsgs(cdc codec.JSONCodec, data []byte) ([]sdk.Msg, error) { var m uibc.ICS20Memo if err := cdc.UnmarshalJSON(data, &m); err != nil { return nil, err diff --git a/x/uibc/uics20/ics4_module_int_test.go b/x/uibc/uics20/ics4_module_int_test.go index 33559f4169..a55e298632 100644 --- a/x/uibc/uics20/ics4_module_int_test.go +++ b/x/uibc/uics20/ics4_module_int_test.go @@ -1,5 +1,37 @@ -package main +package uics20_test import ( - "fmt" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/stretchr/testify/assert" + + "github.com/umee-network/umee/v6/tests/accs" + "github.com/umee-network/umee/v6/tests/tsdk" + ltypes "github.com/umee-network/umee/v6/x/leverage/types" + "github.com/umee-network/umee/v6/x/uibc" + "github.com/umee-network/umee/v6/x/uibc/uics20" ) + +func TestMsgMarshalling(t *testing.T) { + assert := assert.New(t) + cdc := tsdk.NewCodec(uibc.RegisterInterfaces, ltypes.RegisterInterfaces) + msgs := []sdk.Msg{ + &uibc.MsgGovSetIBCStatus{Authority: "auth1", Description: "d1", + IbcStatus: uibc.IBCTransferStatus_IBC_TRANSFER_STATUS_QUOTA_OUT_DISABLED}, + ltypes.NewMsgCollateralize(accs.Alice, sdk.NewCoin("ATOM", sdk.NewInt(1020))), + } + anyMsg, err := tx.SetMsgs(msgs) + assert.NoError(err) + var memo = uibc.ICS20Memo{Messages: anyMsg} + + bz, err := cdc.MarshalJSON(&memo) + assert.NoError(err) + + msgs2, err := uics20.DeserializeMemoMsgs(cdc, bz) + assert.NoError(err) + for i := range msgs2 { + assert.Equal(msgs[i], msgs2[i], "idx=%d", i) + } +} diff --git a/x/uibc/uics20/ics4_wrapper_test.go b/x/uibc/uics20/ics4_wrapper_test.go index 82c5195901..ffdc194289 100644 --- a/x/uibc/uics20/ics4_wrapper_test.go +++ b/x/uibc/uics20/ics4_wrapper_test.go @@ -3,8 +3,6 @@ package uics20_test import ( "testing" - "gotest.tools/v3/assert" - "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,6 +12,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" "github.com/golang/mock/gomock" + "gotest.tools/v3/assert" "github.com/umee-network/umee/v6/tests/tsdk" lfixtures "github.com/umee-network/umee/v6/x/leverage/fixtures"