Skip to content

Commit

Permalink
Set chainID
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Mar 16, 2023
1 parent fd17566 commit fe9272b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 6 additions & 8 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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())
}
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)),
)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/wasmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions x/wasm/ibctesting/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ibctesting

import (
"fmt"
"github.com/cosmos/cosmos-sdk/baseapp"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fe9272b

Please sign in to comment.