cosmos-sdk/testutil/testdata/codec.go
Amaury Martiny 82f15f306e
RegisterInterfaces registers service Msg type_urls (#7671)
* Add RegisterMsgServiceDesc

* Refactor newSendTxMsgServiceCmd

* Add test

* Register in all modules

* Remove RegisterMsgServiceDesc from baseapp

* Add explicit error message

* Add comment

* Update comment

* Add test

* Update comment

* Remove duplicate import

* Fix lint

* Forgot vesting

* Fix lint

* Fix test

* Put in types/module

* Put in types/msgservice

* Add comment about panic

* Update baseapp/msg_service_router.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update baseapp/msg_service_router.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update baseapp/msg_service_router.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Add comment

* Add better test

* Update baseapp/msg_service_router.go

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-10-28 19:20:45 +00:00

52 lines
1.3 KiB
Go

package testdata
import (
amino "github.com/tendermint/go-amino"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
func NewTestInterfaceRegistry() types.InterfaceRegistry {
registry := types.NewInterfaceRegistry()
RegisterInterfaces(registry)
return registry
}
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil), &TestMsg{})
registry.RegisterInterface("Animal", (*Animal)(nil))
registry.RegisterImplementations(
(*Animal)(nil),
&Dog{},
&Cat{},
)
registry.RegisterImplementations(
(*HasAnimalI)(nil),
&HasAnimal{},
)
registry.RegisterImplementations(
(*HasHasAnimalI)(nil),
&HasHasAnimal{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
func NewTestAmino() *amino.Codec {
cdc := amino.NewCodec()
cdc.RegisterInterface((*Animal)(nil), nil)
cdc.RegisterConcrete(&Dog{}, "testdata/Dog", nil)
cdc.RegisterConcrete(&Cat{}, "testdata/Cat", nil)
cdc.RegisterInterface((*HasAnimalI)(nil), nil)
cdc.RegisterConcrete(&HasAnimal{}, "testdata/HasAnimal", nil)
cdc.RegisterInterface((*HasHasAnimalI)(nil), nil)
cdc.RegisterConcrete(&HasHasAnimal{}, "testdata/HasHasAnimal", nil)
return cdc
}