Address PR comments

This commit is contained in:
Christopher Goes 2018-07-07 02:20:37 +02:00
parent dbe7744b14
commit 3630cde63e
2 changed files with 4 additions and 6 deletions

View File

@ -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 // 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. // 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) // 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 return
} }
ownerAddress := validator.GetOwner() ownerAddress := validator.GetOwner()

View File

@ -93,7 +93,7 @@ func TestUpdateValidatorByPowerIndex(t *testing.T) {
require.True(t, keeper.validatorByPowerIndexExists(ctx, power)) require.True(t, keeper.validatorByPowerIndexExists(ctx, power))
} }
func TestZeroPowerUnbonded(t *testing.T) { func TestSlashToZeroPowerRemoved(t *testing.T) {
// initialize setup // initialize setup
ctx, _, keeper := CreateTestInput(t, false, 100) ctx, _, keeper := CreateTestInput(t, false, 100)
pool := keeper.GetPool(ctx) pool := keeper.GetPool(ctx)
@ -105,15 +105,13 @@ func TestZeroPowerUnbonded(t *testing.T) {
require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).RoundInt64()) require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).RoundInt64())
keeper.SetPool(ctx, pool) keeper.SetPool(ctx, pool)
keeper.SetValidatorByPubKeyIndex(ctx, validator) keeper.SetValidatorByPubKeyIndex(ctx, validator)
keeper.UpdateValidator(ctx, validator) validator = keeper.UpdateValidator(ctx, validator)
validator, found := keeper.GetValidator(ctx, addrVals[0])
require.True(t, found)
require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).RoundInt64(), "\nvalidator %v\npool %v", validator, pool) require.Equal(t, int64(100), validator.PoolShares.Tokens(pool).RoundInt64(), "\nvalidator %v\npool %v", validator, pool)
// slash the validator by 100% // slash the validator by 100%
keeper.Slash(ctx, PKs[0], 0, 100, sdk.OneRat()) keeper.Slash(ctx, PKs[0], 0, 100, sdk.OneRat())
// validator should have been deleted // validator should have been deleted
_, found = keeper.GetValidator(ctx, addrVals[0]) _, found := keeper.GetValidator(ctx, addrVals[0])
require.False(t, found) require.False(t, found)
} }