2022-01-08 00:39:27 +00:00
|
|
|
package keeper_test
|
|
|
|
|
|
|
|
import (
|
2023-04-05 23:21:59 +00:00
|
|
|
sdkmath "cosmossdk.io/math"
|
2022-01-08 00:39:27 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
|
|
|
"github.com/kava-labs/kava/x/kavadist/keeper"
|
|
|
|
"github.com/kava-labs/kava/x/kavadist/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (suite *keeperTestSuite) TestHandleCommunityPoolMultiSpendProposal() {
|
2023-01-26 17:01:28 +00:00
|
|
|
addr, distrKeeper, ctx := suite.Addrs[0], suite.App.GetDistrKeeper(), suite.Ctx
|
2022-01-08 00:39:27 +00:00
|
|
|
initBalances := suite.BankKeeper.GetAllBalances(ctx, addr)
|
|
|
|
|
2023-01-26 17:01:28 +00:00
|
|
|
// add coins to the module account and fund fee pool
|
|
|
|
macc := distrKeeper.GetDistributionAccount(ctx)
|
|
|
|
fundAmount := sdk.NewCoins(sdk.NewInt64Coin("ukava", 1000000))
|
|
|
|
suite.Require().NoError(suite.App.FundModuleAccount(ctx, macc.GetName(), fundAmount))
|
|
|
|
feePool := distrKeeper.GetFeePool(ctx)
|
|
|
|
feePool.CommunityPool = sdk.NewDecCoinsFromCoins(fundAmount...)
|
|
|
|
distrKeeper.SetFeePool(ctx, feePool)
|
2022-01-08 00:39:27 +00:00
|
|
|
|
|
|
|
proposalAmount1 := int64(1100)
|
|
|
|
proposalAmount2 := int64(1200)
|
|
|
|
proposal := types.NewCommunityPoolMultiSpendProposal("test title", "description", []types.MultiSpendRecipient{
|
|
|
|
{
|
|
|
|
Address: addr.String(),
|
|
|
|
Amount: sdk.NewCoins(sdk.NewInt64Coin("ukava", proposalAmount1)),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: addr.String(),
|
|
|
|
Amount: sdk.NewCoins(sdk.NewInt64Coin("ukava", proposalAmount2)),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
err := keeper.HandleCommunityPoolMultiSpendProposal(ctx, suite.Keeper, proposal)
|
|
|
|
suite.Require().Nil(err)
|
|
|
|
|
|
|
|
balances := suite.BankKeeper.GetAllBalances(ctx, addr)
|
2023-04-05 23:21:59 +00:00
|
|
|
expected := initBalances.AmountOf("ukava").Add(sdkmath.NewInt(proposalAmount1 + proposalAmount2))
|
2022-01-08 00:39:27 +00:00
|
|
|
suite.Require().Equal(expected, balances.AmountOf("ukava"))
|
|
|
|
}
|