Merge pull request #102 from tendermint/bugfix/101-genesis-without-app-options
fix panic when genesis file does not include app_options (Fixes #101)
This commit is contained in:
commit
7624c66f98
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
3
app/testdata/genesis3.json
vendored
Normal file
3
app/testdata/genesis3.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"chain_id": "foo_bar_chain"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user