parent
913fcf8a3d
commit
b493c6dc09
|
@ -0,0 +1,49 @@
|
||||||
|
// Reference file.
|
||||||
|
|
||||||
|
package keeper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"cosmos-test/x/cosmostest"
|
||||||
|
"cosmos-test/x/cosmostest/types"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
tendermintTypes "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Integration Tests Tutorial:
|
||||||
|
// https://tutorials.cosmos.network/academy/3-my-own-chain/game-wager.html#integration-tests
|
||||||
|
|
||||||
|
// Example integration test suite:
|
||||||
|
// https://github.com/cosmos/cosmos-sdk/blob/9e1ec7b/x/bank/keeper/keeper_test.go#L66-L110
|
||||||
|
|
||||||
|
type IntegrationTestSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
|
||||||
|
app cosmostest.AppModule
|
||||||
|
msgServer types.MsgServer
|
||||||
|
ctx sdk.Context
|
||||||
|
queryClient types.QueryClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *IntegrationTestSuite) SetupTest() {
|
||||||
|
suite.app = cosmostest.AppModule{
|
||||||
|
Keeper: NewKeeper(cdc)
|
||||||
|
}
|
||||||
|
suite.ctx = suite.app.NewContext(false, tendermintTypes.Header{Time: time.Now()})
|
||||||
|
suite.app.AccountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())
|
||||||
|
suite.app.BankKeeper.SetParams(suite.ctx, banktypes.DefaultParams())
|
||||||
|
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry())
|
||||||
|
types.RegisterQueryServer(queryHelper)
|
||||||
|
suite.queryClient = types.NewQueryClient(queryHelper)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKeeperTestSuite(t *testing.T) {
|
||||||
|
suite.Run(t, new(IntegrationTestSuite))
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package cosmostest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"cosmos-test/x/cosmostest/types"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
tendermintTypes "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Integration Tests Tutorial:
|
||||||
|
// https://tutorials.cosmos.network/academy/3-my-own-chain/game-wager.html#integration-tests
|
||||||
|
|
||||||
|
// Example integration test suite:
|
||||||
|
// https://github.com/cosmos/cosmos-sdk/blob/9e1ec7b/x/bank/keeper/keeper_test.go#L66-L110
|
||||||
|
|
||||||
|
type IntegrationTestSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
|
||||||
|
app *AppModule
|
||||||
|
msgServer types.MsgServer
|
||||||
|
ctx sdk.Context
|
||||||
|
queryClient types.QueryClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *IntegrationTestSuite) SetupTest() {
|
||||||
|
suite.ctx = suite.app.NewContext(false, tendermintTypes.Header{Time: time.Now()})
|
||||||
|
suite.app.AccountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())
|
||||||
|
suite.app.BankKeeper.SetParams(suite.ctx, banktypes.DefaultParams())
|
||||||
|
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry())
|
||||||
|
types.RegisterQueryServer(queryHelper)
|
||||||
|
suite.queryClient = types.NewQueryClient(queryHelper)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKeeperTestSuite(t *testing.T) {
|
||||||
|
suite.Run(t, new(IntegrationTestSuite))
|
||||||
|
}
|
Loading…
Reference in New Issue