From 3630cde63e103a8f56e66102917a49c091d01164 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Sat, 7 Jul 2018 02:20:37 +0200 Subject: [PATCH] Address PR comments --- x/stake/keeper/slash.go | 2 +- x/stake/keeper/validator_test.go | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/x/stake/keeper/slash.go b/x/stake/keeper/slash.go index 75cc753a2..f194d656c 100644 --- a/x/stake/keeper/slash.go +++ b/x/stake/keeper/slash.go @@ -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() diff --git a/x/stake/keeper/validator_test.go b/x/stake/keeper/validator_test.go index 99cf6d450..8320f259c 100644 --- a/x/stake/keeper/validator_test.go +++ b/x/stake/keeper/validator_test.go @@ -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) }