Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed Sep 9, 2021
1 parent 390ee63 commit c401c60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions x/genutil/client/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {

genFile := config.GenesisFile()
overwrite, _ := cmd.Flags().GetBool(FlagOverwrite)

stakingBondDenom, _ := cmd.Flags().GetString(FlagStakingBondDenom)

if !overwrite && tmos.FileExists(genFile) {
Expand All @@ -128,17 +127,20 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
appGenState := mbm.DefaultGenesis(cdc)

if stakingBondDenom != "" {
stakingRaw := appGenState[stakingtypes.ModuleName]
var stakingGenesis stakingtypes.GenesisState

stakingRaw := appGenState[stakingtypes.ModuleName]
err := clientCtx.Codec.UnmarshalJSON(stakingRaw, &stakingGenesis)
if err != nil {
return err
}

stakingGenesis.Params.BondDenom = stakingBondDenom
modifiedStakingStr, err := clientCtx.Codec.MarshalJSON(&stakingGenesis)
if err != nil {
return err
}

appGenState[stakingtypes.ModuleName] = modifiedStakingStr
}

Expand All @@ -162,6 +164,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
genDoc.ChainID = chainID
genDoc.Validators = nil
genDoc.AppState = appState

if err = genutil.ExportGenesisFile(genDoc, genFile); err != nil {
return errors.Wrap(err, "Failed to export gensis file")
}
Expand Down
6 changes: 5 additions & 1 deletion x/genutil/client/cli/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
"github.com/cosmos/cosmos-sdk/x/staking"
)

var testMbm = module.NewBasicManager(genutil.AppModuleBasic{})
var testMbm = module.NewBasicManager(
staking.AppModuleBasic{},
genutil.AppModuleBasic{},
)

func TestInitCmd(t *testing.T) {
tests := []struct {
Expand Down

0 comments on commit c401c60

Please sign in to comment.