diff --git a/app/app_test.go b/app/app_test.go index 429796666..df3f279e6 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -11,7 +11,7 @@ import ( ) func TestBabylonBlockedAddrs(t *testing.T) { - encCfg := MakeTestEncodingConfig() + encCfg := GetEncodingConfig() db := dbm.NewMemDB() signer, _ := SetupPrivSigner() logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) @@ -48,7 +48,7 @@ func TestGetMaccPerms(t *testing.T) { } func TestUpgradeStateOnGenesis(t *testing.T) { - encCfg := MakeTestEncodingConfig() + encCfg := GetEncodingConfig() db := dbm.NewMemDB() privSigner, err := SetupPrivSigner() require.NoError(t, err) diff --git a/app/encoding.go b/app/encoding.go index c414f23f0..800f0e302 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -1,16 +1,20 @@ package app import ( - appparams "github.com/babylonchain/babylon/app/params" "github.com/cosmos/cosmos-sdk/std" + + appparams "github.com/babylonchain/babylon/app/params" ) -// MakeTestEncodingConfig creates an EncodingConfig for testing. This function -// should be used only in tests or when creating a new app instance (NewApp*()). -// App user shouldn't create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -func MakeTestEncodingConfig() appparams.EncodingConfig { - encodingConfig := appparams.MakeTestEncodingConfig() +var encodingConfig = makeEncodingConfig() + +func GetEncodingConfig() appparams.EncodingConfig { + return encodingConfig +} + +// makeEncodingConfig creates an EncodingConfig. +func makeEncodingConfig() appparams.EncodingConfig { + encodingConfig := appparams.GetEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) std.RegisterInterfaces(encodingConfig.InterfaceRegistry) ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) diff --git a/app/modules.go b/app/modules.go index d3fafbc66..8a9252c50 100644 --- a/app/modules.go +++ b/app/modules.go @@ -23,5 +23,5 @@ func (app *BabylonApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { } func (app *BabylonApp) GetTxConfig() client.TxConfig { - return MakeTestEncodingConfig().TxConfig + return GetEncodingConfig().TxConfig } diff --git a/app/params/proto.go b/app/params/proto.go index a752d1079..f2f36aae3 100644 --- a/app/params/proto.go +++ b/app/params/proto.go @@ -9,19 +9,17 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/tx" ) -// MakeTestEncodingConfig creates an EncodingConfig for a non-amino based test configuration. -// This function should be used only internally (in the SDK). -// App user should'nt create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -func MakeTestEncodingConfig() EncodingConfig { - cdc := codec.NewLegacyAmino() +// GetEncodingConfig creates an EncodingConfig for an amino based test configuration. +func GetEncodingConfig() EncodingConfig { + amino := codec.NewLegacyAmino() interfaceRegistry := types.NewInterfaceRegistry() marshaler := codec.NewProtoCodec(interfaceRegistry) + txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) return EncodingConfig{ InterfaceRegistry: interfaceRegistry, Marshaler: marshaler, - TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes), - Amino: cdc, + TxConfig: txCfg, + Amino: amino, } } diff --git a/app/test_helpers.go b/app/test_helpers.go index 170e95d19..e02cf9fde 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -13,13 +13,13 @@ import ( "cosmossdk.io/math" tmconfig "github.com/tendermint/tendermint/config" + tmjson "github.com/tendermint/tendermint/libs/json" + + "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonchain/babylon/app/params" appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/testutil/datagen" - tmjson "github.com/tendermint/tendermint/libs/json" - txformat "github.com/babylonchain/babylon/btctxformatter" - bbn "github.com/babylonchain/babylon/types" bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -43,6 +43,9 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" dbm "github.com/tendermint/tm-db" + + txformat "github.com/babylonchain/babylon/btctxformatter" + bbn "github.com/babylonchain/babylon/types" ) // DefaultConsensusParams defines the default Tendermint consensus params used in @@ -77,7 +80,7 @@ type SetupOptions struct { func setup(withGenesis bool, invCheckPeriod uint) (*BabylonApp, GenesisState) { db := dbm.NewMemDB() - encCdc := MakeTestEncodingConfig() + encCdc := GetEncodingConfig() privSigner, err := SetupPrivSigner() if err != nil { panic(err) @@ -242,7 +245,8 @@ func SetupPrivSigner() (*PrivSigner, error) { if err != nil { return nil, err } - privSigner, _ := InitPrivSigner(client.Context{}, ".", kr) + encodingCfg := appparams.GetEncodingConfig() + privSigner, _ := InitPrivSigner(client.Context{}, ".", kr, encodingCfg) privSigner.WrappedPV.Clean(nodeCfg.PrivValidatorKeyFile(), nodeCfg.PrivValidatorStateFile()) return privSigner, nil } diff --git a/app/utils.go b/app/utils.go index 1cd4bb8f9..2d11432bd 100644 --- a/app/utils.go +++ b/app/utils.go @@ -16,6 +16,7 @@ import ( tmconfig "github.com/tendermint/tendermint/config" tmos "github.com/tendermint/tendermint/libs/os" + appparams "github.com/babylonchain/babylon/app/params" "github.com/babylonchain/babylon/privval" ) @@ -43,7 +44,7 @@ type PrivSigner struct { ClientCtx client.Context } -func InitPrivSigner(clientCtx client.Context, nodeDir string, kr keyring.Keyring) (*PrivSigner, error) { +func InitPrivSigner(clientCtx client.Context, nodeDir string, kr keyring.Keyring, encodingCfg appparams.EncodingConfig) (*PrivSigner, error) { // setup private validator nodeCfg := tmconfig.DefaultConfig() pvKeyFile := filepath.Join(nodeDir, nodeCfg.PrivValidatorKeyFile()) @@ -58,9 +59,6 @@ func InitPrivSigner(clientCtx client.Context, nodeDir string, kr keyring.Keyring } wrappedPV := privval.LoadOrGenWrappedFilePV(pvKeyFile, pvStateFile) - // TODO this should probably not create separate config, but rahter accept it - // as argument - encodingCfg := MakeTestEncodingConfig() clientCtx = clientCtx. WithInterfaceRegistry(encodingCfg.InterfaceRegistry). WithCodec(encodingCfg.Marshaler). diff --git a/cmd/babylond/cmd/add_gen_bls_test.go b/cmd/babylond/cmd/add_gen_bls_test.go index f1e631ba3..ac6c34b2a 100644 --- a/cmd/babylond/cmd/add_gen_bls_test.go +++ b/cmd/babylond/cmd/add_gen_bls_test.go @@ -3,10 +3,11 @@ package cmd_test import ( "context" "fmt" - "github.com/cosmos/cosmos-sdk/server/config" "path/filepath" "testing" + "github.com/cosmos/cosmos-sdk/server/config" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -36,7 +37,7 @@ func Test_AddGenBlsCmdWithoutGentx(t *testing.T) { tmcfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) - appCodec := app.MakeTestEncodingConfig().Marshaler + appCodec := app.GetEncodingConfig().Marshaler err = genutiltest.ExecInitCmd(testMbm, home, appCodec) require.NoError(t, err) diff --git a/cmd/babylond/cmd/genaccounts_test.go b/cmd/babylond/cmd/genaccounts_test.go index ef8a2101a..803df1f55 100644 --- a/cmd/babylond/cmd/genaccounts_test.go +++ b/cmd/babylond/cmd/genaccounts_test.go @@ -13,8 +13,6 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" - "github.com/babylonchain/babylon/app" - bbncmd "github.com/babylonchain/babylon/cmd/babylond/cmd" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -22,6 +20,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" + + "github.com/babylonchain/babylon/app" + bbncmd "github.com/babylonchain/babylon/cmd/babylond/cmd" ) var testMbm = module.NewBasicManager(genutil.AppModuleBasic{}) @@ -73,7 +74,7 @@ func TestAddGenesisAccountCmd(t *testing.T) { cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) - appCodec := app.MakeTestEncodingConfig().Marshaler + appCodec := app.GetEncodingConfig().Marshaler err = genutiltest.ExecInitCmd(testMbm, home, appCodec) require.NoError(t, err) diff --git a/cmd/babylond/cmd/genbls_test.go b/cmd/babylond/cmd/genbls_test.go index 46904a3c6..5f7379a55 100644 --- a/cmd/babylond/cmd/genbls_test.go +++ b/cmd/babylond/cmd/genbls_test.go @@ -28,7 +28,7 @@ import ( func Test_GenBlsCmd(t *testing.T) { home := t.TempDir() - encodingConfig := app.MakeTestEncodingConfig() + encodingConfig := app.GetEncodingConfig() logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) diff --git a/cmd/babylond/cmd/root.go b/cmd/babylond/cmd/root.go index c04b2dac8..43429f7f3 100644 --- a/cmd/babylond/cmd/root.go +++ b/cmd/babylond/cmd/root.go @@ -40,7 +40,7 @@ import ( // NewRootCmd creates a new root command for babylond. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - encodingConfig := app.MakeTestEncodingConfig() + encodingConfig := app.GetEncodingConfig() initClientCtx := client.Context{}. WithCodec(encodingConfig.Marshaler). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). @@ -274,7 +274,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a if err != nil { panic(err) } - privSigner, err := app.InitPrivSigner(clientCtx, homeDir, clientCtx.Keyring) + privSigner, err := app.InitPrivSigner(clientCtx, homeDir, clientCtx.Keyring, a.encCfg) if err != nil { panic(err) } @@ -337,7 +337,7 @@ func (a appCreator) appExport( panic(err) } - privSigner, err := app.InitPrivSigner(clientCtx, homePath, kr) + privSigner, err := app.InitPrivSigner(clientCtx, homePath, kr, a.encCfg) if err != nil { panic(err) } diff --git a/cmd/babylond/cmd/testnet_test.go b/cmd/babylond/cmd/testnet_test.go index a8660c821..1fc62f834 100644 --- a/cmd/babylond/cmd/testnet_test.go +++ b/cmd/babylond/cmd/testnet_test.go @@ -5,7 +5,6 @@ import ( "fmt" "testing" - "github.com/babylonchain/babylon/app" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -15,11 +14,13 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" + + "github.com/babylonchain/babylon/app" ) func Test_TestnetCmd(t *testing.T) { home := t.TempDir() - encodingConfig := app.MakeTestEncodingConfig() + encodingConfig := app.GetEncodingConfig() logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) diff --git a/cmd/babylond/cmd/validate_genesis_test.go b/cmd/babylond/cmd/validate_genesis_test.go index 070ce5037..aae452917 100644 --- a/cmd/babylond/cmd/validate_genesis_test.go +++ b/cmd/babylond/cmd/validate_genesis_test.go @@ -26,7 +26,7 @@ import ( func TestCheckCorrespondence(t *testing.T) { homePath := t.TempDir() - encodingCft := app.MakeTestEncodingConfig() + encodingCft := app.GetEncodingConfig() clientCtx := client.Context{}.WithCodec(encodingCft.Marshaler).WithTxConfig(encodingCft.TxConfig) // generate valid genesis doc @@ -85,7 +85,7 @@ func TestCheckCorrespondence(t *testing.T) { } func generateTestGenesisState(home string, n int) (map[string]json.RawMessage, *tmtypes.GenesisDoc) { - encodingConfig := app.MakeTestEncodingConfig() + encodingConfig := app.GetEncodingConfig() logger := log.NewNopLogger() cfg, _ := genutiltest.CreateDefaultTendermintConfig(home) diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index 7eb28b0d3..797931399 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -39,7 +39,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { if err != nil { b.Fatal(err) } - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( @@ -93,7 +93,7 @@ func BenchmarkInvariants(b *testing.B) { if err != nil { b.Fatal(err) } - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( diff --git a/simapp/sim_test.go b/simapp/sim_test.go index e18fd3c35..4bab4fd39 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -12,13 +12,10 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" - "github.com/babylonchain/babylon/app" storetypes "github.com/cosmos/cosmos-sdk/store/types" - btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclightclienttypes "github.com/babylonchain/babylon/x/btclightclient/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonchain/babylon/app" + "github.com/cosmos/cosmos-sdk/baseapp" sdksimapp "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/simapp/helpers" @@ -38,6 +35,11 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/tendermint/tendermint/abci/types" + + btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types" + btclightclienttypes "github.com/babylonchain/babylon/x/btclightclient/types" + checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonchain/babylon/x/epoching/types" ) // Get flags every time the simulator is run @@ -77,7 +79,7 @@ func TestFullAppSimulation(t *testing.T) { privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", babylon.Name()) // run randomized simulation @@ -117,7 +119,7 @@ func TestAppImportExport(t *testing.T) { privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", babylon.Name()) // Run randomized simulation @@ -157,7 +159,7 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", newBabylon.Name()) var genesisState app.GenesisState @@ -221,7 +223,7 @@ func TestAppSimulationAfterImport(t *testing.T) { privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", babylon.Name()) // Run randomized simulation @@ -266,7 +268,7 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", newBabylon.Name()) newBabylon.InitChain(abci.RequestInitChain{ @@ -319,7 +321,7 @@ func TestAppStateDeterminism(t *testing.T) { db := dbm.NewMemDB() privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) fmt.Printf( "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", diff --git a/test/e2e/util/codec.go b/test/e2e/util/codec.go index 7fb561788..73e4bb911 100644 --- a/test/e2e/util/codec.go +++ b/test/e2e/util/codec.go @@ -22,7 +22,7 @@ func init() { } func initEncodingConfigAndCdc() (params.EncodingConfig, codec.Codec) { - encodingConfig := babylonApp.MakeTestEncodingConfig() + encodingConfig := babylonApp.GetEncodingConfig() encodingConfig.InterfaceRegistry.RegisterImplementations( (*sdk.Msg)(nil), diff --git a/test/utils.go b/test/utils.go index 532a78527..12bfec43b 100644 --- a/test/utils.go +++ b/test/utils.go @@ -8,12 +8,6 @@ import ( tm "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" - "github.com/babylonchain/babylon/app" - appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - btccheckpoint "github.com/babylonchain/babylon/x/btccheckpoint/types" - lightclient "github.com/babylonchain/babylon/x/btclightclient/types" "github.com/btcsuite/btcd/wire" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -22,6 +16,13 @@ import ( acctypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/tendermint/tendermint/types" "google.golang.org/grpc" + + "github.com/babylonchain/babylon/app" + appparams "github.com/babylonchain/babylon/app/params" + "github.com/babylonchain/babylon/testutil/datagen" + bbn "github.com/babylonchain/babylon/types" + btccheckpoint "github.com/babylonchain/babylon/x/btccheckpoint/types" + lightclient "github.com/babylonchain/babylon/x/btclightclient/types" ) type TestTxSender struct { @@ -37,7 +38,7 @@ func NewTestTxSender( genesisPath string, conn *grpc.ClientConn, ) (*TestTxSender, error) { - cfg := app.MakeTestEncodingConfig() + cfg := app.GetEncodingConfig() kb, err := keyring.New("babylond", "test", keyringPath, nil, cfg.Marshaler) diff --git a/x/checkpointing/client/cli/tx_test.go b/x/checkpointing/client/cli/tx_test.go index c7150d3cc..155627884 100644 --- a/x/checkpointing/client/cli/tx_test.go +++ b/x/checkpointing/client/cli/tx_test.go @@ -22,11 +22,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/client/cli" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/privval" - testutilcli "github.com/babylonchain/babylon/testutil/cli" - checkpointcli "github.com/babylonchain/babylon/x/checkpointing/client/cli" abci "github.com/tendermint/tendermint/abci/types" tmconfig "github.com/tendermint/tendermint/config" tmbytes "github.com/tendermint/tendermint/libs/bytes" @@ -35,6 +30,12 @@ import ( rpcclientmock "github.com/tendermint/tendermint/rpc/client/mock" coretypes "github.com/tendermint/tendermint/rpc/core/types" tmtypes "github.com/tendermint/tendermint/types" + + "github.com/babylonchain/babylon/app" + "github.com/babylonchain/babylon/app/params" + "github.com/babylonchain/babylon/privval" + testutilcli "github.com/babylonchain/babylon/testutil/cli" + checkpointcli "github.com/babylonchain/babylon/x/checkpointing/client/cli" ) type mockTendermintRPC struct { @@ -70,7 +71,7 @@ type CLITestSuite struct { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = app.MakeTestEncodingConfig() + s.encCfg = app.GetEncodingConfig() s.kr = keyring.NewInMemory(s.encCfg.Marshaler) ctrl := gomock.NewController(s.T()) mockAccountRetriever := mocks.NewMockAccountRetriever(ctrl) diff --git a/x/epoching/simulation/decoder_test.go b/x/epoching/simulation/decoder_test.go index f8fc723d6..79f173215 100644 --- a/x/epoching/simulation/decoder_test.go +++ b/x/epoching/simulation/decoder_test.go @@ -2,17 +2,19 @@ package simulation_test import ( "fmt" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "testing" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/x/epoching/simulation" - "github.com/babylonchain/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" + + "github.com/babylonchain/babylon/app" + "github.com/babylonchain/babylon/x/epoching/simulation" + "github.com/babylonchain/babylon/x/epoching/types" ) // nolint:deadcode,unused,varcheck @@ -25,7 +27,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := app.MakeTestEncodingConfig().Marshaler + cdc := app.GetEncodingConfig().Marshaler dec := simulation.NewDecodeStore(cdc) epochNumber := uint64(123) diff --git a/x/zoneconcierge/keeper/keeper_test.go b/x/zoneconcierge/keeper/keeper_test.go index 12069d90f..eb69f4f86 100644 --- a/x/zoneconcierge/keeper/keeper_test.go +++ b/x/zoneconcierge/keeper/keeper_test.go @@ -4,12 +4,13 @@ import ( "encoding/json" "testing" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/datagen" - zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" sdk "github.com/cosmos/cosmos-sdk/types" ibctmtypes "github.com/cosmos/ibc-go/v5/modules/light-clients/07-tendermint/types" ibctesting "github.com/cosmos/ibc-go/v5/testing" + + "github.com/babylonchain/babylon/app" + "github.com/babylonchain/babylon/testutil/datagen" + zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" ) // SetupTest creates a coordinator with 2 test chains, and a ZoneConcierge keeper. @@ -20,7 +21,7 @@ func SetupTest(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain, *i ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(t, false) bbnApp = babylonApp - encCdc := app.MakeTestEncodingConfig() + encCdc := app.GetEncodingConfig() genesis := app.NewDefaultGenesisState(encCdc.Marshaler) return babylonApp, genesis } diff --git a/x/zoneconcierge/keeper/proof_tx_in_block_test.go b/x/zoneconcierge/keeper/proof_tx_in_block_test.go index 11944081a..889121542 100644 --- a/x/zoneconcierge/keeper/proof_tx_in_block_test.go +++ b/x/zoneconcierge/keeper/proof_tx_in_block_test.go @@ -4,8 +4,6 @@ import ( "fmt" "testing" - "github.com/babylonchain/babylon/app" - zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -13,12 +11,15 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/spf13/pflag" "github.com/stretchr/testify/require" + + "github.com/babylonchain/babylon/app" + zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" ) func TestProveTxInBlock(t *testing.T) { // setup virtual network cfg := network.DefaultConfig() - encodingCfg := app.MakeTestEncodingConfig() + encodingCfg := app.GetEncodingConfig() cfg.InterfaceRegistry = encodingCfg.InterfaceRegistry cfg.TxConfig = encodingCfg.TxConfig cfg.NumValidators = 2 diff --git a/x/zoneconcierge/module_ibc_packet_test.go b/x/zoneconcierge/module_ibc_packet_test.go index 468e766e3..01f56aacb 100644 --- a/x/zoneconcierge/module_ibc_packet_test.go +++ b/x/zoneconcierge/module_ibc_packet_test.go @@ -4,10 +4,11 @@ import ( "encoding/json" "math/rand" - "github.com/babylonchain/babylon/app" - zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v5/testing" + + "github.com/babylonchain/babylon/app" + zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" ) // SetupTest creates a coordinator with 2 test chains. @@ -17,7 +18,7 @@ func (suite *ZoneConciergeTestSuite) SetupTestForIBCPackets() { ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(suite.T(), false) suite.zcKeeper = babylonApp.ZoneConciergeKeeper - encCdc := app.MakeTestEncodingConfig() + encCdc := app.GetEncodingConfig() genesis := app.NewDefaultGenesisState(encCdc.Marshaler) return babylonApp, genesis } diff --git a/x/zoneconcierge/module_test.go b/x/zoneconcierge/module_test.go index 8289001a0..b15dc3320 100644 --- a/x/zoneconcierge/module_test.go +++ b/x/zoneconcierge/module_test.go @@ -7,8 +7,6 @@ import ( "testing" "time" - "github.com/babylonchain/babylon/app" - zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -26,6 +24,9 @@ import ( tmbytes "github.com/tendermint/tendermint/libs/bytes" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" + + "github.com/babylonchain/babylon/app" + zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" ) // ZoneConciergeTestSuite provides a test suite for IBC functionalities in ZoneConcierge @@ -65,7 +66,7 @@ func (suite *ZoneConciergeTestSuite) SetupTest() { ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(suite.T(), false) suite.zcKeeper = babylonApp.ZoneConciergeKeeper - encCdc := app.MakeTestEncodingConfig() + encCdc := app.GetEncodingConfig() return babylonApp, app.NewDefaultGenesisState(encCdc.Marshaler) } babylonChainID := ibctesting.GetChainID(1)