Skip to content

Commit

Permalink
CNS-872: PR fix
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-lava committed Mar 6, 2024
1 parent 38f4d48 commit 85ba689
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions testutil/common/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ func (ts *Tester) GetBalance(accAddr sdk.AccAddress) int64 {
return ts.Keepers.BankKeeper.GetBalance(ts.Ctx, accAddr, denom).Amount.Int64()
}

func (ts *Tester) GetBalances(accAddr sdk.AccAddress) sdk.Coins {
return ts.Keepers.BankKeeper.GetAllBalances(ts.Ctx, accAddr)
}

func (ts *Tester) FindPlan(index string, block uint64) (planstypes.Plan, bool) {
return ts.Keepers.Plans.FindPlan(ts.Ctx, index, block)
}
Expand Down
3 changes: 3 additions & 0 deletions x/rewards/keeper/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ func (ts *tester) setupForIprpcTests(fundIprpcPool bool) {
duration := uint64(1)
err = ts.Keepers.BankKeeper.AddToBalance(consumerAcc.Addr, iprpcFunds.MulInt(sdk.NewIntFromUint64(duration)))
require.NoError(ts.T, err)
balanceBeforeFund := ts.GetBalances(consumerAcc.Addr)
_, err = ts.TxRewardsFundIprpc(consumer, mockSpec2, duration, iprpcFunds)
require.NoError(ts.T, err)
expectedBalanceAfterFund := balanceBeforeFund.Sub(iprpcFunds.MulInt(math.NewIntFromUint64(duration))...)
require.True(ts.T, ts.GetBalances(consumerAcc.Addr).IsEqual(expectedBalanceAfterFund))
ts.AdvanceMonths(1).AdvanceEpoch() // fund only fund for next month, so advance a month
}
}
Expand Down
9 changes: 9 additions & 0 deletions x/rewards/keeper/iprpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,15 @@ func TestIprpcEligibleSubscriptions(t *testing.T) {
require.NoError(t, err)
require.Len(t, res1.SpecFunds, 0)
require.Len(t, res2.SpecFunds, 0)

// advance another month and see there are still no rewards
ts.AdvanceMonths(1).AdvanceEpoch()
res1, err = ts.QueryRewardsIprpcProviderRewardEstimation(p1)
require.NoError(t, err)
res2, err = ts.QueryRewardsIprpcProviderRewardEstimation(p2)
require.NoError(t, err)
require.Len(t, res1.SpecFunds, 0)
require.Len(t, res2.SpecFunds, 0)
}

// TestMultipleIprpcSpec checks that rewards are distributed correctly when multiple specs are configured in the IPRPC pool
Expand Down

0 comments on commit 85ba689

Please sign in to comment.