From ec42e6650156b4f768e138231df5971a1d6b284e Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Mon, 27 Aug 2018 00:20:40 -0400 Subject: [PATCH] fix old tests --- x/slashing/keeper_test.go | 6 +++--- x/slashing/tick_test.go | 2 +- x/stake/handler_test.go | 4 ++-- x/stake/keeper/validator_test.go | 14 ++++++++------ x/stake/types/validator.go | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/x/slashing/keeper_test.go b/x/slashing/keeper_test.go index 808c82014..6e9765ab2 100644 --- a/x/slashing/keeper_test.go +++ b/x/slashing/keeper_test.go @@ -114,7 +114,7 @@ func TestHandleAbsentValidator(t *testing.T) { // validator should have been jailed validator, _ = sk.GetValidatorByPubKey(ctx, val) - require.Equal(t, sdk.Unbonded, validator.GetStatus()) + require.Equal(t, sdk.Unbonding, validator.GetStatus()) // unrevocation should fail prior to jail expiration got = slh(ctx, NewMsgUnjail(addr)) @@ -161,7 +161,7 @@ func TestHandleAbsentValidator(t *testing.T) { keeper.handleValidatorSignature(ctx, val.Address(), amtInt, false) } validator, _ = sk.GetValidatorByPubKey(ctx, val) - require.Equal(t, sdk.Unbonded, validator.GetStatus()) + require.Equal(t, sdk.Unbonding, validator.GetStatus()) } // Test a new validator entering the validator set @@ -230,7 +230,7 @@ func TestHandleAlreadyJailed(t *testing.T) { // validator should have been jailed and slashed validator, _ := sk.GetValidatorByPubKey(ctx, val) - require.Equal(t, sdk.Unbonded, validator.GetStatus()) + require.Equal(t, sdk.Unbonding, validator.GetStatus()) // validator should have been slashed require.Equal(t, int64(amtInt-1), validator.GetTokens().RoundInt64()) diff --git a/x/slashing/tick_test.go b/x/slashing/tick_test.go index 78d269549..9a8eaf4ff 100644 --- a/x/slashing/tick_test.go +++ b/x/slashing/tick_test.go @@ -80,5 +80,5 @@ func TestBeginBlocker(t *testing.T) { // validator should be jailed validator, found := sk.GetValidatorByPubKey(ctx, pk) require.True(t, found) - require.Equal(t, sdk.Unbonded, validator.GetStatus()) + require.Equal(t, sdk.Unbonding, validator.GetStatus()) } diff --git a/x/stake/handler_test.go b/x/stake/handler_test.go index 6ab54e48c..f0fce9dcb 100644 --- a/x/stake/handler_test.go +++ b/x/stake/handler_test.go @@ -85,8 +85,8 @@ func TestValidatorByPowerIndex(t *testing.T) { keeper.Jail(ctx, keep.PKs[0]) validator, found = keeper.GetValidator(ctx, validatorAddr) require.True(t, found) - require.Equal(t, sdk.Unbonded, validator.Status) // ensure is unbonded - require.Equal(t, int64(500000), validator.Tokens.RoundInt64()) // ensure is unbonded + require.Equal(t, sdk.Unbonding, validator.Status) // ensure is unbonding + require.Equal(t, int64(500000), validator.Tokens.RoundInt64()) // ensure tokens slashed // the old power record should have been deleted as the power changed require.False(t, keep.ValidatorByPowerIndexExists(ctx, keeper, power)) diff --git a/x/stake/keeper/validator_test.go b/x/stake/keeper/validator_test.go index 54149707e..dee822366 100644 --- a/x/stake/keeper/validator_test.go +++ b/x/stake/keeper/validator_test.go @@ -137,7 +137,7 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) { expectedValStatus := map[int]sdk.BondStatus{ 9: sdk.Bonded, 8: sdk.Bonded, 7: sdk.Bonded, 5: sdk.Bonded, 4: sdk.Bonded, - 0: sdk.Unbonded, 1: sdk.Unbonded, 2: sdk.Unbonded, 3: sdk.Unbonded, 6: sdk.Unbonded, + 0: sdk.Unbonding, 1: sdk.Unbonding, 2: sdk.Unbonding, 3: sdk.Unbonding, 6: sdk.Unbonding, } // require all the validators have their respective statuses @@ -145,9 +145,11 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) { valAddr := validators[valIdx].Operator val, _ := keeper.GetValidator(ctx, valAddr) - require.Equal( - t, val.GetStatus(), status, - fmt.Sprintf("expected validator to have status: %s", sdk.BondStatusToString(status))) + assert.Equal( + t, status, val.GetStatus(), + fmt.Sprintf("expected validator at index %v to have status: %s", + valIdx, + sdk.BondStatusToString(status))) } } @@ -610,8 +612,8 @@ func TestFullValidatorSetPowerChange(t *testing.T) { validators[i], found = keeper.GetValidator(ctx, validators[i].Operator) require.True(t, found) } - assert.Equal(t, sdk.Unbonded, validators[0].Status) - assert.Equal(t, sdk.Unbonded, validators[1].Status) + assert.Equal(t, sdk.Unbonding, validators[0].Status) + assert.Equal(t, sdk.Unbonding, validators[1].Status) assert.Equal(t, sdk.Bonded, validators[2].Status) assert.Equal(t, sdk.Bonded, validators[3].Status) assert.Equal(t, sdk.Unbonded, validators[4].Status) diff --git a/x/stake/types/validator.go b/x/stake/types/validator.go index db9c8afd5..c8868a56c 100644 --- a/x/stake/types/validator.go +++ b/x/stake/types/validator.go @@ -161,7 +161,7 @@ func (v Validator) HumanReadableString() (string, error) { resp += fmt.Sprintf("Description: %s\n", v.Description) resp += fmt.Sprintf("Bond Height: %d\n", v.BondHeight) resp += fmt.Sprintf("Unbonding Height: %d\n", v.UnbondingHeight) - resp += fmt.Sprintf("Minimum Unbonding Time: %d\n", v.UnbondingMinTime) + resp += fmt.Sprintf("Minimum Unbonding Time: %v\n", v.UnbondingMinTime) resp += fmt.Sprintf("Commission: %s\n", v.Commission.String()) resp += fmt.Sprintf("Max Commission Rate: %s\n", v.CommissionMax.String()) resp += fmt.Sprintf("Commission Change Rate: %s\n", v.CommissionChangeRate.String())