Skip to content

Commit

Permalink
Merge PR cosmos#3958: Fix lcd-testing 303030 bug continued
Browse files Browse the repository at this point in the history
* 303030 bug part 2

* further rearrange
  • Loading branch information
rigelrozanski authored Mar 21, 2019
1 parent 424adf1 commit 9b27901
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,21 @@ func TestBonding(t *testing.T) {
// test redelegation
rdTokens := sdk.TokensFromTendermintPower(30)
resultTx = doBeginRedelegation(t, port, name1, pw, addr, operAddrs[0], operAddrs[1], rdTokens, fees)
require.Equal(t, uint32(0), resultTx.Code)
tests.WaitForHeight(resultTx.Height+1, port)
validator2 := getValidator(t, port, operAddrs[1])

require.Equal(t, uint32(0), resultTx.Code)
// query delegations, unbondings and redelegations from validator and delegator
delegatorDels = getDelegatorDelegations(t, port, addr)
require.Len(t, delegatorDels, 1)
require.Equal(t, operAddrs[1], delegatorDels[0].ValidatorAddress)

// 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
delTokensAfterRedelegation := validator2.ShareTokens(delegatorDels[0].GetShares())
require.Equal(t, rdTokens.ToDec(), delTokensAfterRedelegation)

// verify balance after paying fees
acc = getAccount(t, port, addr)
Expand All @@ -542,20 +554,6 @@ func TestBonding(t *testing.T) {
require.Len(t, txs, 1)
require.Equal(t, resultTx.Height, txs[0].Height)

// query delegations, unbondings and redelegations from validator and delegator
delegatorDels = getDelegatorDelegations(t, port, addr)
require.Len(t, delegatorDels, 1)
require.Equal(t, operAddrs[1], delegatorDels[0].ValidatorAddress)

// 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 := validator2.ShareTokens(delegatorDels[0].GetShares())
require.Equal(t, rdTokens.ToDec(), delTokensAfterRedelegation)

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

0 comments on commit 9b27901

Please sign in to comment.