Skip to content

Commit

Permalink
initchain panic makes validate genesis fail
Browse files Browse the repository at this point in the history
int
  • Loading branch information
rigelrozanski committed May 13, 2019
1 parent eb5f7a5 commit 5c0aa05
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions x/genutil/client/cli/validate_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import (
"os"

"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -45,6 +50,20 @@ func ValidateGenesisCmd(ctx *server.Context, cdc *codec.Codec, mbm sdk.ModuleBas
return fmt.Errorf("error validating genesis file %s: %s", genesis, err.Error())
}

// make sure initchain doesn't panic
db := db.NewMemDB()
gapp := app.NewGaiaApp(log.NewNopLogger(), db, nil, true, 0)
defaultGenesisBytes := cdc.MustMarshalJSON(mbm.DefaultGenesis())
cms := store.NewCommitMultiStore(db)
ctx := sdk.NewContext(cms, abci.Header{}, false, log.NewNopLogger())
req := abci.RequestInitChain{AppStateBytes: defaultGenesisBytes}
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("InitChainer panics %s", r)
}
}()
_ = gapp.InitChainer(ctx, req)

fmt.Printf("File at %s is a valid genesis file for gaiad\n", genesis)
return nil
},
Expand Down

0 comments on commit 5c0aa05

Please sign in to comment.