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 ¶
- type App
- func (app *App) GetAuthority() string
- func (app *App) GetCodec() codec.Codec
- func (app *App) GetFaucetBech32() string
- func (app *App) GetKeyRing() keyring.Keyring
- func (app *App) GetPreGeneratedAccounts() *testkeyring.PreGeneratedAccountIterator
- 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) (tx.MsgResponse, error)
- func (app *App) RunMsgs(t *testing.T, msgs ...sdk.Msg) (txMsgResps []tx.MsgResponse, err error)
- type InitChainerModuleFn
- type IntegrationAppConfig
- type IntegrationAppOptionFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { *baseapp.BaseApp // Some default helper fixtures for general testing. // They're publicly exposed and should/could be improved and expand on // over time. // // TODO_IMPROVE: Refactor into a DefaultActorsIntegrationSuite test suite. 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 ¶
func NewCompleteIntegrationApp(t *testing.T, opts ...IntegrationAppOptionFn) *App
NewCompleteIntegrationApp creates a new instance of the App, abstracting out all 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, txCfg client.TxConfig, registry codectypes.InterfaceRegistry, bApp *baseapp.BaseApp, logger log.Logger, authority sdk.AccAddress, modules map[string]appmodule.AppModule, keys map[string]*storetypes.KVStoreKey, msgRouter *baseapp.MsgServiceRouter, queryHelper *baseapp.QueryServiceTestHelper, opts ...IntegrationAppOptionFn, ) *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) GetFaucetBech32 ¶ added in v0.0.10
GetFaucetBech32 returns the faucet address used by the application.
func (*App) GetKeyRing ¶
GetKeyRing returns the keyring used by the application.
func (*App) GetPreGeneratedAccounts ¶ added in v0.0.10
func (app *App) GetPreGeneratedAccounts() *testkeyring.PreGeneratedAccountIterator
GetPreGeneratedAccounts returns the pre-generated accounts iterater 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 process a message by packing it into a tx and driving the ABCI through block finalization. It returns a tx.MsgResponse (any) which corresponds to the request message. It is a convenience method which wraps RunMsgs.
func (*App) RunMsgs ¶ added in v0.0.10
RunMsgs provides the ability to process messages by packing them into a tx and driving the ABCI through block finalization. It returns a slice of tx.MsgResponse (any) whose elements correspond to the request message of the same index. These responses can be type asserted to the expected response type. If execution for ANY message fails, ALL failing messages' errors are joined and returned. In order to run a message, the application must have a handler for it. These handlers are registered on the application message service router.
type InitChainerModuleFn ¶ added in v0.0.10
InitChainerModuleFn is a function that is called for each module during the integration App's InitChainer function.
func NewInitChainerModuleGenesisStateOptionFn ¶ added in v0.0.10
func NewInitChainerModuleGenesisStateOptionFn[T module.HasGenesis](genesisState cosmostypes.Msg) InitChainerModuleFn
NewInitChainerModuleGenesisStateOptionFn returns an InitChainerModuleFn that initializes the module's genesis state with the given genesisState. T is expected to be the module's AppModule type.
type IntegrationAppConfig ¶ added in v0.0.10
type IntegrationAppConfig struct { // InitChainerModuleFns are called for each module during the integration App's // InitChainer function. InitChainerModuleFns []InitChainerModuleFn TokenLogicModules []tlm.TokenLogicModule }
IntegrationAppConfig is a configuration struct for an integration App. Its fields are intended to be set/updated by IntegrationAppOptionFn functions which are passed during integration App construction.
type IntegrationAppOptionFn ¶ added in v0.0.10
type IntegrationAppOptionFn func(*IntegrationAppConfig)
IntegrationAppOptionFn is a function that receives and has the opportunity to modify the IntegrationAppConfig. It is intended to be passed during integration App construction to modify the behavior of the integration App.
func WithInitChainerModuleFn ¶ added in v0.0.10
func WithInitChainerModuleFn(fn InitChainerModuleFn) IntegrationAppOptionFn
WithInitChainerModuleFn returns an IntegrationAppOptionFn that appends the given InitChainerModuleFn to the IntegrationAppConfig's InitChainerModuleFns.
func WithModuleGenesisState ¶ added in v0.0.10
func WithModuleGenesisState[T module.HasGenesis](genesisState cosmostypes.Msg) IntegrationAppOptionFn
WithModuleGenesisState returns an IntegrationAppOptionFn that appends an InitChainerModuleFn to the IntegrationAppConfig's InitChainerModuleFns which initializes the module's genesis state with the given genesisState. T is expected to be the module's AppModule type.
func WithTokenLogicModules ¶
func WithTokenLogicModules(tokenLogicModules []tlm.TokenLogicModule) IntegrationAppOptionFn
WithTokenLogicModules returns an IntegrationAppOptionFn that sets the given TLM processors on the IntegrationAppConfig.