-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (39 loc) · 1.35 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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/incubus-network/nemo/app"
"github.com/incubus-network/nemo/x/community/keeper"
"github.com/incubus-network/nemo/x/community/types"
)
// Test suite used for all community tests
type Suite struct {
suite.Suite
App app.TestApp
Ctx sdk.Context
Keeper keeper.Keeper
MaccAddress sdk.AccAddress
}
// 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()})
tApp.InitializeFromGenesisStates()
suite.App = tApp
suite.Ctx = ctx
suite.Keeper = tApp.GetCommunityKeeper()
communityPoolAddress := tApp.GetAccountKeeper().GetModuleAddress(types.ModuleAccountName)
// hello, greppers!
suite.Equal("fury17d2wax0zhjrrecvaszuyxdf5wcu5a0p4vpmrwu", communityPoolAddress.String())
suite.MaccAddress = communityPoolAddress
}
// 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
}