From fe9272b97561d55122768a9ae80fea569f6a6dc0 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Thu, 16 Mar 2023 10:57:38 +0100 Subject: [PATCH] Set chainID --- app/test_helpers.go | 14 ++++++-------- cmd/wasmd/root.go | 2 +- x/wasm/ibctesting/endpoint.go | 2 ++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/test_helpers.go b/app/test_helpers.go index e6bed95dbe..edd84436c5 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -53,7 +53,8 @@ type SetupOptions struct { WasmOpts []wasm.Option } -func setup(t testing.TB, withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*WasmApp, GenesisState) { +func setup(t testing.TB, chainID string, withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*WasmApp, GenesisState) { + db := dbm.NewMemDB() nodeHome := t.TempDir() snapshotDir := filepath.Join(nodeHome, "data", "snapshots") @@ -62,15 +63,11 @@ func setup(t testing.TB, withGenesis bool, invCheckPeriod uint, opts ...wasm.Opt t.Cleanup(func() { snapshotDB.Close() }) snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir) require.NoError(t, err) - baseAppOpts := []func(*bam.BaseApp){bam.SetSnapshot(snapshotStore, snapshottypes.SnapshotOptions{KeepRecent: 2})} - db := dbm.NewMemDB() - t.Cleanup(func() { db.Close() }) appOptions := make(simtestutil.AppOptionsMap, 0) appOptions[flags.FlagHome] = nodeHome // ensure unique folder appOptions[server.FlagInvCheckPeriod] = invCheckPeriod - - app := NewWasmApp(log.NewNopLogger(), db, nil, true, wasmtypes.EnableAllProposals, appOptions, opts, baseAppOpts...) + app := NewWasmApp(log.NewNopLogger(), db, nil, true, wasmtypes.EnableAllProposals, appOptions, opts, bam.SetChainID(chainID), bam.SetSnapshot(snapshotStore, snapshottypes.SnapshotOptions{KeepRecent: 2})) if withGenesis { return app, NewDefaultGenesisState(app.AppCodec()) } @@ -151,7 +148,7 @@ func Setup(t *testing.T, opts ...wasm.Option) *WasmApp { func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasm.Option, balances ...banktypes.Balance) *WasmApp { t.Helper() - app, genesisState := setup(t, true, 5, opts...) + app, genesisState := setup(t, chainID, true, 5, opts...) genesisState, err := GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, genAccs, balances...) require.NoError(t, err) @@ -185,7 +182,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs // SetupWithEmptyStore set up a wasmd app instance with empty DB func SetupWithEmptyStore(t testing.TB) *WasmApp { - app, _ := setup(t, false, 0) + app, _ := setup(t, "testing", false, 0) return app } @@ -274,6 +271,7 @@ func NewTestNetworkFixture() network.TestFixture { emptyWasmOptions, bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices), + bam.SetChainID(val.GetCtx().Viper.GetString(flags.FlagChainID)), ) } diff --git a/cmd/wasmd/root.go b/cmd/wasmd/root.go index 9cc9c87a8b..95558a7794 100644 --- a/cmd/wasmd/root.go +++ b/cmd/wasmd/root.go @@ -57,7 +57,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { WithInput(os.Stdin). WithAccountRetriever(authtypes.AccountRetriever{}). WithHomeDir(app.DefaultNodeHome). - WithViper("") + WithViper("") // In wasmd, we don't use any prefix for env variables. rootCmd := &cobra.Command{ Use: version.AppName, diff --git a/x/wasm/ibctesting/endpoint.go b/x/wasm/ibctesting/endpoint.go index 48a6e05bd3..3f431dcc67 100644 --- a/x/wasm/ibctesting/endpoint.go +++ b/x/wasm/ibctesting/endpoint.go @@ -2,6 +2,7 @@ package ibctesting import ( "fmt" + "github.com/cosmos/cosmos-sdk/baseapp" "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -180,6 +181,7 @@ func (endpoint *Endpoint) UpgradeChain() error { } // update chain + baseapp.SetChainID(newChainID)(endpoint.Chain.App.BaseApp) endpoint.Chain.ChainID = newChainID endpoint.Chain.CurrentHeader.ChainID = newChainID endpoint.Chain.NextBlock() // commit changes