interchaintest

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

README

End-to-End/Integration Testing for the System

Config Setup

Config supports expanding with any available runtime OS environment variables, e.g. ${HOME}, ${USER}, ${PWD}, ${BASE_PATH}

$BASE_PATH environment variable is also available which points to the root of the project.

Setting up the test Environment

Documentation

Index

Constants

View Source
const (
	FaucetAccountKeyName = "faucet"
	IBCOwnerAccount      = "ibc-owner"
	XCallOwnerAccount    = "xcall-owner"
	UserAccount          = "user"
)

Variables

This section is empty.

Functions

func BackupConfig

func BackupConfig(chain chains.Chain) error

for saving data in particular format

func CleanBackupConfig

func CleanBackupConfig()

func CleanDockerSetup

func CleanDockerSetup(t *testing.T, name string)

func CreateLogFile

func CreateLogFile(name string) (*os.File, error)

CreateLogFile creates a file with name in dir $HOME/.interchaintest/logs/

func DefaultBlockDatabaseFilepath

func DefaultBlockDatabaseFilepath() string

DefaultBlockDatabaseFilepath is the default filepath to the sqlite database for tracking blocks and transactions.

func DockerSetup

func DockerSetup(t *testing.T) (*client.Client, string)

DockerSetup returns a new Docker Client and the ID of a configured network, associated with t.

If any part of the setup fails, t.Fatal is called.

func GetLocalFileContent

func GetLocalFileContent(fileName string) ([]byte, error)

func KeepDockerVolumesOnFailure

func KeepDockerVolumesOnFailure(b bool)

KeepDockerVolumesOnFailure sets whether volumes associated with a particular test are retained or deleted following a test failure.

The value is false by default, but can be initialized to true by setting the environment variable IBCTEST_SKIP_FAILURE_CLEANUP to a non-empty value. Alternatively, importers of the interchaintest package may call KeepDockerVolumesOnFailure(true).

func RestoreConfig

func RestoreConfig(chain chains.Chain) error

func StartChainPair

func StartChainPair(
	t *testing.T,
	ctx context.Context,
	rep *testreporter.Reporter,
	cli *client.Client,
	networkID string,
	srcChain, dstChain ibc.Chain,
	f it.RelayerFactory,
	preRelayerStartFuncs []func([]ibc.ChannelOutput),
) (ibc.Relayer, error)

startup both chains creates wallets in the relayer for src and dst chain funds relayer src and dst wallets on respective chain in genesis creates a faucet account on the both chains (separate fullnode) funds faucet accounts in genesis

func StopStartRelayerWithPreStartFuncs

func StopStartRelayerWithPreStartFuncs(
	t *testing.T,
	ctx context.Context,
	srcChainID string,
	relayerImpl ibc.Relayer,
	eRep *testreporter.RelayerExecReporter,
	preRelayerStartFuncs []func([]ibc.ChannelOutput),
	pathNames ...string,
) ([]ibc.ChannelOutput, error)

StopStartRelayerWithPreStartFuncs will stop the relayer if it is currently running, then execute the preRelayerStartFuncs and wait for all to complete before starting the relayer.

Types

type Interchain

type Interchain struct {

	// Map of chain to additional genesis wallets to include at chain start.
	AdditionalGenesisWallets map[ibc.Chain][]ibc.WalletAmount
	// contains filtered or unexported fields
}

Interchain represents a full IBC network, encompassing a collection of one or more chains, one or more relayer instances, and initial account configuration.

func NewInterchain

func NewInterchain() *Interchain

NewInterchain returns a new Interchain.

Typical usage involves multiple calls to AddChain, one or more calls to AddRelayer, one or more calls to AddLink, and then finally a single call to Build.

func (*Interchain) AddChain

func (ic *Interchain) AddChain(chain ibc.Chain, additionalGenesisWallets ...ibc.WalletAmount) *Interchain

AddChain adds the given chain to the Interchain, using the chain ID reported by the chain's config. If the given chain already exists, or if another chain with the same configured chain ID exists, AddChain panics.

func (ic *Interchain) AddLink(link InterchainLink) *Interchain

AddLink adds the given link to the Interchain. If any validation fails, AddLink panics.

func (*Interchain) AddRelayer

func (ic *Interchain) AddRelayer(relayer ibc.Relayer, name string) *Interchain

