2022-12-09 21:24:35 +00:00
|
|
|
package testutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
|
|
tmtime "github.com/tendermint/tendermint/types/time"
|
|
|
|
|
|
|
|
"github.com/kava-labs/kava/app"
|
|
|
|
"github.com/kava-labs/kava/x/community/keeper"
|
2022-12-13 00:38:27 +00:00
|
|
|
"github.com/kava-labs/kava/x/community/types"
|
2022-12-09 21:24:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Test suite used for all community tests
|
|
|
|
type Suite struct {
|
|
|
|
suite.Suite
|
|
|
|
App app.TestApp
|
|
|
|
Ctx sdk.Context
|
|
|
|
Keeper keeper.Keeper
|
2022-12-13 00:38:27 +00:00
|
|
|
|
|
|
|
MaccAddress sdk.AccAddress
|
2022-12-09 21:24:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The default state used by each test
|
|
|
|
func (suite *Suite) SetupTest() {
|
|
|
|
app.SetSDKConfig()
|
|
|
|
tApp := app.NewTestApp()
|
|
|
|
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
|
|
|
|
2023-10-25 17:09:19 +00:00
|
|
|
suite.App = tApp.InitializeFromGenesisStates()
|
2022-12-09 21:24:35 +00:00
|
|
|
|
|
|
|
suite.Ctx = ctx
|
|
|
|
suite.Keeper = tApp.GetCommunityKeeper()
|
2022-12-13 00:38:27 +00:00
|
|
|
communityPoolAddress := tApp.GetAccountKeeper().GetModuleAddress(types.ModuleAccountName)
|
|
|
|
// hello, greppers!
|
|
|
|
suite.Equal("kava17d2wax0zhjrrecvaszuyxdf5wcu5a0p4qlx3t5", communityPoolAddress.String())
|
|
|
|
suite.MaccAddress = communityPoolAddress
|
2022-12-09 21:24:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateFundedAccount creates a random account and mints `coins` to it.
|
|
|
|
func (suite *Suite) CreateFundedAccount(coins sdk.Coins) sdk.AccAddress {
|
|
|
|
addr := app.RandomAddress()
|
|
|
|
err := suite.App.FundAccount(suite.Ctx, addr, coins)
|
|
|
|
suite.Require().NoError(err)
|
|
|
|
return addr
|
|
|
|
}
|