Fix ForceUnbond() testcase
This commit is contained in:
parent
e614799d0f
commit
97b084b842
|
@ -120,6 +120,8 @@ func TestHandleAbsentValidator(t *testing.T) {
|
||||||
// should be bonded still
|
// should be bonded still
|
||||||
validator := sk.ValidatorByPubKey(ctx, val)
|
validator := sk.ValidatorByPubKey(ctx, val)
|
||||||
require.Equal(t, sdk.Bonded, validator.GetStatus())
|
require.Equal(t, sdk.Bonded, validator.GetStatus())
|
||||||
|
pool := sk.GetPool(ctx)
|
||||||
|
require.Equal(t, int64(210), pool.BondedTokens)
|
||||||
// 51st block missed
|
// 51st block missed
|
||||||
ctx = ctx.WithBlockHeight(height)
|
ctx = ctx.WithBlockHeight(height)
|
||||||
keeper.handleValidatorSignature(ctx, val, false)
|
keeper.handleValidatorSignature(ctx, val, false)
|
||||||
|
@ -138,8 +140,9 @@ func TestHandleAbsentValidator(t *testing.T) {
|
||||||
require.True(t, got.IsOK()) // should succeed after jail expiration
|
require.True(t, got.IsOK()) // should succeed after jail expiration
|
||||||
validator = sk.ValidatorByPubKey(ctx, val)
|
validator = sk.ValidatorByPubKey(ctx, val)
|
||||||
require.Equal(t, sdk.Bonded, validator.GetStatus())
|
require.Equal(t, sdk.Bonded, validator.GetStatus())
|
||||||
|
pool = sk.GetPool(ctx)
|
||||||
// should have been slashed
|
// should have been slashed
|
||||||
require.Equal(t, sdk.NewRat(amt).Mul(sdk.NewRat(99).Quo(sdk.NewRat(100))), sk.Validator(ctx, addr).GetPower())
|
require.Equal(t, int64(208), pool.BondedTokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPubKey(pk string) (res crypto.PubKey) {
|
func newPubKey(pk string) (res crypto.PubKey) {
|
||||||
|
|
|
@ -220,9 +220,7 @@ func (k Keeper) updateValidator(ctx sdk.Context, validator Validator) Validator
|
||||||
oldValidator, oldFound := k.GetValidator(ctx, ownerAddr)
|
oldValidator, oldFound := k.GetValidator(ctx, ownerAddr)
|
||||||
|
|
||||||
if validator.Revoked && oldValidator.Status() == sdk.Bonded {
|
if validator.Revoked && oldValidator.Status() == sdk.Bonded {
|
||||||
fmt.Printf("val preupdate: %v\n", validator)
|
|
||||||
validator, pool = validator.UpdateStatus(pool, sdk.Unbonded)
|
validator, pool = validator.UpdateStatus(pool, sdk.Unbonded)
|
||||||
fmt.Printf("val postupdate: %v\n", validator)
|
|
||||||
k.setPool(ctx, pool)
|
k.setPool(ctx, pool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue