Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!test: add msg server tests #111

Merged
merged 17 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions testutil/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ package testutil

import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func GenPubKey() cryptotypes.PubKey {
return secp256k1.GenPrivKey().PubKey()
}

func GenAddress() sdk.AccAddress {
priv := secp256k1.GenPrivKey()

Expand Down
18 changes: 15 additions & 3 deletions x/multi-staking/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,36 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

sdk "github.com/cosmos/cosmos-sdk/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

type KeeperTestSuite struct {
suite.Suite

ctx sdk.Context
msKeeper *multistakingkeeper.Keeper
app *simapp.SimApp
ctx sdk.Context
msKeeper *multistakingkeeper.Keeper
msgServer stakingtypes.MsgServer
}

func (suite *KeeperTestSuite) SetupTest() {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
multiStakingMsgServer := multistakingkeeper.NewMsgServerImpl(app.MultiStakingKeeper)

suite.ctx, suite.msKeeper = ctx, &app.MultiStakingKeeper
suite.app, suite.ctx, suite.msKeeper, suite.msgServer = app, ctx, &app.MultiStakingKeeper, multiStakingMsgServer
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
}

// Todo: add CheckBalance; AddAccountWithCoin; FundAccount
func (suite *KeeperTestSuite) FundAccount(addr sdk.AccAddress, amounts sdk.Coins) error {
err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, amounts)
if err != nil {
return err
}
return suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr, amounts)
}
Loading
Loading