integration

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 62 Imported by: 0

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

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

func NewCompleteIntegrationApp(t *testing.T) *App

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

func (app *App) GetAuthority() string

GetAuthority returns the authority address used by the application.

func (*App) GetCodec

func (app *App) GetCodec() codec.Codec

GetCodec returns the codec used by the application.

func (*App) GetKeyRing

func (app *App) GetKeyRing() keyring.Keyring

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) GetSdkCtx

func (app *App) GetSdkCtx() *sdk.Context

GetSdkCtx returns the context used by the application.

func (*App) NextBlock

func (app *App) NextBlock(t *testing.T)

NextBlock commits and finalizes all existing transactions. It then updates and advances the context of the App.

func (*App) NextBlocks

func (app *App) NextBlocks(t *testing.T, numBlocks int)

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

func (app *App) RunMsg(t *testing.T, msg sdk.Msg, option ...RunOption) *codectypes.Any

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 RunConfig

type RunConfig struct {
	AutomaticFinalizeBlock bool
	AutomaticCommit        bool
}

RunConfig is the configuration for the testing integration app.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL