feat: add Context as arg to NewIntegrationApp (#15779)
## Description Closes: #XXXX This PR adds `sdk.Context` arg to `NewIntegrationApp`. This allows us to set the context updatable while verifying `begin/end block` logic in integration tests. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... * [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title * [ ] added `!` to the type prefix if API or client breaking change * [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) * [ ] provided a link to the relevant issue or specification * [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules) * [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) * [ ] added a changelog entry to `CHANGELOG.md` * [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) * [ ] updated the relevant documentation or specification * [ ] reviewed "Files changed" and left comments if necessary * [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... * [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title * [ ] confirmed `!` in the type prefix if API or client breaking change * [ ] confirmed all author checklist items have been addressed * [ ] reviewed state machine logic * [ ] reviewed API design and naming * [ ] reviewed documentation is accurate * [ ] reviewed tests and test coverage * [ ] manually tested (if applicable)
This commit is contained in:
@@ -6,6 +6,10 @@ import (
|
||||
|
||||
"cosmossdk.io/log"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/integration"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@@ -17,7 +21,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
// Example shows how to use the integration test framework to test the integration of SDK modules.
|
||||
@@ -29,6 +32,12 @@ func Example() {
|
||||
keys := storetypes.NewKVStoreKeys(authtypes.StoreKey, minttypes.StoreKey)
|
||||
authority := authtypes.NewModuleAddress("gov").String()
|
||||
|
||||
// replace the logger by testing values in a real test case (e.g. log.NewTestLogger(t))
|
||||
logger := log.NewLogger(io.Discard, log.OutputJSONOption())
|
||||
|
||||
cms := integration.CreateMultiStore(keys, logger)
|
||||
newCtx := sdk.NewContext(cms, cmtproto.Header{}, true, logger)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
encodingCfg.Codec,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
@@ -47,9 +56,9 @@ func Example() {
|
||||
mintModule := mint.NewAppModule(encodingCfg.Codec, mintKeeper, accountKeeper, nil, nil)
|
||||
|
||||
// create the application and register all the modules from the previous step
|
||||
// replace the logger by testing values in a real test case (e.g. log.NewTestLogger(t))
|
||||
integrationApp := integration.NewIntegrationApp(
|
||||
log.NewLogger(io.Discard, log.OutputJSONOption()),
|
||||
newCtx,
|
||||
logger,
|
||||
keys,
|
||||
encodingCfg.Codec,
|
||||
authModule, mintModule,
|
||||
@@ -104,6 +113,12 @@ func Example_oneModule() {
|
||||
keys := storetypes.NewKVStoreKeys(authtypes.StoreKey)
|
||||
authority := authtypes.NewModuleAddress("gov").String()
|
||||
|
||||
// replace the logger by testing values in a real test case (e.g. log.NewTestLogger(t))
|
||||
logger := log.NewLogger(io.Discard)
|
||||
|
||||
cms := integration.CreateMultiStore(keys, logger)
|
||||
newCtx := sdk.NewContext(cms, cmtproto.Header{}, true, logger)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
encodingCfg.Codec,
|
||||
runtime.NewKVStoreService(keys[authtypes.StoreKey]),
|
||||
@@ -117,9 +132,9 @@ func Example_oneModule() {
|
||||
authModule := auth.NewAppModule(encodingCfg.Codec, accountKeeper, authsims.RandomGenesisAccounts, nil)
|
||||
|
||||
// create the application and register all the modules from the previous step
|
||||
// replace the logger by testing values in a real test case (e.g. log.NewTestLogger(t))
|
||||
integrationApp := integration.NewIntegrationApp(
|
||||
log.NewLogger(io.Discard),
|
||||
newCtx,
|
||||
logger,
|
||||
keys,
|
||||
encodingCfg.Codec,
|
||||
authModule,
|
||||
|
||||
Reference in New Issue
Block a user