From 7ee50eacf2fee5494978b8bb316a70f37b2b8bda Mon Sep 17 00:00:00 2001 From: Jonathan Gimeno Date: Mon, 24 Feb 2020 18:43:51 +0100 Subject: [PATCH] refactor TestSlashAtFutureHeight test --- x/staking/keeper/old_slash_test.go | 8 -------- x/staking/keeper/slash_test.go | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/x/staking/keeper/old_slash_test.go b/x/staking/keeper/old_slash_test.go index bd311491b..f59ad9f80 100644 --- a/x/staking/keeper/old_slash_test.go +++ b/x/staking/keeper/old_slash_test.go @@ -37,14 +37,6 @@ func setupHelper(t *testing.T, power int64) (sdk.Context, Keeper, types.Params) //_________________________________________________________________________________ -// tests Slash at a future height (must panic) -func TestSlashAtFutureHeight(t *testing.T) { - ctx, keeper, _ := setupHelper(t, 10) - consAddr := sdk.ConsAddress(PKs[0].Address()) - fraction := sdk.NewDecWithPrec(5, 1) - require.Panics(t, func() { keeper.Slash(ctx, consAddr, 1, 10, fraction) }) -} - // test slash at a negative height // this just represents pre-genesis and should have the same effect as slashing at height 0 func TestSlashAtNegativeHeight(t *testing.T) { diff --git a/x/staking/keeper/slash_test.go b/x/staking/keeper/slash_test.go index 15d735bbe..3aed1a8e1 100644 --- a/x/staking/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -180,3 +180,12 @@ func TestSlashRedelegation(t *testing.T) { burnedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), slashAmount)) require.Equal(t, balances.Sub(burnedCoins), app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress())) } + +// tests Slash at a future height (must panic) +func TestSlashAtFutureHeight(t *testing.T) { + app, ctx, _, _ := initConfig(t, 10) + + consAddr := sdk.ConsAddress(PKs[0].Address()) + fraction := sdk.NewDecWithPrec(5, 1) + require.Panics(t, func() { app.StakingKeeper.Slash(ctx, consAddr, 1, 10, fraction) }) +}