remove x/community references (#1454)

* remove new community pool from earn

* remove x/community from kavadist

* remove overridden community-pool query
This commit is contained in:
Robert Pirtle 2023-01-26 09:01:28 -08:00 committed by GitHub
parent 0d38ce77a1
commit 05a705be79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 91 additions and 287 deletions

View File

@ -93,7 +93,6 @@ import (
"github.com/kava-labs/kava/app/ante"
kavaparams "github.com/kava-labs/kava/app/params"
kavadistrquery "github.com/kava-labs/kava/app/query/distribution"
"github.com/kava-labs/kava/x/auction"
auctionkeeper "github.com/kava-labs/kava/x/auction/keeper"
auctiontypes "github.com/kava-labs/kava/x/auction/types"
@ -608,7 +607,7 @@ func NewApp(
&app.liquidKeeper,
&hardKeeper,
&savingsKeeper,
communitytypes.ModuleAccountName,
&app.distrKeeper,
)
// x/community's deposit/withdraw to lend proposals depend on hard keeper.
@ -624,7 +623,7 @@ func NewApp(
kavadistSubspace,
app.bankKeeper,
app.accountKeeper,
app.communityKeeper,
app.distrKeeper,
app.loadBlockedMaccAddrs(),
)
@ -972,25 +971,7 @@ func NewApp(
}
func (app *App) RegisterServices(cfg module.Configurator) {
// Register services from all unmodified modules
for _, module := range app.mm.Modules {
// skip registration of distribution services
if module.Name() == distrtypes.ModuleName {
continue
}
module.RegisterServices(cfg)
}
// register ditribution services except query server
distrtypes.RegisterMsgServer(cfg.MsgServer(), distrkeeper.NewMsgServerImpl(app.distrKeeper))
cfg.RegisterMigration(
distrtypes.ModuleName,
1,
distrkeeper.NewMigrator(app.distrKeeper).Migrate1to2,
)
// register fake distribution query server
distrtypes.RegisterQueryServer(cfg.QueryServer(), kavadistrquery.NewQueryServer(app.distrKeeper, app.communityKeeper))
app.mm.RegisterServices(cfg)
}
// BeginBlocker contains app specific logic for the BeginBlock abci call.

View File

@ -1,10 +0,0 @@
package distribution
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// CommunityKeeper defines the contract needed to be fulfilled for community module dependencies.
type CommunityKeeper interface {
GetModuleAccountBalance(sdk.Context) sdk.Coins
}

View File

@ -1,38 +0,0 @@
package distribution
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
)
var _ distrtypes.QueryServer = &queryServer{}
type queryServer struct {
distrkeeper.Keeper
communityKeeper CommunityKeeper
}
// NewQueryServer returns a grpc query server for the distribution module.
// It forwards most requests to the distribution keeper, except for the community pool request
// which is mapped to the kava community module.
func NewQueryServer(distrKeeper distrkeeper.Keeper, commKeeper CommunityKeeper) distrtypes.QueryServer {
return &queryServer{
Keeper: distrKeeper,
communityKeeper: commKeeper,
}
}
// CommunityPool queries the kava community module
// The original community pool, which is a separately accounted for portion of x/auth's fee pool
// is replaces with the x/community module account.
// TODO: implement legacy community pool balance query in x/community
// To query the original community pool, including historical values, use x/community's LegacyCommunityPoolBalance
func (q queryServer) CommunityPool(c context.Context, req *distrtypes.QueryCommunityPoolRequest) (*distrtypes.QueryCommunityPoolResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
balance := q.communityKeeper.GetModuleAccountBalance(ctx)
return &distrtypes.QueryCommunityPoolResponse{Pool: sdk.NewDecCoinsFromCoins(balance...)}, nil
}

View File

@ -1,170 +0,0 @@
package distribution_test
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/suite"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app"
distrquery "github.com/kava-labs/kava/app/query/distribution"
communitytypes "github.com/kava-labs/kava/x/community/types"
)
type queryTestSuite struct {
suite.Suite
App app.TestApp
Ctx sdk.Context
queryClient distrtypes.QueryClient
communityPoolAddress sdk.AccAddress
}
func (suite *queryTestSuite) SetupTest() {
app.SetSDKConfig()
tApp := app.NewTestApp()
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
tApp.InitializeFromGenesisStates()
suite.App = tApp
suite.Ctx = ctx
queryHelper := baseapp.NewQueryServerTestHelper(suite.Ctx, suite.App.InterfaceRegistry())
distrtypes.RegisterQueryServer(queryHelper, distrquery.NewQueryServer(
tApp.GetDistrKeeper(),
tApp.GetCommunityKeeper(),
))
suite.queryClient = distrtypes.NewQueryClient(queryHelper)
suite.communityPoolAddress = tApp.GetAccountKeeper().GetModuleAddress(communitytypes.ModuleAccountName)
}
func TestGRPQueryTestSuite(t *testing.T) {
suite.Run(t, new(queryTestSuite))
}
func (suite queryTestSuite) FundCommunityPool(amt sdk.Coins) {
err := suite.App.FundModuleAccount(suite.Ctx, communitytypes.ModuleAccountName, amt)
suite.NoError(err)
}
func (suite queryTestSuite) CheckCommunityPoolBalance(expected sdk.Coins, result sdk.DecCoins) {
actual := suite.App.GetBankKeeper().GetAllBalances(suite.Ctx, suite.communityPoolAddress)
// check that account was properly funded
suite.Equal(expected, actual, "unexpected community pool balance")
// transform the expected values to DecCoins to compare with result
decCoins := sdk.NewDecCoinsFromCoins(expected...)
suite.True(decCoins.IsEqual(result), "unexpected community pool query response")
}
func (suite *queryTestSuite) Test_CommunityPoolOverride() {
singleDenom := sdk.NewCoins(sdk.NewInt64Coin("ukava", 1e10))
multiDenom := singleDenom.Add(sdk.NewInt64Coin("other-denom", 1e9))
testCases := []struct {
name string
funds sdk.Coins
}{
{"single denom", singleDenom},
{"multiple denoms", multiDenom},
{"no balance", sdk.NewCoins()},
}
for _, tc := range testCases {
suite.Run(fmt.Sprintf("queries the correct balance - %s", tc.name), func() {
suite.SetupTest()
// init community pool funds
if !tc.funds.IsZero() {
suite.FundCommunityPool(tc.funds)
}
// query the overridden endpoint
balance, err := suite.queryClient.CommunityPool(
context.Background(),
&distrtypes.QueryCommunityPoolRequest{},
)
suite.NoError(err)
suite.CheckCommunityPoolBalance(tc.funds, balance.Pool)
})
}
}
// modified from sdk test of distribution querier
func (suite *queryTestSuite) Test_OGDistributionQueries() {
suite.SetupTest()
ctx, distrKeeper, stakingKeeper := suite.Ctx, suite.App.GetDistrKeeper(), suite.App.GetStakingKeeper()
// setup a validator
addr := app.RandomAddress()
valAddr := sdk.ValAddress(addr)
bondDenom := stakingKeeper.BondDenom(ctx)
// test param queries
params := distrtypes.Params{
CommunityTax: sdk.ZeroDec(),
BaseProposerReward: sdk.NewDecWithPrec(2, 1),
BonusProposerReward: sdk.NewDecWithPrec(1, 1),
WithdrawAddrEnabled: true,
}
distrKeeper.SetParams(ctx, params)
r1, err := suite.queryClient.Params(context.Background(), &distrtypes.QueryParamsRequest{})
suite.NoError(err)
suite.Equal(params, r1.Params)
// test outstanding rewards query
outstandingRewards := sdk.NewDecCoins(sdk.NewInt64DecCoin(bondDenom, 100), sdk.NewInt64DecCoin("other", 10))
distrKeeper.SetValidatorOutstandingRewards(ctx, valAddr, distrtypes.ValidatorOutstandingRewards{Rewards: outstandingRewards})
r2, err := suite.queryClient.ValidatorOutstandingRewards(context.Background(), &distrtypes.QueryValidatorOutstandingRewardsRequest{ValidatorAddress: valAddr.String()})
suite.NoError(err)
suite.Equal(outstandingRewards, r2.Rewards.Rewards)
// test validator commission query
commission := sdk.DecCoins{{Denom: "token1", Amount: sdk.NewDec(4)}, {Denom: "token2", Amount: sdk.NewDec(2)}}
distrKeeper.SetValidatorAccumulatedCommission(ctx, valAddr, distrtypes.ValidatorAccumulatedCommission{Commission: commission})
r3, err := suite.queryClient.ValidatorCommission(context.Background(), &distrtypes.QueryValidatorCommissionRequest{ValidatorAddress: valAddr.String()})
suite.NoError(err)
suite.Equal(commission, r3.Commission.Commission)
// test delegator's total rewards query
r4, err := suite.queryClient.DelegationTotalRewards(context.Background(), &distrtypes.QueryDelegationTotalRewardsRequest{DelegatorAddress: addr.String()})
suite.NoError(err)
suite.Equal(&distrtypes.QueryDelegationTotalRewardsResponse{}, r4)
// test validator slashes query with height range
slashOne := distrtypes.NewValidatorSlashEvent(3, sdk.NewDecWithPrec(5, 1))
slashTwo := distrtypes.NewValidatorSlashEvent(7, sdk.NewDecWithPrec(6, 1))
distrKeeper.SetValidatorSlashEvent(ctx, valAddr, 3, 0, slashOne)
distrKeeper.SetValidatorSlashEvent(ctx, valAddr, 7, 0, slashTwo)
slashes := suite.getQueriedValidatorSlashes(valAddr, 0, 2)
suite.Equal(0, len(slashes))
slashes = suite.getQueriedValidatorSlashes(valAddr, 0, 5)
suite.Equal([]distrtypes.ValidatorSlashEvent{slashOne}, slashes)
slashes = suite.getQueriedValidatorSlashes(valAddr, 0, 10)
suite.Equal([]distrtypes.ValidatorSlashEvent{slashOne, slashTwo}, slashes)
// non-zero delegator reward queries are not tested here.
}
func (suite *queryTestSuite) getQueriedValidatorSlashes(validatorAddr sdk.ValAddress, startHeight uint64, endHeight uint64) (slashes []distrtypes.ValidatorSlashEvent) {
result, err := suite.queryClient.ValidatorSlashes(
context.Background(),
&distrtypes.QueryValidatorSlashesRequest{
ValidatorAddress: validatorAddr.String(),
StartingHeight: startHeight,
EndingHeight: endHeight,
},
)
suite.NoError(err)
return result.Slashes
}

