From b09653c9ea29071c5c9035faa026ad58796ed47c Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 9 Feb 2018 18:04:18 +0100 Subject: [PATCH] Fix init state bug --- examples/basecoin/app/app_test.go | 4 ++-- examples/basecoin/app/init_baseapp.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/basecoin/app/app_test.go b/examples/basecoin/app/app_test.go index 9178820126..9749f4e3cf 100644 --- a/examples/basecoin/app/app_test.go +++ b/examples/basecoin/app/app_test.go @@ -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) } diff --git a/examples/basecoin/app/init_baseapp.go b/examples/basecoin/app/init_baseapp.go index 34272e6bb5..e1735d3ed2 100644 --- a/examples/basecoin/app/init_baseapp.go +++ b/examples/basecoin/app/init_baseapp.go @@ -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 })