diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 59c4259f3..98749c2b8 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -24,8 +24,8 @@ func TestWithdrawDelegationReward(t *testing.T) { amt := accMapper.GetAccount(ctx, delAddr1).GetCoins().AmountOf(denom) require.Equal(t, int64(90), amt.Int64()) - _ = keeper - //keeper.WithdrawDelegationReward(ctx, delAddr1, valAddr1) + + keeper.WithdrawDelegationReward(ctx, delAddr1, valAddr1) } func TestWithdrawDelegationRewardsAll(t *testing.T) { diff --git a/x/distribution/keeper/hooks.go b/x/distribution/keeper/hooks.go index a408b0d21..721a26db1 100644 --- a/x/distribution/keeper/hooks.go +++ b/x/distribution/keeper/hooks.go @@ -67,6 +67,8 @@ type Hooks struct { k Keeper } +var _ sdk.StakingHooks = Hooks{} + // New Validator Hooks func (k Keeper) Hooks() Hooks { return Hooks{k} } @@ -89,3 +91,7 @@ func (h Hooks) OnDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddres func (h Hooks) OnDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { h.k.onDelegationRemoved(ctx, delAddr, valAddr) } + +// nolint - unused hooks for interface +func (h Hooks) OnValidatorBonded(ctx sdk.Context, addr sdk.ConsAddress) {} +func (h Hooks) OnValidatorBeginUnbonding(ctx sdk.Context, addr sdk.ConsAddress) {} diff --git a/x/distribution/keeper/test_common.go b/x/distribution/keeper/test_common.go index 37c1b0d4b..95921068b 100644 --- a/x/distribution/keeper/test_common.go +++ b/x/distribution/keeper/test_common.go @@ -77,9 +77,15 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initCoins int64) ( db := dbm.NewMemDB() ms := store.NewCommitMultiStore(db) + + ms.MountStoreWithDB(tkeyDistr, sdk.StoreTypeTransient, nil) + ms.MountStoreWithDB(keyDistr, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(tkeyStake, sdk.StoreTypeTransient, nil) ms.MountStoreWithDB(keyStake, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyAcc, sdk.StoreTypeIAVL, db) + ms.MountStoreWithDB(keyFeeCollection, sdk.StoreTypeIAVL, db) + ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) + err := ms.LoadLatestVersion() require.Nil(t, err) @@ -107,5 +113,12 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initCoins int64) ( pk := params.NewKeeper(cdc, keyParams) keeper := NewKeeper(cdc, keyDistr, tkeyDistr, pk.Setter(), ck, sk, fck, types.DefaultCodespace) + // set the distribution hooks on staking + sk = sk.WithHooks(keeper.Hooks()) + + // set genesis items required for distribution + keeper.SetFeePool(ctx, types.InitialFeePool()) + keeper.SetCommunityTax(ctx, sdk.NewDecWithPrec(2, 2)) + return ctx, accountMapper, keeper, sk }