View File

@ -22,8 +22,8 @@ type Keeper struct {
hardKeeper types.HardKeeper
savingsKeeper types.SavingsKeeper
// name of module account the community pool deposit/withdraw proposals use
communityPoolMaccName string
// Keeper for community pool transfers
distKeeper types.DistributionKeeper
}
// NewKeeper creates a new keeper
@ -36,7 +36,7 @@ func NewKeeper(
liquidKeeper types.LiquidKeeper,
hardKeeper types.HardKeeper,
savingsKeeper types.SavingsKeeper,
communityPoolMaccName string,
distKeeper types.DistributionKeeper,
) Keeper {
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
@ -51,8 +51,7 @@ func NewKeeper(
liquidKeeper: liquidKeeper,
hardKeeper: hardKeeper,
savingsKeeper: savingsKeeper,
communityPoolMaccName: communityPoolMaccName,
distKeeper: distKeeper,
}
}

View File

@ -4,15 +4,46 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/earn/types"
kavadisttypes "github.com/kava-labs/kava/x/kavadist/types"
)
// HandleCommunityPoolDepositProposal is a handler for executing a passed community pool deposit proposal
func HandleCommunityPoolDepositProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolDepositProposal) error {
return k.DepositFromModuleAccount(ctx, k.communityPoolMaccName, p.Amount, types.STRATEGY_TYPE_SAVINGS)
fundAcc := k.accountKeeper.GetModuleAccount(ctx, kavadisttypes.FundModuleAccount)
if err := k.distKeeper.DistributeFromFeePool(ctx, sdk.NewCoins(p.Amount), fundAcc.GetAddress()); err != nil {
return err
}
err := k.DepositFromModuleAccount(ctx, kavadisttypes.FundModuleAccount, p.Amount, types.STRATEGY_TYPE_SAVINGS)
if err != nil {
return err
}
return nil
}
// HandleCommunityPoolWithdrawProposal is a handler for executing a passed community pool withdraw proposal.
func HandleCommunityPoolWithdrawProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolWithdrawProposal) error {
_, err := k.WithdrawFromModuleAccount(ctx, k.communityPoolMaccName, p.Amount, types.STRATEGY_TYPE_SAVINGS)
// Withdraw to fund module account
withdrawAmount, err := k.WithdrawFromModuleAccount(ctx, kavadisttypes.FundModuleAccount, p.Amount, types.STRATEGY_TYPE_SAVINGS)
if err != nil {
return err
}
// Move funds to the community pool manually
err = k.bankKeeper.SendCoinsFromModuleToModule(
ctx,
kavadisttypes.FundModuleAccount,
k.distKeeper.GetDistributionAccount(ctx).GetName(),
sdk.NewCoins(withdrawAmount),
)
if err != nil {
return err
}
feePool := k.distKeeper.GetFeePool(ctx)
newCommunityPool := feePool.CommunityPool.Add(sdk.NewDecCoinFromCoin(withdrawAmount))
feePool.CommunityPool = newCommunityPool
k.distKeeper.SetFeePool(ctx, feePool)
return nil
}

