diff --git a/app/genesis.go b/app/genesis.go index fa6a5ac3053b..3901fa68985e 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -37,6 +37,7 @@ func (app *Basecoin) LoadGenesis(path string) error { r := app.SetOption(kv.Key, kv.Value) app.logger.Info("Done setting Plugin key-value pair via SetOption", "result", r, "k", kv.Key, "v", kv.Value) } + return nil } @@ -71,6 +72,10 @@ func loadGenesis(filePath string) (*FullGenesisDoc, error) { return nil, errors.Wrap(err, "unmarshaling genesis file") } + if genDoc.AppOptions == nil { + genDoc.AppOptions = new(GenesisDoc) + } + pluginOpts, err := parseGenesisList(genDoc.AppOptions.PluginOptions) if err != nil { return nil, err diff --git a/app/genesis_test.go b/app/genesis_test.go index b2a590bcf3d9..dc398afd971f 100644 --- a/app/genesis_test.go +++ b/app/genesis_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/basecoin/types" - "github.com/tendermint/go-crypto" + crypto "github.com/tendermint/go-crypto" eyescli "github.com/tendermint/merkleeyes/client" cmn "github.com/tendermint/tmlibs/common" ) @@ -16,6 +16,13 @@ import ( const genesisFilepath = "./testdata/genesis.json" const genesisAcctFilepath = "./testdata/genesis2.json" +func TestLoadGenesisDoNotFailIfAppOptionsAreMissing(t *testing.T) { + eyesCli := eyescli.NewLocalClient("", 0) + app := NewBasecoin(eyesCli) + err := app.LoadGenesis("./testdata/genesis3.json") + require.Nil(t, err, "%+v", err) +} + func TestLoadGenesis(t *testing.T) { assert, require := assert.New(t), require.New(t) diff --git a/app/testdata/genesis3.json b/app/testdata/genesis3.json new file mode 100644 index 000000000000..b58b1d740256 --- /dev/null +++ b/app/testdata/genesis3.json @@ -0,0 +1,3 @@ +{ + "chain_id": "foo_bar_chain" +}