Address PR comments
This commit is contained in:
parent
dbe7744b14
commit
3630cde63e
|
@ -38,7 +38,7 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in
|
|||
// NOTE: Correctness dependent on invariant that unbonding delegations / redelegations must also have been completely
|
||||
// slashed in this case - which we don't explicitly check, but should be true.
|
||||
// Log the slash attempt for future reference (maybe we should tag it too)
|
||||
logger.Info(fmt.Sprintf("Ignored attempt to slash a nonexistent validator with address %s", pubkey.Address()))
|
||||
logger.Error(fmt.Sprintf("WARNING: Ignored attempt to slash a nonexistent validator with address %s, we recommend you investigate immediately", pubkey.Address()))
|
||||
return
|
||||
}
|
||||
ownerAddress := validator.GetOwner()
|
||||
|
|
|
@ -93,7 +93,7 @@ func TestUpdateValidatorByPowerIndex(t *testing.T) {
|
|||
require.True(t, keeper.validatorByPowerIndexExists(ctx, power))
|
||||
}
|
||||
|
||||
func TestZeroPowerUnbonded(t *testing.T) {
|
||||
func TestSlashToZeroPowerRemoved(t *testing.T) {
|
||||
// initialize setup
|
||||
ctx, _, keeper := CreateTestInput(t, false, 100)
|
||||
pool := keeper.GetPool(ctx)
|
||||
|
@ -105,15 +105,13 @@ func TestZeroPowerUnbonded(t *testing.T) {
|
|||
require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).RoundInt64())
|
||||
keeper.SetPool(ctx, pool)
|
||||
keeper.SetValidatorByPubKeyIndex(ctx, validator)
|
||||
keeper.UpdateValidator(ctx, validator)
|
||||
validator, found := keeper.GetValidator(ctx, addrVals[0])
|
||||
require.True(t, found)
|
||||
validator = keeper.UpdateValidator(ctx, validator)
|
||||
require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).RoundInt64(), "\nvalidator %v\npool %v", validator, pool)
|
||||
|
||||
// slash the validator by 100%
|
||||
keeper.Slash(ctx, PKs[0], 0, 100, sdk.OneRat())
|
||||
// validator should have been deleted
|
||||
_, found = keeper.GetValidator(ctx, addrVals[0])
|
||||
_, found := keeper.GetValidator(ctx, addrVals[0])
|
||||
require.False(t, found)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue