diff --git a/app/app.go b/app/app.go index 41afa325b..1d472dedd 100644 --- a/app/app.go +++ b/app/app.go @@ -40,6 +40,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/codec" @@ -47,6 +48,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" + "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -238,8 +240,6 @@ type App struct { interfaceRegistry types.InterfaceRegistry txConfig client.TxConfig - invCheckPeriod uint - // keys to access the substores keys map[string]*storetypes.KVStoreKey tkeys map[string]*storetypes.TransientStoreKey @@ -326,8 +326,7 @@ func init() { // New returns a reference to an initialized Provenance Blockchain App. func New( - logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool, - homePath string, invCheckPeriod uint, + logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *App { signingOptions := signing.Options{ @@ -395,7 +394,6 @@ func New( legacyAmino: legacyAmino, appCodec: appCodec, interfaceRegistry: interfaceRegistry, - invCheckPeriod: invCheckPeriod, keys: keys, tkeys: tkeys, memKeys: memKeys, @@ -476,11 +474,21 @@ func New( appCodec, legacyAmino, runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, govAuthority, ) - app.CrisisKeeper = crisiskeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[crisistypes.StoreKey]), app.invCheckPeriod, + invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) + app.CrisisKeeper = crisiskeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, govAuthority, app.AccountKeeper.AddressCodec()) app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[feegrant.StoreKey]), app.AccountKeeper) + // get skipUpgradeHeights from the app options + skipUpgradeHeights := make(map[int64]bool) + for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { + skipUpgradeHeights[int64(h)] = true + } + homePath := cast.ToString(appOpts.Get(flags.FlagHome)) + if len(homePath) == 0 { + homePath = DefaultNodeHome + } app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, govAuthority) app.MsgFeesKeeper = msgfeeskeeper.NewKeeper( diff --git a/app/app_test.go b/app/app_test.go index 83efbca2c..d9b8b5199 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -28,12 +28,9 @@ import ( func TestSimAppExportAndBlockedAddrs(t *testing.T) { opts := SetupOptions{ - Logger: log.NewTestLogger(t), - DB: dbm.NewMemDB(), - InvCheckPeriod: 0, - HomePath: t.TempDir(), - SkipUpgradeHeights: map[int64]bool{}, - AppOpts: simtestutil.EmptyAppOptions{}, + Logger: log.NewTestLogger(t), + DB: dbm.NewMemDB(), + AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), } app := NewAppWithCustomOptions(t, false, opts) @@ -54,8 +51,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { app.Commit() // Making a new app object with the db, so that initchain hasn't been called - app2 := New(log.NewTestLogger(t), opts.DB, nil, true, - map[int64]bool{}, opts.HomePath, 0, simtestutil.EmptyAppOptions{}) + app2 := New(log.NewTestLogger(t), opts.DB, nil, true, opts.AppOpts) require.NotPanics(t, func() { _, err = app2.ExportAppStateAndValidators(false, nil, nil) }, "exporting app state at current height") @@ -74,12 +70,9 @@ func TestGetMaccPerms(t *testing.T) { func TestExportAppStateAndValidators(t *testing.T) { opts := SetupOptions{ - Logger: log.NewTestLogger(t), - DB: dbm.NewMemDB(), - InvCheckPeriod: 0, - HomePath: t.TempDir(), - SkipUpgradeHeights: map[int64]bool{}, - AppOpts: simtestutil.EmptyAppOptions{}, + Logger: log.NewTestLogger(t), + DB: dbm.NewMemDB(), + AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), } app := NewAppWithCustomOptions(t, false, opts) ctx := app.BaseApp.NewContext(false) diff --git a/app/sim_bench_test.go b/app/sim_bench_test.go index eb2d87bbc..62624cc7a 100644 --- a/app/sim_bench_test.go +++ b/app/sim_bench_test.go @@ -12,7 +12,6 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" - simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli" ) // Profile with: @@ -37,7 +36,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { } }() - app := New(logger, db, nil, true, map[int64]bool{}, b.TempDir(), simcli.FlagPeriodValue, simtestutil.EmptyAppOptions{}, interBlockCacheOpt()) + app := New(logger, db, nil, true, newSimAppOpts(b), interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( @@ -86,7 +85,7 @@ func BenchmarkInvariants(b *testing.B) { } }() - app := New(logger, db, nil, true, map[int64]bool{}, b.TempDir(), simcli.FlagPeriodValue, simtestutil.EmptyAppOptions{}, interBlockCacheOpt()) + app := New(logger, db, nil, true, newSimAppOpts(b), interBlockCacheOpt()) // run randomized simulation _, lastBlockTime, simParams, simErr := simulation.SimulateFromSeedProv( diff --git a/app/sim_test.go b/app/sim_test.go index 32a40417b..158812f21 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -14,7 +14,6 @@ import ( "time" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -178,6 +177,14 @@ func printDBInfo(db dbm.DB) { fmt.Println("-^^^- Database Info -^^^-") } +// newSimAppOpts creates a new set of AppOptions with a temp dir for home, and the desired invariant check period. +func newSimAppOpts(t testing.TB) simtestutil.AppOptionsMap { + return simtestutil.AppOptionsMap{ + flags.FlagHome: t.TempDir(), + server.FlagInvCheckPeriod: simcli.FlagPeriodValue, + } +} + func TestFullAppSimulation(t *testing.T) { config, db, dir, logger, skip, err := setupSimulation("leveldb-app-sim", "Simulation") if skip { @@ -191,7 +198,7 @@ func TestFullAppSimulation(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() - app := New(logger, db, nil, true, map[int64]bool{}, t.TempDir(), simcli.FlagPeriodValue, simtestutil.EmptyAppOptions{}, fauxMerkleModeOpt) + app := New(logger, db, nil, true, newSimAppOpts(t), fauxMerkleModeOpt) require.Equal(t, "provenanced", app.Name()) fmt.Printf("running provenance full app simulation\n") @@ -230,7 +237,7 @@ func TestSimple(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() - app := New(logger, db, nil, true, map[int64]bool{}, t.TempDir(), simcli.FlagPeriodValue, simtestutil.EmptyAppOptions{}, fauxMerkleModeOpt) + app := New(logger, db, nil, true, newSimAppOpts(t), fauxMerkleModeOpt) require.Equal(t, "provenanced", app.Name()) // run randomized simulation @@ -268,12 +275,12 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() - home := t.TempDir() - appOptions := make(simtestutil.AppOptionsMap) - appOptions[flags.FlagHome] = home - appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue - - app := New(logger, db, nil, true, map[int64]bool{}, home, simcli.FlagPeriodValue, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(config.ChainID)) + appOpts := newSimAppOpts(t) + baseAppOpts := []func(*baseapp.BaseApp){ + fauxMerkleModeOpt, + baseapp.SetChainID(config.ChainID), + } + app := New(logger, db, nil, true, appOpts, baseAppOpts...) require.Equal(t, "provenanced", app.Name()) fmt.Printf("running provenance test import export\n") @@ -305,7 +312,7 @@ func TestAppImportExport(t *testing.T) { fmt.Printf("importing genesis...\n") - newDB, newDir, _, _, err := simtestutil.SetupSimulation(config, "leveldb-app-sim-2", "Simulation-2", simcli.FlagVerboseValue, simcli.FlagEnabledValue) + newDB, newDir, newLogger, _, err := simtestutil.SetupSimulation(config, "leveldb-app-sim-2", "Simulation-2", simcli.FlagVerboseValue, simcli.FlagEnabledValue) require.NoError(t, err, "simulation setup failed") defer func() { @@ -313,7 +320,7 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newApp := New(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, home, simcli.FlagPeriodValue, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(config.ChainID)) + newApp := New(newLogger, newDB, nil, true, appOpts, baseAppOpts...) var genesisState map[string]json.RawMessage err = json.Unmarshal(exported.AppState, &genesisState) @@ -396,8 +403,12 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() - home := t.TempDir() - app := New(logger, db, nil, true, map[int64]bool{}, home, simcli.FlagPeriodValue, simtestutil.EmptyAppOptions{}, fauxMerkleModeOpt) + appOpts := newSimAppOpts(t) + baseAppOpts := []func(*baseapp.BaseApp){ + fauxMerkleModeOpt, + baseapp.SetChainID(config.ChainID), + } + app := New(logger, db, nil, true, appOpts, baseAppOpts...) // Run randomized simulation stopEarly, lastBlockTime, simParams, simErr := simulation.SimulateFromSeedProv( @@ -431,7 +442,7 @@ func TestAppSimulationAfterImport(t *testing.T) { fmt.Printf("importing genesis...\n") - _, newDB, newDir, _, _, err := setupSimulation("leveldb-app-sim-2", "Simulation-2") + _, newDB, newDir, newLogger, _, err := setupSimulation("leveldb-app-sim-2", "Simulation-2") require.NoError(t, err, "simulation setup failed") defer func() { @@ -439,7 +450,7 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newApp := New(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, home, simcli.FlagPeriodValue, simtestutil.EmptyAppOptions{}, fauxMerkleModeOpt) + newApp := New(newLogger, newDB, nil, true, appOpts, baseAppOpts...) _, err = newApp.InitChain(&abci.RequestInitChain{ AppStateBytes: exported.AppState, @@ -500,13 +511,9 @@ func TestAppStateDeterminism(t *testing.T) { } } - home := t.TempDir() - - appOptions := viper.New() - appOptions.SetDefault(flags.FlagHome, home) - appOptions.SetDefault(server.FlagInvCheckPeriod, simcli.FlagPeriodValue) + appOpts := newSimAppOpts(t) if simcli.FlagVerboseValue { - appOptions.SetDefault(flags.FlagLogLevel, "debug") + appOpts[flags.FlagLogLevel] = "debug" } for i, seed := range seeds { @@ -522,7 +529,7 @@ func TestAppStateDeterminism(t *testing.T) { } db := dbm.NewMemDB() - app := New(logger, db, nil, true, map[int64]bool{}, home, simcli.FlagPeriodValue, appOptions, interBlockCacheOpt(), baseapp.SetChainID(config.ChainID)) + app := New(logger, db, nil, true, appOpts, interBlockCacheOpt(), baseapp.SetChainID(config.ChainID)) fmt.Printf( "running provenance non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", diff --git a/app/test_helpers.go b/app/test_helpers.go index 51f3d7de6..4ba5aa6d2 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -65,13 +65,10 @@ var DefaultConsensusParams = &cmttmtypes.ConsensusParams{ // SetupOptions defines arguments that are passed into `Simapp` constructor. type SetupOptions struct { - Logger log.Logger - DB *dbm.MemDB - InvCheckPeriod uint - HomePath string - SkipUpgradeHeights map[int64]bool - AppOpts servertypes.AppOptions - ChainID string + Logger log.Logger + DB *dbm.MemDB + AppOpts servertypes.AppOptions + ChainID string } func setup(t *testing.T, withGenesis bool, invCheckPeriod uint, chainID string) (*App, GenesisState) { @@ -81,7 +78,7 @@ func setup(t *testing.T, withGenesis bool, invCheckPeriod uint, chainID string) pioconfig.SetProvenanceConfig("", 0) } - app := New(loggerMaker(), db, nil, true, map[int64]bool{}, t.TempDir(), invCheckPeriod, simtestutil.EmptyAppOptions{}, baseapp.SetChainID(chainID)) + app := New(loggerMaker(), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), baseapp.SetChainID(chainID)) if withGenesis { return app, app.DefaultGenesis() } @@ -157,7 +154,7 @@ func NewAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptions) Coins: sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100_000_000_000_000)), } - app := New(options.Logger, options.DB, nil, true, options.SkipUpgradeHeights, options.HomePath, options.InvCheckPeriod, options.AppOpts) + app := New(options.Logger, options.DB, nil, true, options.AppOpts, baseapp.SetChainID(options.ChainID)) genesisState := app.DefaultGenesis() genesisState = genesisStateWithValSet(t, app, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) @@ -524,10 +521,6 @@ func MakeTestEncodingConfig(t *testing.T) params.EncodingConfig { } defer os.RemoveAll(tempDir) - tempApp := New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil, - tempDir, - 0, - simtestutil.EmptyAppOptions{}, - ) + tempApp := New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir)) return tempApp.GetEncodingConfig() } diff --git a/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index 7c53da56e..84e3c8441 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -2,7 +2,6 @@ package cmd import ( "context" - "errors" "fmt" "io" "os" @@ -75,11 +74,7 @@ func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) { // We initially set the config as testnet so commands that run before start work for testing such as gentx. app.SetConfig(true, false) - tempApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil, - tempDir, - 0, - simtestutil.EmptyAppOptions{}, - ) + tempApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir)) encodingConfig := tempApp.GetEncodingConfig() initClientCtx := client.Context{}. @@ -275,11 +270,6 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty cache = store.NewCommitKVStoreCacheManager() } - skipUpgradeHeights := make(map[int64]bool) - for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { - skipUpgradeHeights[int64(h)] = true - } - pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts) if err != nil { panic(err) @@ -310,10 +300,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) return app.New( - logger, db, traceStore, true, skipUpgradeHeights, - cast.ToString(appOpts.Get(flags.FlagHome)), - cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), - appOpts, + logger, db, traceStore, true, appOpts, baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))), @@ -362,19 +349,14 @@ func createAppAndExport( ) (servertypes.ExportedApp, error) { var a *app.App - homePath, ok := appOpts.Get(flags.FlagHome).(string) - if !ok || homePath == "" { - return servertypes.ExportedApp{}, errors.New("application home not set") - } - if height != -1 { - a = app.New(logger, db, traceStore, false, map[int64]bool{}, homePath, cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), appOpts) + a = app.New(logger, db, traceStore, false, appOpts) if err := a.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - a = app.New(logger, db, traceStore, true, map[int64]bool{}, homePath, cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), appOpts) + a = app.New(logger, db, traceStore, true, appOpts) } return a.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) diff --git a/cmd/provenanced/cmd/testnet_test.go b/cmd/provenanced/cmd/testnet_test.go index 3a9f44203..ac1162f82 100644 --- a/cmd/provenanced/cmd/testnet_test.go +++ b/cmd/provenanced/cmd/testnet_test.go @@ -38,11 +38,7 @@ func Test_TestnetCmd(t *testing.T) { pioconfig.SetProvenanceConfig("", 0) logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultCometConfig(home) - tempApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil, - home, - 0, - simtestutil.EmptyAppOptions{}, - ) + tempApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(home)) encodingConfig := tempApp.GetEncodingConfig() require.NoError(t, err) diff --git a/testutil/network.go b/testutil/network.go index ef08127ac..babc6f29a 100644 --- a/testutil/network.go +++ b/testutil/network.go @@ -34,8 +34,7 @@ func NewAppConstructor() testnet.AppConstructor { ctx := val.GetCtx() appCfg := val.GetAppConfig() return provenanceapp.New( - ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), ctx.Config.RootDir, 0, - simtestutil.EmptyAppOptions{}, + ctx.Logger, dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(ctx.Config.RootDir), baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(appCfg.Pruning)), baseapp.SetMinGasPrices(appCfg.MinGasPrices), baseapp.SetChainID(ctx.Viper.GetString(flags.FlagChainID)), @@ -51,10 +50,7 @@ func DefaultTestNetworkConfig() testnet.Config { } defer os.RemoveAll(tempDir) - tempApp := provenanceapp.New( - log.NewNopLogger(), dbm.NewMemDB(), nil, true, make(map[int64]bool), tempDir, 0, - simtestutil.NewAppOptionsWithFlagHome(tempDir), - ) + tempApp := provenanceapp.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir)) encCfg := tempApp.GetEncodingConfig() return testnet.Config{ diff --git a/x/ibchooks/ibc_middleware_test.go b/x/ibchooks/ibc_middleware_test.go index 38e1af349..2da8c2aac 100644 --- a/x/ibchooks/ibc_middleware_test.go +++ b/x/ibchooks/ibc_middleware_test.go @@ -13,6 +13,8 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -77,19 +79,22 @@ type HooksTestSuite struct { path *ibctesting.Path } -func SetupSimApp() (ibctesting.TestingApp, map[string]json.RawMessage) { - pioconfig.SetProvenanceConfig(sdk.DefaultBondDenom, 0) - db := dbm.NewMemDB() - provenanceApp := app.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, app.DefaultNodeHome, 5, simtestutil.EmptyAppOptions{}) - genesis := provenanceApp.DefaultGenesis() - return provenanceApp, genesis -} - -func init() { - ibctesting.DefaultTestingAppInit = SetupSimApp +func SetupSimAppFn(t *testing.T) func() (ibctesting.TestingApp, map[string]json.RawMessage) { + return func() (ibctesting.TestingApp, map[string]json.RawMessage) { + pioconfig.SetProvenanceConfig(sdk.DefaultBondDenom, 0) + db := dbm.NewMemDB() + appOpts := simtestutil.AppOptionsMap{ + flags.FlagHome: t.TempDir(), + server.FlagInvCheckPeriod: 5, + } + provenanceApp := app.New(log.NewNopLogger(), db, nil, true, appOpts) + genesis := provenanceApp.DefaultGenesis() + return provenanceApp, genesis + } } func (suite *HooksTestSuite) SetupTest() { + ibctesting.DefaultTestingAppInit = SetupSimAppFn(suite.T()) suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = &testutil.TestChain{ TestChain: suite.coordinator.GetChain(ibctesting.GetChainID(1)), diff --git a/x/ibchooks/marker_hooks_test.go b/x/ibchooks/marker_hooks_test.go index 37f81be80..52007cec3 100644 --- a/x/ibchooks/marker_hooks_test.go +++ b/x/ibchooks/marker_hooks_test.go @@ -40,11 +40,8 @@ type MarkerHooksTestSuite struct { path *ibctesting.Path } -func init() { - ibctesting.DefaultTestingAppInit = SetupSimApp -} - func (suite *MarkerHooksTestSuite) SetupTest() { + ibctesting.DefaultTestingAppInit = SetupSimAppFn(suite.T()) suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = &testutil.TestChain{ TestChain: suite.coordinator.GetChain(ibctesting.GetChainID(1)), diff --git a/x/ibcratelimit/module/ibc_middleware_test.go b/x/ibcratelimit/module/ibc_middleware_test.go index 56967ddf8..77a89ca5d 100644 --- a/x/ibcratelimit/module/ibc_middleware_test.go +++ b/x/ibcratelimit/module/ibc_middleware_test.go @@ -12,11 +12,14 @@ import ( "github.com/stretchr/testify/suite" + abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/log" sdkmath "cosmossdk.io/math" - abci "github.com/cometbft/cometbft/abci/types" dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" @@ -51,17 +54,23 @@ func TestMiddlewareTestSuite(t *testing.T) { suite.Run(t, new(MiddlewareTestSuite)) } -func SetupSimApp() (ibctesting.TestingApp, map[string]json.RawMessage) { - pioconfig.SetProvenanceConfig(sdk.DefaultBondDenom, 0) - db := dbm.NewMemDB() - provenanceApp := app.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, app.DefaultNodeHome, 5, simtestutil.EmptyAppOptions{}) - genesis := provenanceApp.DefaultGenesis() - return provenanceApp, genesis +func (suite *MiddlewareTestSuite) SetupSimAppFn() func() (ibctesting.TestingApp, map[string]json.RawMessage) { + return func() (ibctesting.TestingApp, map[string]json.RawMessage) { + pioconfig.SetProvenanceConfig(sdk.DefaultBondDenom, 0) + db := dbm.NewMemDB() + appOpts := simtestutil.AppOptionsMap{ + flags.FlagHome: suite.T().TempDir(), + server.FlagInvCheckPeriod: 5, + } + provenanceApp := app.New(log.NewNopLogger(), db, nil, true, appOpts) + genesis := provenanceApp.DefaultGenesis() + return provenanceApp, genesis + } } func (suite *MiddlewareTestSuite) SetupTest() { SkipIfWSL(suite.T()) - ibctesting.DefaultTestingAppInit = SetupSimApp + ibctesting.DefaultTestingAppInit = suite.SetupSimAppFn() suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = &testutil.TestChain{