encoding: fix test (#64)

This commit is contained in:
Federico Kunze 2021-06-04 09:45:37 -04:00 committed by GitHub
parent 475c61851c
commit 9509e18842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 12 deletions

View File

@ -24,6 +24,7 @@ import (
"github.com/cosmos/ethermint/app" "github.com/cosmos/ethermint/app"
ante "github.com/cosmos/ethermint/app/ante" ante "github.com/cosmos/ethermint/app/ante"
"github.com/cosmos/ethermint/crypto/ethsecp256k1" "github.com/cosmos/ethermint/crypto/ethsecp256k1"
"github.com/cosmos/ethermint/encoding"
"github.com/cosmos/ethermint/tests" "github.com/cosmos/ethermint/tests"
evmtypes "github.com/cosmos/ethermint/x/evm/types" 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.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams())
suite.app.EvmKeeper.SetParams(infCtx, evmtypes.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. // We're using TestMsg amino encoding in some tests, so register it here.
encodingConfig.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) encodingConfig.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil)

View File

@ -38,12 +38,13 @@ import (
"github.com/cosmos/ethermint/app" "github.com/cosmos/ethermint/app"
ethermintclient "github.com/cosmos/ethermint/client" 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 // NewRootCmd creates a new root command for simd. It is called once in the
// main function. // main function.
func NewRootCmd() (*cobra.Command, params.EncodingConfig) { func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
encodingConfig := app.MakeEncodingConfig() encodingConfig := encoding.MakeConfig(app.ModuleBasics)
initClientCtx := client.Context{}. initClientCtx := client.Context{}.
WithJSONMarshaler(encodingConfig.Marshaler). WithJSONMarshaler(encodingConfig.Marshaler).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry). 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, logger, db, traceStore, true, skipUpgradeHeights,
cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(sdkserver.FlagInvCheckPeriod)), 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, appOpts,
baseapp.SetPruning(pruningOpts), baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(sdkserver.FlagMinGasPrices))), 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, logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string,
appOpts servertypes.AppOptions, appOpts servertypes.AppOptions,
) (servertypes.ExportedApp, error) { ) (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) encCfg.Marshaler = codec.NewProtoCodec(encCfg.InterfaceRegistry)
var ethermintApp *app.EthermintApp var ethermintApp *app.EthermintApp
if height != -1 { if height != -1 {

View File

@ -1,4 +1,4 @@
package encoding package codec
import ( import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"

View File

@ -11,6 +11,7 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types" ethtypes "github.com/ethereum/go-ethereum/core/types"
enccodec "github.com/cosmos/ethermint/encoding/codec"
evmtypes "github.com/cosmos/ethermint/x/evm/types" evmtypes "github.com/cosmos/ethermint/x/evm/types"
) )
@ -27,9 +28,9 @@ func MakeConfig(mb module.BasicManager) params.EncodingConfig {
Amino: cdc, Amino: cdc,
} }
RegisterLegacyAminoCodec(encodingConfig.Amino) enccodec.RegisterLegacyAminoCodec(encodingConfig.Amino)
mb.RegisterLegacyAminoCodec(encodingConfig.Amino) mb.RegisterLegacyAminoCodec(encodingConfig.Amino)
RegisterInterfaces(encodingConfig.InterfaceRegistry) enccodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
mb.RegisterInterfaces(encodingConfig.InterfaceRegistry) mb.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig return encodingConfig
} }

View File

@ -28,7 +28,7 @@ import (
paramkeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramkeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" 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" "github.com/cosmos/ethermint/types"
evmkeeper "github.com/cosmos/ethermint/x/evm/keeper" evmkeeper "github.com/cosmos/ethermint/x/evm/keeper"
evmtypes "github.com/cosmos/ethermint/x/evm/types" evmtypes "github.com/cosmos/ethermint/x/evm/types"

View File

@ -12,9 +12,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
ethermintcodec "github.com/cosmos/ethermint/codec"
cryptocodec "github.com/cosmos/ethermint/crypto/codec" cryptocodec "github.com/cosmos/ethermint/crypto/codec"
"github.com/cosmos/ethermint/crypto/ethsecp256k1" "github.com/cosmos/ethermint/crypto/ethsecp256k1"
ethermintcodec "github.com/cosmos/ethermint/encoding/codec"
"github.com/cosmos/ethermint/types" "github.com/cosmos/ethermint/types"
) )

View File

@ -5,6 +5,8 @@ import (
"os" "os"
"testing" "testing"
"github.com/cosmos/ethermint/crypto/ethsecp256k1"
enccodec "github.com/cosmos/ethermint/encoding/codec"
ethermint "github.com/cosmos/ethermint/types" ethermint "github.com/cosmos/ethermint/types"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
@ -28,8 +30,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types" 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) { func newTestCodec() (codec.BinaryMarshaler, *codec.LegacyAmino) {
@ -39,7 +39,7 @@ func newTestCodec() (codec.BinaryMarshaler, *codec.LegacyAmino) {
sdk.RegisterLegacyAminoCodec(amino) sdk.RegisterLegacyAminoCodec(amino)
ethcodec.RegisterInterfaces(interfaceRegistry) enccodec.RegisterInterfaces(interfaceRegistry)
return cdc, amino return cdc, amino
} }