Skip to content

Commit

Permalink
Merge PR: Fix lcd test unexpected slashing in TestBonding
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelrozanski authored and cwgoes committed Feb 22, 2019
1 parent 0611d2e commit b823203
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ decoded automatically.

### SDK

* \#3559 fix occasional failing due to non-determinism in lcd test TestBonding
where validator is unexpectedly slashed throwing off test calculations
* [\#3411] Include the `RequestInitChain.Time` in the block header init during
`InitChain`.

Expand Down
12 changes: 10 additions & 2 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,18 @@ func TestBonding(t *testing.T) {
require.Equal(t, resultTx.Height, txs[0].Height)

// query delegations, unbondings and redelegations from validator and delegator
rdShares := rdTokens.ToDec()
delegatorDels = getDelegatorDelegations(t, port, addr)
require.Len(t, delegatorDels, 1)
require.Equal(t, rdShares, delegatorDels[0].GetShares())
require.Equal(t, operAddrs[1], delegatorDels[0].ValidatorAddr)

// because the second validator never signs during these tests, if this
// this test takes a long time to run, eventually this second validator
// will get slashed, meaning that it's exchange rate is no-longer 1-to-1,
// hence we utilize the exchange rate in the following test

validator2 := getValidator(t, port, operAddrs[1])
delTokensAfterRedelegation := delegatorDels[0].GetShares().Mul(validator2.DelegatorShareExRate())
require.Equal(t, rdTokens.ToDec(), delTokensAfterRedelegation)

redelegation := getRedelegations(t, port, addr, operAddrs[0], operAddrs[1])
require.Len(t, redelegation, 1)
Expand Down

0 comments on commit b823203

Please sign in to comment.