AddRelayer adds the given relayer with the given name to the Interchain.

func (*Interchain) Build

Build starts all the chains and configures the relayers associated with the Interchain. It is the caller's responsibility to directly call StartRelayer on the relayer implementations.

Calling Build more than once will cause a panic.

func (*Interchain) BuildChains

func (*Interchain) BuildRelayer

func (*Interchain) Close

func (ic *Interchain) Close() error

Close cleans up any resources created during Build, and returns any relevant errors.

func (*Interchain) WithLog

func (ic *Interchain) WithLog(log *zap.Logger) *Interchain

WithLog sets the logger on the interchain object. Usually the default nop logger is fine, but sometimes it can be helpful to see more verbose logs, typically by passing zaptest.NewLogger(t).

type InterchainBuildOptions

type InterchainBuildOptions struct {
	TestName string

	Client    *client.Client
	NetworkID string

	// If set, ic.Build does not create paths or links in the relayer,
	// but it does still configure keys and wallets for declared relayer-chain links.
	// This is useful for tests that need lower-level access to configuring relayers.
	SkipPathCreation bool

	// Optional. Git sha for test invocation. Once Go 1.18 supported,
	// may be deprecated in favor of runtime/debug.ReadBuildInfo.
	GitSha string

	// If set, saves block history to a sqlite3 database to aid debugging.
	BlockDatabaseFile string
}

InterchainBuildOptions describes configuration for (*Interchain).Build.

type InterchainLink struct {
	// Chains involved.
	Chain1, Chain2 ibc.Chain

	// Relayer to use for link.
	Relayer ibc.Relayer

	// Name of path to create.
	Path string

	// If set, these options will be used when creating the client in the path link step.
	// If a zero value initialization is used, e.g. CreateClientOptions{},
	// then the default values will be used via ibc.DefaultClientOpts.
	CreateClientOpts ibc.CreateClientOptions

	// If set, these options will be used when creating the channel in the path link step.
	// If a zero value initialization is used, e.g. CreateChannelOptions{},
	// then the default values will be used via ibc.DefaultChannelOpts.
	CreateChannelOpts ibc.CreateChannelOptions
}

InterchainLink describes a link between two chains, by specifying the chain names, the relayer name, and the name of the path to create.

type Relayer

type Relayer interface {
	ibc.Relayer
	RestartRelayerContainer(context.Context) error
	StopRelayerContainer(context.Context, ibc.RelayerExecReporter) error
	WriteBlockHeight(context.Context, string, uint64) error
	RestoreICONKeystore(ctx context.Context, chainID string, wallet ibc.Wallet) error
}

type RelayerFactory

type RelayerFactory interface {
	// Build returns a Relayer associated with the given arguments.
	Build(t *testing.T, cli *client.Client, networkID string) ibc.Relayer

	// Name returns a descriptive name of the factory,
	// indicating details of the Relayer that will be built.
	Name() string

	// Capabilities is an indication of the features this relayer supports.
	// Tests for any unsupported features will be skipped rather than failed.
	Capabilities() map[relayer.Capability]bool
}

RelayerFactory describes how to start a Relayer.

func NewICONRelayerFactory

func NewICONRelayerFactory(logger *zap.Logger, options ...relayer.RelayerOption) RelayerFactory

Directories

Path Synopsis
e2e
integration
internal
blockdb
Package blockdb saves chain and block data for inspection later to aid in debugging ibctest failures.
Package blockdb saves chain and block data for inspection later to aid in debugging ibctest failures.
dockerutil
Package dockerutil contains helpers for interacting with Docker containers.
Package dockerutil contains helpers for interacting with Docker containers.
mocktesting
Package mocktesting contains a mock instance of *testing.T which is useful for testing ibctest's interactions with Go tests.
Package mocktesting contains a mock instance of *testing.T which is useful for testing ibctest's interactions with Go tests.
Package relayer contains general functionality relevant to individual relayer implementations.
Package relayer contains general functionality relevant to individual relayer implementations.
icon
Package rly provides an interface to the cosmos relayer running in a Docker container.
Package rly provides an interface to the cosmos relayer running in a Docker container.
Package testsuite provides a suite of end-to-end tests for the IBC relayer.
Package testsuite provides a suite of end-to-end tests for the IBC relayer.

Jump to

Keyboard shortcuts

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