Skip to content

Commit f50868e

Browse files
committed
fix test
1 parent df7a668 commit f50868e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

x/protocolpool/keeper/keeper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (k Keeper) SetToDistribute(ctx context.Context) error {
195195
return err
196196
}
197197

198-
if !lastBalance.IsZero() { // only reset if the last balance is not zero
198+
if !lastBalance.IsZero() { // only reset if the last balance is not zero (so we leave it at zero/nil)
199199
return k.LastBalance.Set(ctx, math.ZeroInt())
200200
}
201201

x/protocolpool/keeper/keeper_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,31 @@ func (suite *KeeperTestSuite) TestSetToDistribute() {
186186
distrBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000)))
187187
suite.bankKeeper.EXPECT().GetAllBalances(suite.ctx, poolDistrAcc.GetAddress()).Return(distrBal).AnyTimes()
188188

189+
// because there are no continuous funds, all are going to the community pool
190+
suite.bankKeeper.EXPECT().SendCoinsFromModuleToModule(suite.ctx, poolDistrAcc.GetName(), poolAcc.GetName(), distrBal)
191+
189192
err := suite.poolKeeper.SetToDistribute(suite.ctx)
190193
suite.Require().NoError(err)
191194

195+
// Verify that LastBalance was not set (zero balance)
196+
_, err = suite.poolKeeper.LastBalance.Get(suite.ctx)
197+
suite.Require().ErrorContains(err, "not found")
198+
199+
// create new continuous fund and distribute again
200+
addrCdc := address.NewBech32Codec("cosmos")
201+
addrStr := "cosmos1qypq2q2l8z4wz2z2l8z4wz2z2l8z4wz2srklj6"
202+
addrBz, err := addrCdc.StringToBytes(addrStr)
203+
suite.Require().NoError(err)
204+
205+
suite.poolKeeper.ContinuousFund.Set(suite.ctx, addrBz, types.ContinuousFund{
206+
Recipient: addrStr,
207+
Percentage: math.LegacyMustNewDecFromStr("0.3"),
208+
Expiry: nil,
209+
})
210+
211+
err = suite.poolKeeper.SetToDistribute(suite.ctx)
212+
suite.Require().NoError(err)
213+
192214
// Verify that LastBalance was set correctly
193215
lastBalance, err := suite.poolKeeper.LastBalance.Get(suite.ctx)
194216
suite.Require().NoError(err)

0 commit comments

Comments
 (0)