integration

package
v0.0.0-...-4fb2347 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Genesis_COMMIT = iota
	Genesis_NOCOMMIT
	Genesis_SKIP
)
View Source
const DefaultGenTxGas = 10000000

Variables

View Source
var DefaultConsensusParams = &cmtproto.ConsensusParams{
	Version: &cmtproto.VersionParams{
		App: 1,
	},
	Block: &cmtproto.BlockParams{
		MaxBytes: 200000,
		MaxGas:   100_000_000,
	},
	Evidence: &cmtproto.EvidenceParams{
		MaxAgeNumBlocks: 302400,
		MaxAgeDuration:  504 * time.Hour,
		MaxBytes:        10000,
	},
	Validator: &cmtproto.ValidatorParams{
		PubKeyTypes: []string{
			cmttypes.ABCIPubKeyTypeEd25519,
			cmttypes.ABCIPubKeyTypeSecp256k1,
		},
	},
}

DefaultConsensusParams defines the default CometBFT consensus params used in SimApp testing.

View Source
var ErrInvalidMsgType = fmt.Errorf("invalid message type")

Functions

func CreateRandomValidatorSet

func CreateRandomValidatorSet() (*cmttypes.ValidatorSet, error)

CreateRandomValidatorSet creates a validator set with one random validator

func EventsFromContext

func EventsFromContext(ctx context.Context) []event.Event

func GasMeterFactory

func GasMeterFactory(ctx context.Context) func() gas.Meter

func GasMeterFromContext

func GasMeterFromContext(ctx context.Context) gas.Meter

func GetAttribute

func GetAttribute(e event.Event, key string) (event.Attribute, bool)

func GetAttributes

func GetAttributes(e []event.Event, key string) ([]event.Attribute, bool)

func HeaderInfoFromContext

func HeaderInfoFromContext(ctx context.Context) header.Info

func NewGenesisTxCodec

func NewGenesisTxCodec(txConfigOptions tx.ConfigOptions) *genesisTxCodec

func SetCometInfo

func SetCometInfo(ctx context.Context, c comet.Info) context.Context

func SetGasMeter

func SetGasMeter(ctx context.Context, meter gas.Meter) context.Context

func SetHeaderInfo

func SetHeaderInfo(ctx context.Context, h header.Info) context.Context

Types

type App

type App struct {
	*runtime.App[stateMachineTx]

	Store store.RootStore
	// contains filtered or unexported fields
}

App is a wrapper around runtime.App that provides additional testing utilities.

func NewApp

func NewApp(
	appConfig depinject.Config,
	startupConfig StartupConfig,
	extraOutputs ...interface{},
) (*App, error)

NewApp initializes a new runtime.App. A Nop logger is set in runtime.App. appConfig defines the application configuration (f.e. app_config.go). extraOutputs defines the extra outputs to be assigned by the dependency injector (depinject).

func (*App) CheckBalance

func (a *App) CheckBalance(
	t *testing.T, ctx context.Context, addr sdk.AccAddress, expected sdk.Coins, keeper bankkeeper.Keeper,
)

CheckBalance checks the balance of the given address.

func (*App) Close

func (a *App) Close() error

func (*App) Commit

func (a *App) Commit(state corestore.WriterMap) ([]byte, error)

Commit commits the given state and returns the new state hash.

func (*App) Deliver

func (a *App) Deliver(
	t *testing.T, ctx context.Context, txs []stateMachineTx,
) (*server.BlockResponse, corestore.WriterMap)

Deliver delivers a block with the given transactions and returns the resulting state.

func (App) LastBlockHeight

func (a App) LastBlockHeight() uint64

func (*App) RunMsg

func (app *App) RunMsg(t *testing.T, ctx context.Context, handler handler, option ...Option) (resp transaction.Msg, err error)

RunMsg runs the handler for a transaction message. It required the context to have the integration context. a new state is committed if the option WithAutomaticCommit is set in options.

func (*App) SignCheckDeliver

func (a *App) SignCheckDeliver(
	t *testing.T, ctx context.Context, msgs []sdk.Msg,
	chainID string, accNums, accSeqs []uint64, privateKeys []cryptotypes.PrivKey,
	txErrString string,
) server.TxResult

SignCheckDeliver signs and checks the given messages and delivers them.

func (*App) StateLatestContext

func (a *App) StateLatestContext(tb testing.TB) context.Context

StateLatestContext creates returns a new context from context.Background() with the latest state.

type BranchService

type BranchService struct{}

custom branch service for integration tests

func (*BranchService) Execute

func (bs *BranchService) Execute(ctx context.Context, f func(ctx context.Context) error) error

func (*BranchService) ExecuteWithGasLimit

func (bs *BranchService) ExecuteWithGasLimit(
	ctx context.Context,
	gasLimit uint64,
	f func(ctx context.Context) error,
) (gasUsed uint64, err error)

type GasService

type GasService struct{}

func (*GasService) GasConfig

func (g *GasService) GasConfig(ctx context.Context) gas.GasConfig

func (*GasService) GasMeter

func (g *GasService) GasMeter(ctx context.Context) gas.Meter

type GenesisAccount

type GenesisAccount struct {
	authtypes.GenesisAccount
	Coins sdk.Coins
}

type HeaderService

type HeaderService struct{}

func (*HeaderService) HeaderInfo

func (h *HeaderService) HeaderInfo(ctx context.Context) header.Info

type Option

type Option func(*RunMsgConfig)

Option is a function that can be used to configure the integration app.

func WithAutomaticCommit

func WithAutomaticCommit() Option

WithAutomaticCommit enables automatic commit. This means that the integration app will automatically commit the state after each msg.

type RouterService

type RouterService struct {
	// contains filtered or unexported fields
}

custom router service for integration tests

func NewRouterService

func NewRouterService() *RouterService

func (RouterService) CanInvoke

func (rs RouterService) CanInvoke(ctx context.Context, typeUrl string) error

func (RouterService) Invoke

func (*RouterService) RegisterHandler

func (rs *RouterService) RegisterHandler(handler routerHandler, typeUrl string)

type RunMsgConfig

type RunMsgConfig struct {
	Commit bool
}

RunMsgConfig defines the run message configuration.

type StartupConfig

type StartupConfig struct {
	// ValidatorSet defines a custom validator set to be validating the app.
	ValidatorSet func() (*cmttypes.ValidatorSet, error)
	// AppOption defines the additional operations that will be run in the app builder phase.
	AppOption runtime.AppBuilderOption[stateMachineTx]
	// GenesisBehavior defines the behavior of the app at genesis.
	GenesisBehavior int
	// GenesisAccounts defines the genesis accounts to be used in the app.
	GenesisAccounts []GenesisAccount
	// HomeDir defines the home directory of the app where config and data will be stored.
	HomeDir string
	// BranchService defines the custom branch service to be used in the app.
	BranchService corebranch.Service
	// RouterServiceBuilder defines the custom builder
	// for msg router and query router service to be used in the app.
	RouterServiceBuilder runtime.RouterServiceBuilder
	// HeaderService defines the custom header service to be used in the app.
	HeaderService header.Service

	GasService gas.Service
}

StartupConfig defines the startup configuration of a new test app.

func DefaultStartUpConfig

func DefaultStartUpConfig(tb testing.TB) StartupConfig

Directories

Path Synopsis
accounts

Jump to

Keyboard shortcuts

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