2020-04-24 22:15:51 +00:00
|
|
|
package keeper_test
|
|
|
|
|
|
|
|
import (
|
2020-04-26 14:28:57 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2020-04-24 22:15:51 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2021-06-07 16:08:03 +00:00
|
|
|
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
2020-04-24 23:22:56 +00:00
|
|
|
|
2020-04-26 14:28:57 +00:00
|
|
|
"github.com/kava-labs/kava/app"
|
|
|
|
"github.com/kava-labs/kava/x/committee"
|
2020-04-24 23:22:56 +00:00
|
|
|
"github.com/kava-labs/kava/x/committee/keeper"
|
2020-04-24 22:15:51 +00:00
|
|
|
"github.com/kava-labs/kava/x/committee/types"
|
|
|
|
)
|
|
|
|
|
2020-04-25 16:39:59 +00:00
|
|
|
// Avoid cluttering test cases with long function names
|
|
|
|
func i(in int64) sdk.Int { return sdk.NewInt(in) }
|
|
|
|
func d(str string) sdk.Dec { return sdk.MustNewDecFromStr(str) }
|
|
|
|
func c(denom string, amount int64) sdk.Coin { return sdk.NewInt64Coin(denom, amount) }
|
|
|
|
func cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) }
|
|
|
|
|
2020-04-27 14:04:47 +00:00
|
|
|
// getProposalVoteMap collects up votes into a map indexed by proposalID
|
2020-04-24 22:15:51 +00:00
|
|
|
func getProposalVoteMap(k keeper.Keeper, ctx sdk.Context) map[uint64]([]types.Vote) {
|
|
|
|
|
2020-04-24 23:22:56 +00:00
|
|
|
proposalVoteMap := map[uint64]([]types.Vote){}
|
2020-04-24 22:15:51 +00:00
|
|
|
|
2020-04-24 23:22:56 +00:00
|
|
|
k.IterateProposals(ctx, func(p types.Proposal) bool {
|
2020-04-27 14:04:47 +00:00
|
|
|
proposalVoteMap[p.ID] = k.GetVotesByProposal(ctx, p.ID)
|
2020-04-24 22:15:51 +00:00
|
|
|
return false
|
|
|
|
})
|
|
|
|
return proposalVoteMap
|
|
|
|
}
|
2020-04-26 14:28:57 +00:00
|
|
|
|
2021-06-07 16:08:03 +00:00
|
|
|
func (suite *KeeperTestSuite) getAccount(addr sdk.AccAddress) authexported.Account {
|
|
|
|
ak := suite.app.GetAccountKeeper()
|
|
|
|
return ak.GetAccount(suite.ctx, addr)
|
|
|
|
}
|
|
|
|
|
2020-04-26 14:28:57 +00:00
|
|
|
// NewCommitteeGenesisState marshals a committee genesis state into json for use in initializing test apps.
|
|
|
|
func NewCommitteeGenesisState(cdc *codec.Codec, gs committee.GenesisState) app.GenesisState {
|
|
|
|
return app.GenesisState{committee.ModuleName: cdc.MustMarshalJSON(gs)}
|
|
|
|
}
|