Documentation ¶
Overview ¶
The integration package contains the preparation of a full application to be used for module integration tests.
It is intended to be a middle ground between unit tests and full-blown end-to-end tests, while enabling a quick feedback loop to verify cross module interactions.
Integration tests are suitable for things like testing business logic that happens in the ABCI handlers, as well as start/end block hooks.
References from the Cosmos SDK that this package is based on: - https://github.com/cosmos/cosmos-sdk/tree/main/testutil/integration - https://docs.cosmos.network/main/build/building-modules/testing#integration-tests - https://tutorials.cosmos.network/academy/2-cosmos-concepts/12-testing.html#integration-tests
Index ¶
- func CreateMultiStore(keys map[string]*storetypes.KVStoreKey, logger log.Logger) storetypes.CommitMultiStore
- type App
- func (app *App) GetAuthority() string
- func (app *App) GetCodec() codec.Codec
- func (app *App) GetKeyRing() keyring.Keyring
- func (app *App) GetRingClient() crypto.RingClient
- func (app *App) GetSdkCtx() *sdk.Context
- func (app *App) NextBlock(t *testing.T)
- func (app *App) NextBlocks(t *testing.T, numBlocks int)
- func (app *App) QueryHelper() *baseapp.QueryServiceTestHelper
- func (app *App) RunMsg(t *testing.T, msg sdk.Msg, option ...RunOption) *codectypes.Any
- type RunConfig
- type RunOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMultiStore ¶
func CreateMultiStore(keys map[string]*storetypes.KVStoreKey, logger log.Logger) storetypes.CommitMultiStore
CreateMultiStore is a helper for setting up multiple stores for provided modules.
Types ¶
type App ¶
type App struct { *baseapp.BaseApp // Some default helper fixtures for general testing. // They're publically exposed and should/could be improve and expand on // over time. DefaultService *sharedtypes.Service DefaultApplication *apptypes.Application DefaultApplicationKeyringUid string DefaultSupplier *sharedtypes.Supplier DefaultSupplierKeyringKeyringUid string // contains filtered or unexported fields }
App is a test application that can be used to test the behaviour when none of the modules are mocked and their integration (cross module interaction) needs to be validated.
func NewCompleteIntegrationApp ¶
NewCompleteIntegrationApp creates a new instance of the App, abstracting out all of the internal details and complexities of the application setup. TODO_TECHDEBT: Not all of the modules are created here (e.g. minting module), so it is up to the developer to add / improve / update this function over time as the need arises.
func NewIntegrationApp ¶
func NewIntegrationApp( t *testing.T, sdkCtx sdk.Context, cdc codec.Codec, registry codectypes.InterfaceRegistry, logger log.Logger, authority sdk.AccAddress, modules map[string]appmodule.AppModule, keys map[string]*storetypes.KVStoreKey, msgRouter *baseapp.MsgServiceRouter, queryHelper *baseapp.QueryServiceTestHelper, ) *App
NewIntegrationApp creates a new instance of the App with the provided details on how the modules should be configured.
func (*App) GetAuthority ¶
GetAuthority returns the authority address used by the application.
func (*App) GetKeyRing ¶
GetKeyRing returns the keyring used by the application.
func (*App) GetRingClient ¶
func (app *App) GetRingClient() crypto.RingClient
GetRingClient returns the ring client used by the application.
func (*App) NextBlock ¶
NextBlock commits and finalizes all existing transactions. It then updates and advances the context of the App.
func (*App) NextBlocks ¶
NextBlocks calls NextBlock numBlocks times
func (*App) QueryHelper ¶
func (app *App) QueryHelper() *baseapp.QueryServiceTestHelper
QueryHelper returns the query helper used by the application that can be used to submit queries to the application.
func (*App) RunMsg ¶
RunMsg provides the ability to run a message and return the response. In order to run a message, the application must have a handler for it. These handlers are registered on the application message service router. The result of the message execution is returned as an Any type. That any type can be unmarshaled to the expected response type. If the message execution fails, an error is returned.
type RunOption ¶
type RunOption func(*RunConfig)
RunOption is a function that can be used to configure the integration app.
func WithAutomaticCommit ¶
func WithAutomaticCommit() RunOption
WithAutomaticCommit enables automatic commit. This means that the integration app will automatically commit the state after each msg.
func WithAutomaticFinalizeBlock ¶
func WithAutomaticFinalizeBlock() RunOption
WithAutomaticFinalizeBlock calls ABCI finalize block.