cosmos-sdk/cmd/gaia/app/app_test.go

34 lines
743 B
Go
Raw Normal View History

2018-04-06 22:12:00 -07:00
package app
import (
"github.com/cosmos/cosmos-sdk/wire"
2018-04-06 22:12:00 -07:00
"github.com/cosmos/cosmos-sdk/x/auth"
2018-04-06 22:50:46 -07:00
"github.com/cosmos/cosmos-sdk/x/stake"
2018-04-06 22:12:00 -07:00
abci "github.com/tendermint/tendermint/abci/types"
2018-04-06 22:12:00 -07:00
)
2018-04-06 22:50:46 -07:00
func setGenesis(gapp *GaiaApp, accs ...*auth.BaseAccount) error {
2018-04-06 22:12:00 -07:00
genaccs := make([]GenesisAccount, len(accs))
for i, acc := range accs {
genaccs[i] = NewGenesisAccount(acc)
}
genesisState := GenesisState{
2018-04-06 22:50:46 -07:00
Accounts: genaccs,
StakeData: stake.DefaultGenesisState(),
2018-04-06 22:12:00 -07:00
}
stateBytes, err := wire.MarshalJSONIndent(gapp.cdc, genesisState)
2018-04-06 22:12:00 -07:00
if err != nil {
return err
}
// Initialize the chain
vals := []abci.Validator{}
2018-06-04 16:42:01 -07:00
gapp.InitChain(abci.RequestInitChain{Validators: vals, AppStateBytes: stateBytes})
2018-04-06 22:12:00 -07:00
gapp.Commit()
return nil
}