Skip to content

Commit

Permalink
add chain-id to setup to prevent assert failure in chain Init()
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Mar 15, 2024
1 parent b61e496 commit fb4e389
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
11 changes: 6 additions & 5 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
sdkmath "cosmossdk.io/math"

dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
Expand Down Expand Up @@ -75,15 +76,15 @@ type SetupOptions struct {
ChainID string
}

func setup(t *testing.T, withGenesis bool, invCheckPeriod uint) (*App, GenesisState) {
func setup(t *testing.T, withGenesis bool, invCheckPeriod uint, chainID string) (*App, GenesisState) {
db := dbm.NewMemDB()
encCdc := MakeEncodingConfig()
// set default config if not set by the flow
if len(pioconfig.GetProvenanceConfig().FeeDenom) == 0 {
pioconfig.SetProvenanceConfig("", 0)
}

app := New(loggerMaker(), db, nil, true, map[int64]bool{}, t.TempDir(), invCheckPeriod, encCdc, simtestutil.EmptyAppOptions{})
app := New(loggerMaker(), db, nil, true, map[int64]bool{}, t.TempDir(), invCheckPeriod, encCdc, simtestutil.EmptyAppOptions{}, baseapp.SetChainID(chainID))
if withGenesis {
return app, NewDefaultGenesisState(encCdc.Marshaler)
}
Expand Down Expand Up @@ -264,7 +265,7 @@ func genesisStateWithValSet(t *testing.T,

// SetupQuerier initializes a new App without genesis and without calling InitChain.
func SetupQuerier(t *testing.T) *App {
app, _ := setup(t, false, 0)
app, _ := setup(t, false, 0, "")
return app
}

Expand All @@ -275,7 +276,7 @@ func SetupQuerier(t *testing.T) *App {
func SetupWithGenesisValSet(t *testing.T, chainID string, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *App {
t.Helper()

app, genesisState := setup(t, true, 5)
app, genesisState := setup(t, true, 5, chainID)
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
Expand Down Expand Up @@ -504,7 +505,7 @@ func SetupWithGenesisRewardsProgram(t *testing.T, nextRewardProgramID uint64, ge
}
}

app, genesisState := setup(t, true, 0)
app, genesisState := setup(t, true, 0, "")
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)
genesisState = genesisStateWithRewards(t, app, genesisState, nextRewardProgramID, genesisRewards)

Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ require (
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/go-metrics v0.5.2
github.com/otiai10/copy v1.14.0
github.com/rakyll/statik v0.1.7
github.com/rs/zerolog v1.32.0
github.com/spf13/cast v1.6.0
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,6 @@ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA=
github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs=
github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks=
github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM=
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
Expand Down

0 comments on commit fb4e389

Please sign in to comment.