Fix init state bug

This commit is contained in:
Ethan Frey 2018-02-09 18:04:18 +01:00
parent fd1684ab6b
commit b09653c9ea
2 changed files with 7 additions and 7 deletions

View File

@ -57,7 +57,7 @@ func TestSendMsg(t *testing.T) {
PubKey: pk,
Sequence: 0,
}
acc := types.AppAccount{baseAcc, "foobart"}
acc := &types.AppAccount{baseAcc, "foobart"}
gaccs := []*GenesisAccount{
NewGenesisAccount(acc),
@ -71,5 +71,5 @@ func TestSendMsg(t *testing.T) {
require.Nil(t, err)
res1 := app.accountMapper.GetAccount(ctxDeliverTx, baseAcc.Address)
assert.Equal(t, baseAcc, res1)
assert.Equal(t, acc, res1)
}

View File

@ -43,7 +43,7 @@ type GenesisAccount struct {
Sequence int64 `json:"sequence"`
}
func NewGenesisAccount(aa types.AppAccount) *GenesisAccount {
func NewGenesisAccount(aa *types.AppAccount) *GenesisAccount {
return &GenesisAccount{
Name: aa.Name,
Address: aa.Address,
@ -54,7 +54,7 @@ func NewGenesisAccount(aa types.AppAccount) *GenesisAccount {
}
// convert GenesisAccount to AppAccount
func (ga *GenesisAccount) toAppAccount() (acc types.AppAccount, err error) {
func (ga *GenesisAccount) toAppAccount() (acc *types.AppAccount, err error) {
pk, err := crypto.PubKeyFromBytes(ga.PubKey)
if err != nil {
@ -66,7 +66,7 @@ func (ga *GenesisAccount) toAppAccount() (acc types.AppAccount, err error) {
PubKey: pk,
Sequence: ga.Sequence,
}
return types.AppAccount{
return &types.AppAccount{
BaseAccount: baseAcc,
Name: "foobart",
}, nil
@ -93,8 +93,8 @@ func (app *BasecoinApp) initBaseAppInitStater() {
if err != nil {
return sdk.ErrGenesisParse("").TraceCause(err, "")
}
accountMapper.SetAccount(ctxCheckTx, acc.BaseAccount)
accountMapper.SetAccount(ctxDeliverTx, acc.BaseAccount)
accountMapper.SetAccount(ctxCheckTx, acc)
accountMapper.SetAccount(ctxDeliverTx, acc)
}
return nil
})