Skip to content

Commit

Permalink
Merge PR #3765: testing sequence increment if not enough balance for …
Browse files Browse the repository at this point in the history
…send
  • Loading branch information
sunnya97 authored and jackzampolin committed Feb 28, 2019
1 parent 10bd98e commit 172e265
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions x/bank/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,36 @@ func getInitChainer(mapp *mock.App, keeper BaseKeeper) sdk.InitChainer {
}
}

func TestSendNotEnoughBalance(t *testing.T) {
mapp := getMockApp(t)
acc := &auth.BaseAccount{
Address: addr1,
Coins: sdk.Coins{sdk.NewInt64Coin("foocoin", 67)},
}

mock.SetGenesis(mapp, []auth.Account{acc})

ctxCheck := mapp.BaseApp.NewContext(true, abci.Header{})

res1 := mapp.AccountKeeper.GetAccount(ctxCheck, addr1)
require.NotNil(t, res1)
require.Equal(t, acc, res1.(*auth.BaseAccount))

origAccNum := res1.GetAccountNumber()
origSeq := res1.GetSequence()

sendMsg := NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)})
mock.SignCheckDeliver(t, mapp.Cdc, mapp.BaseApp, []sdk.Msg{sendMsg}, []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1)

mock.CheckBalance(t, mapp, addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 67)})

res2 := mapp.AccountKeeper.GetAccount(mapp.NewContext(true, abci.Header{}), addr1)
require.NotNil(t, res2)

require.True(t, res2.GetAccountNumber() == origAccNum)
require.True(t, res2.GetSequence() == origSeq+1)
}

func TestMsgMultiSendWithAccounts(t *testing.T) {
mapp := getMockApp(t)
acc := &auth.BaseAccount{
Expand Down

0 comments on commit 172e265

Please sign in to comment.