diff --git a/modules/core/02-client/types/codec.go b/modules/core/02-client/types/codec.go index f115fa39ea7..23b99689f91 100644 --- a/modules/core/02-client/types/codec.go +++ b/modules/core/02-client/types/codec.go @@ -8,6 +8,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -46,6 +47,11 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgIBCSoftwareUpgrade{}, &MsgUpdateParams{}, ) + registry.RegisterImplementations( + (*govtypesv1beta1.Content)(nil), + &ClientUpdateProposal{}, + &UpgradeProposal{}, + ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/modules/core/02-client/types/codec_test.go b/modules/core/02-client/types/codec_test.go index 89e5b6c34df..ce42fc5acd1 100644 --- a/modules/core/02-client/types/codec_test.go +++ b/modules/core/02-client/types/codec_test.go @@ -2,6 +2,7 @@ package types_test import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" @@ -155,3 +156,78 @@ func (suite *TypesTestSuite) TestPackClientMessage() { } } } + +func (suite *TypesTestSuite) TestCodecTypeRegistration() { + testCases := []struct { + name string + typeURL string + expPass bool + }{ + { + "success: MsgCreateClient", + sdk.MsgTypeURL(&types.MsgCreateClient{}), + true, + }, + { + "success: MsgUpdateClient", + sdk.MsgTypeURL(&types.MsgUpdateClient{}), + true, + }, + { + "success: MsgUpgradeClient", + sdk.MsgTypeURL(&types.MsgUpgradeClient{}), + true, + }, + { + "success: MsgSubmitMisbehaviour", + sdk.MsgTypeURL(&types.MsgSubmitMisbehaviour{}), + true, + }, + { + "success: MsgRecoverClient", + sdk.MsgTypeURL(&types.MsgRecoverClient{}), + true, + }, + { + "success: MsgIBCSoftwareUpgrade", + sdk.MsgTypeURL(&types.MsgIBCSoftwareUpgrade{}), + true, + }, + { + "success: MsgUpdateParams", + sdk.MsgTypeURL(&types.MsgUpdateParams{}), + true, + }, + { + "success: ClientUpdateProposal", + sdk.MsgTypeURL(&types.ClientUpdateProposal{}), + true, + }, + { + "success: UpgradeProposal", + sdk.MsgTypeURL(&types.UpgradeProposal{}), + true, + }, + { + "type not registered on codec", + "ibc.invalid.MsgTypeURL", + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + msg, err := suite.chainA.GetSimApp().AppCodec().InterfaceRegistry().Resolve(tc.typeURL) + + if tc.expPass { + suite.Require().NotNil(msg) + suite.Require().NoError(err) + } else { + suite.Require().Nil(msg) + suite.Require().Error(err) + } + }) + } +}