Skip to content

Commit

Permalink
fix(test): allow default genesis creation in testutil
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Jan 17, 2024
1 parent dca3eb2 commit bb35f38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ package app

import (
"encoding/json"
"testing"

"cosmossdk.io/log"

dbm "github.com/cosmos/cosmos-db"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"

"github.com/cosmos/cosmos-sdk/codec"
)
Expand All @@ -15,7 +21,8 @@ import (
// object provided to it during init.
type GenesisState map[string]json.RawMessage

// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState {
return ModuleBasics.DefaultGenesis(cdc)
// NewDefaultGenesisState generates the default state for the application, for testing purpose.
func NewDefaultGenesisState(t testing.TB, cdc codec.JSONCodec) GenesisState {
tempApp := New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()))
return tempApp.BasicModuleManager.DefaultGenesis(cdc)
}
2 changes: 1 addition & 1 deletion testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func DefaultConfig(t *testing.T) network.Config {
baseapp.SetChainID(chainID),
)
},
GenesisState: app.NewDefaultGenesisState(encoding.Codec),
GenesisState: app.NewDefaultGenesisState(t, encoding.Codec),
TimeoutCommit: 2 * time.Second,
ChainID: chainID,
NumValidators: 1,
Expand Down

0 comments on commit bb35f38

Please sign in to comment.