From 9509e1884292f42ea7ea1fa6c8f89e648ad7ac5f Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Fri, 4 Jun 2021 09:45:37 -0400 Subject: [PATCH] encoding: fix test (#64) --- app/ante/utils_test.go | 3 ++- cmd/ethermintd/root.go | 7 ++++--- encoding/{ => codec}/codec.go | 2 +- encoding/config.go | 5 +++-- tests/importer/importer_test.go | 2 +- types/account_test.go | 2 +- x/evm/types/journal_test.go | 6 +++--- 7 files changed, 15 insertions(+), 12 deletions(-) rename encoding/{ => codec}/codec.go (97%) diff --git a/app/ante/utils_test.go b/app/ante/utils_test.go index 714d14f7..620aa56e 100644 --- a/app/ante/utils_test.go +++ b/app/ante/utils_test.go @@ -24,6 +24,7 @@ import ( "github.com/cosmos/ethermint/app" ante "github.com/cosmos/ethermint/app/ante" "github.com/cosmos/ethermint/crypto/ethsecp256k1" + "github.com/cosmos/ethermint/encoding" "github.com/cosmos/ethermint/tests" evmtypes "github.com/cosmos/ethermint/x/evm/types" @@ -53,7 +54,7 @@ func (suite *AnteTestSuite) SetupTest() { suite.app.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams()) suite.app.EvmKeeper.SetParams(infCtx, evmtypes.DefaultParams()) - encodingConfig := app.MakeEncodingConfig() + encodingConfig := encoding.MakeConfig(app.ModuleBasics) // We're using TestMsg amino encoding in some tests, so register it here. encodingConfig.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) diff --git a/cmd/ethermintd/root.go b/cmd/ethermintd/root.go index 45c573bf..119c3def 100644 --- a/cmd/ethermintd/root.go +++ b/cmd/ethermintd/root.go @@ -38,12 +38,13 @@ import ( "github.com/cosmos/ethermint/app" ethermintclient "github.com/cosmos/ethermint/client" + "github.com/cosmos/ethermint/encoding" ) // NewRootCmd creates a new root command for simd. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - encodingConfig := app.MakeEncodingConfig() + encodingConfig := encoding.MakeConfig(app.ModuleBasics) initClientCtx := client.Context{}. WithJSONMarshaler(encodingConfig.Marshaler). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). @@ -225,7 +226,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty logger, db, traceStore, true, skipUpgradeHeights, cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToUint(appOpts.Get(sdkserver.FlagInvCheckPeriod)), - app.MakeEncodingConfig(), // Ideally, we would reuse the one created by NewRootCmd. + encoding.MakeConfig(app.ModuleBasics), // Ideally, we would reuse the one created by NewRootCmd. appOpts, baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(sdkserver.FlagMinGasPrices))), @@ -249,7 +250,7 @@ func createAppAndExport( logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts servertypes.AppOptions, ) (servertypes.ExportedApp, error) { - encCfg := app.MakeEncodingConfig() // Ideally, we would reuse the one created by NewRootCmd. + encCfg := encoding.MakeConfig(app.ModuleBasics) // Ideally, we would reuse the one created by NewRootCmd. encCfg.Marshaler = codec.NewProtoCodec(encCfg.InterfaceRegistry) var ethermintApp *app.EthermintApp if height != -1 { diff --git a/encoding/codec.go b/encoding/codec/codec.go similarity index 97% rename from encoding/codec.go rename to encoding/codec/codec.go index 81540aa2..64782242 100644 --- a/encoding/codec.go +++ b/encoding/codec/codec.go @@ -1,4 +1,4 @@ -package encoding +package codec import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/encoding/config.go b/encoding/config.go index 0744cd83..797db872 100644 --- a/encoding/config.go +++ b/encoding/config.go @@ -11,6 +11,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" + enccodec "github.com/cosmos/ethermint/encoding/codec" evmtypes "github.com/cosmos/ethermint/x/evm/types" ) @@ -27,9 +28,9 @@ func MakeConfig(mb module.BasicManager) params.EncodingConfig { Amino: cdc, } - RegisterLegacyAminoCodec(encodingConfig.Amino) + enccodec.RegisterLegacyAminoCodec(encodingConfig.Amino) mb.RegisterLegacyAminoCodec(encodingConfig.Amino) - RegisterInterfaces(encodingConfig.InterfaceRegistry) + enccodec.RegisterInterfaces(encodingConfig.InterfaceRegistry) mb.RegisterInterfaces(encodingConfig.InterfaceRegistry) return encodingConfig } diff --git a/tests/importer/importer_test.go b/tests/importer/importer_test.go index 1217390f..7d4fbb57 100644 --- a/tests/importer/importer_test.go +++ b/tests/importer/importer_test.go @@ -28,7 +28,7 @@ import ( paramkeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cosmos/ethermint/codec" + "github.com/cosmos/ethermint/encoding/codec" "github.com/cosmos/ethermint/types" evmkeeper "github.com/cosmos/ethermint/x/evm/keeper" evmtypes "github.com/cosmos/ethermint/x/evm/types" diff --git a/types/account_test.go b/types/account_test.go index 3fd199e4..c6483a38 100644 --- a/types/account_test.go +++ b/types/account_test.go @@ -12,9 +12,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - ethermintcodec "github.com/cosmos/ethermint/codec" cryptocodec "github.com/cosmos/ethermint/crypto/codec" "github.com/cosmos/ethermint/crypto/ethsecp256k1" + ethermintcodec "github.com/cosmos/ethermint/encoding/codec" "github.com/cosmos/ethermint/types" ) diff --git a/x/evm/types/journal_test.go b/x/evm/types/journal_test.go index 05c86255..4aad9791 100644 --- a/x/evm/types/journal_test.go +++ b/x/evm/types/journal_test.go @@ -5,6 +5,8 @@ import ( "os" "testing" + "github.com/cosmos/ethermint/crypto/ethsecp256k1" + enccodec "github.com/cosmos/ethermint/encoding/codec" ethermint "github.com/cosmos/ethermint/types" "github.com/stretchr/testify/suite" @@ -28,8 +30,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - ethcodec "github.com/cosmos/ethermint/codec" - "github.com/cosmos/ethermint/crypto/ethsecp256k1" ) func newTestCodec() (codec.BinaryMarshaler, *codec.LegacyAmino) { @@ -39,7 +39,7 @@ func newTestCodec() (codec.BinaryMarshaler, *codec.LegacyAmino) { sdk.RegisterLegacyAminoCodec(amino) - ethcodec.RegisterInterfaces(interfaceRegistry) + enccodec.RegisterInterfaces(interfaceRegistry) return cdc, amino }