View File

@ -4,7 +4,6 @@ import (
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
communitytypes "github.com/kava-labs/kava/x/community/types"
"github.com/kava-labs/kava/x/earn/keeper"
"github.com/kava-labs/kava/x/earn/testutil"
"github.com/kava-labs/kava/x/earn/types"
@ -25,12 +24,15 @@ func TestProposalTestSuite(t *testing.T) {
}
func (suite *proposalTestSuite) TestCommunityDepositProposal() {
distKeeper := suite.App.GetDistrKeeper()
ctx := suite.Ctx
macc := suite.App.GetAccountKeeper().GetModuleAccount(ctx, communitytypes.ModuleAccountName)
macc := distKeeper.GetDistributionAccount(ctx)
fundAmount := sdk.NewCoins(sdk.NewInt64Coin("ukava", 100000000))
depositAmount := sdk.NewCoin("ukava", sdk.NewInt(10000000))
suite.Require().NoError(suite.App.FundModuleAccount(ctx, macc.GetName(), fundAmount))
feePool := distKeeper.GetFeePool(ctx)
feePool.CommunityPool = sdk.NewDecCoinsFromCoins(fundAmount...)
distKeeper.SetFeePool(ctx, feePool)
suite.CreateVault("ukava", types.StrategyTypes{types.STRATEGY_TYPE_SAVINGS}, false, nil)
prop := types.NewCommunityPoolDepositProposal("test title",
"desc", depositAmount)
@ -39,18 +41,23 @@ func (suite *proposalTestSuite) TestCommunityDepositProposal() {
balance := suite.BankKeeper.GetAllBalances(ctx, macc.GetAddress())
suite.Require().Equal(fundAmount.Sub(sdk.NewCoins(depositAmount)), balance)
communityPoolBalance := suite.App.GetCommunityKeeper().GetModuleAccountBalance(ctx)
feePool = distKeeper.GetFeePool(ctx)
communityPoolBalance, change := feePool.CommunityPool.TruncateDecimal()
suite.Require().Equal(fundAmount.Sub(sdk.NewCoins(depositAmount)), communityPoolBalance)
suite.Require().True(change.Empty())
}
func (suite *proposalTestSuite) TestCommunityWithdrawProposal() {
distKeeper := suite.App.GetDistrKeeper()
ctx := suite.Ctx
macc := suite.App.GetAccountKeeper().GetModuleAccount(ctx, communitytypes.ModuleAccountName)
macc := distKeeper.GetDistributionAccount(ctx)
fundAmount := sdk.NewCoins(sdk.NewInt64Coin("ukava", 100000000))
depositAmount := sdk.NewCoin("ukava", sdk.NewInt(10000000))
suite.Require().NoError(suite.App.FundModuleAccount(ctx, macc.GetName(), fundAmount))
feePool := distKeeper.GetFeePool(ctx)
feePool.CommunityPool = sdk.NewDecCoinsFromCoins(fundAmount...)
distKeeper.SetFeePool(ctx, feePool)
// TODO update to STRATEGY_TYPE_SAVINGS once implemented
suite.CreateVault("ukava", types.StrategyTypes{types.STRATEGY_TYPE_SAVINGS}, false, nil)
deposit := types.NewCommunityPoolDepositProposal("test title",
"desc", depositAmount)
@ -66,7 +73,8 @@ func (suite *proposalTestSuite) TestCommunityWithdrawProposal() {
suite.Require().NoError(err)
balance = suite.BankKeeper.GetAllBalances(ctx, macc.GetAddress())
suite.Require().Equal(fundAmount, balance)
communityPoolBalance := suite.App.GetCommunityKeeper().GetModuleAccountBalance(ctx)
feePool = distKeeper.GetFeePool(ctx)
communityPoolBalance, change := feePool.CommunityPool.TruncateDecimal()
suite.Require().Equal(fundAmount, communityPoolBalance)
suite.Require().True(change.Empty())
}

View File

@ -17,6 +17,7 @@ import (
savingskeeper "github.com/kava-labs/kava/x/savings/keeper"
savingstypes "github.com/kava-labs/kava/x/savings/types"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@ -204,7 +205,7 @@ func (suite *Suite) GetEvents() sdk.Events {
// AddCoinsToModule adds coins to the earn module account
func (suite *Suite) AddCoinsToModule(amount sdk.Coins) {
// Does not use suite.BankKeeper.MintCoins as module account would not have permission to mint
err := suite.App.FundModuleAccount(suite.Ctx, types.ModuleName, amount)
err := simapp.FundModuleAccount(suite.BankKeeper, suite.Ctx, types.ModuleName, amount)
suite.Require().NoError(err)
}
@ -226,7 +227,7 @@ func (suite *Suite) CreateAccount(initialBalance sdk.Coins, index int) authtypes
acc := ak.NewAccountWithAddress(suite.Ctx, addrs[index])
ak.SetAccount(suite.Ctx, acc)
err := suite.App.FundAccount(suite.Ctx, acc.GetAddress(), initialBalance)
err := simapp.FundAccount(suite.BankKeeper, suite.Ctx, acc.GetAddress(), initialBalance)
suite.Require().NoError(err)
return acc
@ -239,7 +240,7 @@ func (suite *Suite) NewAccountFromAddr(addr sdk.AccAddress, balance sdk.Coins) a
acc := ak.NewAccountWithAddress(suite.Ctx, addr)
ak.SetAccount(suite.Ctx, acc)
err := suite.App.FundAccount(suite.Ctx, acc.GetAddress(), balance)
err := simapp.FundAccount(suite.BankKeeper, suite.Ctx, acc.GetAddress(), balance)
suite.Require().NoError(err)
return acc

View File

@ -3,6 +3,7 @@ package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
hardtypes "github.com/kava-labs/kava/x/hard/types"
savingstypes "github.com/kava-labs/kava/x/savings/types"
@ -25,6 +26,14 @@ type BankKeeper interface {
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}
// DistributionKeeper defines the expected interface needed for community-pool deposits to earn vaults
type DistributionKeeper interface {
GetFeePool(ctx sdk.Context) (feePool disttypes.FeePool)
SetFeePool(ctx sdk.Context, feePool disttypes.FeePool)
GetDistributionAccount(ctx sdk.Context) types.ModuleAccountI
DistributeFromFeePool(ctx sdk.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error
}
// LiquidKeeper defines the expected interface needed for derivative to staked token conversions.
type LiquidKeeper interface {
GetStakedTokensForDerivatives(ctx sdk.Context, derivatives sdk.Coins) (sdk.Coin, error)

View File

@ -17,8 +17,8 @@ type Keeper struct {
cdc codec.BinaryCodec
paramSubspace paramtypes.Subspace
bankKeeper types.BankKeeper
distKeeper types.DistKeeper
accountKeeper types.AccountKeeper
communityKeeper types.CommunityKeeper
blacklistedAddrs map[string]bool
}
@ -26,7 +26,7 @@ type Keeper struct {
// NewKeeper creates a new keeper
func NewKeeper(
cdc codec.BinaryCodec, key sdk.StoreKey, paramstore paramtypes.Subspace, bk types.BankKeeper, ak types.AccountKeeper,
ck types.CommunityKeeper, blacklistedAddrs map[string]bool,
dk types.DistKeeper, blacklistedAddrs map[string]bool,
) Keeper {
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
@ -37,8 +37,8 @@ func NewKeeper(
cdc: cdc,
paramSubspace: paramstore,
bankKeeper: bk,
distKeeper: dk,
accountKeeper: ak,
communityKeeper: ck,
blacklistedAddrs: blacklistedAddrs,
}
}

View File

@ -13,7 +13,7 @@ func HandleCommunityPoolMultiSpendProposal(ctx sdk.Context, k Keeper, p *types.C
if k.blacklistedAddrs[receiverInfo.Address] {
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is blacklisted from receiving external funds", receiverInfo.Address)
}
err := k.communityKeeper.DistributeFromCommunityPool(ctx, receiverInfo.GetAddress(), receiverInfo.Amount)
err := k.distKeeper.DistributeFromFeePool(ctx, receiverInfo.Amount, receiverInfo.GetAddress())
if err != nil {
return err
}

View File

@ -3,22 +3,21 @@ package keeper_test
import (
sdk "github.com/cosmos/cosmos-sdk/types"
communitytypes "github.com/kava-labs/kava/x/community/types"
"github.com/kava-labs/kava/x/kavadist/keeper"
"github.com/kava-labs/kava/x/kavadist/types"
)
func (suite *keeperTestSuite) TestHandleCommunityPoolMultiSpendProposal() {
addr, communityKeeper, ctx := suite.Addrs[0], suite.App.GetCommunityKeeper(), suite.Ctx
addr, distrKeeper, ctx := suite.Addrs[0], suite.App.GetDistrKeeper(), suite.Ctx
initBalances := suite.BankKeeper.GetAllBalances(ctx, addr)
// add coins to the module account and fund community pool
initialFunds := int64(1000000)
fundAmount := sdk.NewCoins(sdk.NewInt64Coin("ukava", initialFunds))
suite.Require().NoError(suite.App.FundModuleAccount(ctx, communitytypes.ModuleAccountName, fundAmount))
// expect funds to start in community pool
commPoolFunds := communityKeeper.GetModuleAccountBalance(ctx)
suite.Require().True(fundAmount.IsEqual(commPoolFunds))
// 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)
proposalAmount1 := int64(1100)
proposalAmount2 := int64(1200)
@ -36,12 +35,6 @@ func (suite *keeperTestSuite) TestHandleCommunityPoolMultiSpendProposal() {
suite.Require().Nil(err)
balances := suite.BankKeeper.GetAllBalances(ctx, addr)
// expect funds to be transferred to recipient
expected := initBalances.AmountOf("ukava").Add(sdk.NewInt(proposalAmount1 + proposalAmount2))
suite.Require().Equal(expected, balances.AmountOf("ukava"))
// expect funds to be deducted from community pool
expectedCommPool := commPoolFunds.AmountOf("ukava").SubRaw(proposalAmount1 + proposalAmount2)
suite.Require().Equal(expectedCommPool, communityKeeper.GetModuleAccountBalance(ctx).AmountOf("ukava"))
}

View File

@ -5,9 +5,9 @@ import (
authTypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
// CommunityKeeper defines the expected community keeper interface
type CommunityKeeper interface {
DistributeFromCommunityPool(ctx sdk.Context, sender sdk.AccAddress, amount sdk.Coins) error
// DistKeeper defines the expected distribution keeper interface
type DistKeeper interface {
DistributeFromFeePool(ctx sdk.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error
}
// AccountKeeper defines the expected account keeper interface