diff --git a/CHANGELOG.md b/CHANGELOG.md index e4c141631..4de7af20a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ BREAKING CHANGES * Remove go-wire, use go-amino * Gaia simple-staking bond and unbond functions replaced +* [stake] Delegator bonds now store the height at which they were updated * [store] Add `SubspaceIterator` and `ReverseSubspaceIterator` to `KVStore` interface * [basecoin] NewBasecoinApp takes a `dbm.DB` and uses namespaced DBs for substores * All module keepers now require a codespace, see basecoin or democoin for usage diff --git a/x/stake/handler_test.go b/x/stake/handler_test.go index 538c664e9..1240e4e6c 100644 --- a/x/stake/handler_test.go +++ b/x/stake/handler_test.go @@ -76,7 +76,10 @@ func TestIncrementsMsgDelegate(t *testing.T) { // just send the same msgbond multiple times msgDelegate := newTestMsgDelegate(delegatorAddr, candidateAddr, bondAmount) + for i := 0; i < 5; i++ { + ctx = ctx.WithBlockHeight(int64(i)) + got := handleMsgDelegate(ctx, msgDelegate, keeper) require.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got) @@ -90,6 +93,8 @@ func TestIncrementsMsgDelegate(t *testing.T) { expLiabilities := int64(i+2) * bondAmount // (1 self delegation) expDelegatorAcc := initBond - expBond + require.Equal(t, bond.Height, int64(i), "Incorrect bond height") + gotBond := bond.Shares.Evaluate() gotLiabilities := candidate.Liabilities.Evaluate() gotDelegatorAcc := accMapper.GetAccount(ctx, delegatorAddr).GetCoins().AmountOf(params.BondDenom) diff --git a/x/stake/keeper_test.go b/x/stake/keeper_test.go index 03431a403..e3edfbf9e 100644 --- a/x/stake/keeper_test.go +++ b/x/stake/keeper_test.go @@ -143,15 +143,6 @@ func TestBond(t *testing.T) { assert.True(t, found) assert.True(t, bondsEqual(bond1to1, resBond)) - // test height - ctx = ctx.WithBlockHeight(10) - keeper.setDelegatorBond(ctx, bond1to1) - resBond, found = keeper.GetDelegatorBond(ctx, addrDels[0], addrVals[0]) - assert.True(t, found) - assert.Equal(t, resBond.Height, 10) - ctx = ctx.WithBlockHeight(0) - keeper.setDelegatorBond(ctx, bond1to1) - // add some more records keeper.setCandidate(ctx, candidates[1]) keeper.setCandidate(ctx, candidates[2])