testsuite

package
v0.0.0-...-038b244 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 71 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ChainImageEnv specifies the image that the chains will use. If left unspecified, it will
	// default to being determined based on the specified binary. E.g. ghcr.io/cosmos/ibc-go-simd
	ChainImageEnv = "CHAIN_IMAGE"
	// ChainATagEnv specifies the tag that Chain A will use.
	ChainATagEnv = "CHAIN_A_TAG"
	// ChainBTagEnv specifies the tag that Chain B will use. If unspecified
	// the value will default to the same value as Chain A.
	ChainBTagEnv = "CHAIN_B_TAG"
	// RelayerIDEnv specifies the ID of the relayer to use.
	RelayerIDEnv = "RELAYER_ID"
	// ChainBinaryEnv binary is the binary that will be used for both chains.
	ChainBinaryEnv = "CHAIN_BINARY"
	// ChainUpgradeTagEnv specifies the upgrade version tag
	ChainUpgradeTagEnv = "CHAIN_UPGRADE_TAG"
	// ChainUpgradePlanEnv specifies the upgrade plan name
	ChainUpgradePlanEnv = "CHAIN_UPGRADE_PLAN"
	// E2EConfigFilePathEnv allows you to specify a custom path for the config file to be used.
	E2EConfigFilePathEnv = "E2E_CONFIG_PATH"
)
View Source
const (
	// ChainARelayerName is the name given to the relayer wallet on ChainA
	ChainARelayerName = "rlyA"
	// ChainBRelayerName is the name given to the relayer wallet on ChainB
	ChainBRelayerName = "rlyB"
	// DefaultGasValue is the default gas value used to configure tx.Factory
	DefaultGasValue = 500_000_0000
)

Variables

This section is empty.

Functions

func ABCIToSDKEvents

func ABCIToSDKEvents(abciEvents []abci.Event) sdk.Events

ABCIToSDKEvents converts a list of ABCI events to Cosmos SDK events.

func Codec

func Codec() *codec.ProtoCodec

Codec returns the global E2E protobuf codec.

func EncodingConfig

func EncodingConfig() simappparams.EncodingConfig

EncodingConfig returns the global E2E encoding config.

func GetChainATag

func GetChainATag() string

func GetChainBTag

func GetChainBTag() string

func GetIBCToken

func GetIBCToken(fullTokenDenom string, portID, channelID string) transfertypes.DenomTrace

GetIBCToken returns the denomination of the full token denom sent to the receiving channel

func IsCI

func IsCI() bool

IsCI returns true if the tests are running in CI, false is returned if the tests are running locally. Note: github actions passes a CI env value of true by default to all runners.

func IsFork

func IsFork() bool

IsFork returns true if the tests are running in fork mode, false is returned otherwise.

func MustProtoMarshalJSON

func MustProtoMarshalJSON(msg proto.Message) []byte

MustProtoMarshalJSON provides an auxiliary function to return Proto3 JSON encoded bytes of a message. This function should be used when marshalling a proto.Message from the e2e tests. This function strips out unknown fields. This is useful for backwards compatibility tests where the types imported by the e2e package have new fields that older versions do not recognize.

func SDKEncodingConfig

func SDKEncodingConfig() *testutil.TestEncodingConfig

SDKEncodingConfig returns the global E2E encoding config.

func UnmarshalMsgResponses

func UnmarshalMsgResponses(txResp sdk.TxResponse, msgs ...codec.ProtoMarshaler) error

UnmarshalMsgResponses attempts to unmarshal the tx msg responses into the provided message types.

Types

type ChainConfig

type ChainConfig struct {
	ChainID       string `yaml:"chainId"`
	Name          string `yaml:"name"`
	Image         string `yaml:"image"`
	Tag           string `yaml:"tag"`
	Binary        string `yaml:"binary"`
	NumValidators int    `yaml:"numValidators"`
	NumFullNodes  int    `yaml:"numFullNodes"`
}

ChainConfig holds information about an individual chain used in the tests.

type ChainOptionConfiguration

type ChainOptionConfiguration func(options *ChainOptions)

ChainOptionConfiguration enables arbitrary configuration of ChainOptions.

type ChainOptions

type ChainOptions struct {
	ChainASpec       *interchaintest.ChainSpec
	ChainBSpec       *interchaintest.ChainSpec
	SkipPathCreation bool
}

ChainOptions stores chain configurations for the chains that will be created for the tests. They can be modified by passing ChainOptionConfiguration to E2ETestSuite.GetChains.

func DefaultChainOptions

func DefaultChainOptions() ChainOptions

DefaultChainOptions returns the default configuration for the chains. These options can be configured by passing configuration functions to E2ETestSuite.GetChains.

type CometBFTConfig

type CometBFTConfig struct {
	LogLevel string `yaml:"logLevel"`
}

type DebugConfig

type DebugConfig struct {
	// DumpLogs forces the logs to be collected before removing test containers.
	DumpLogs bool `yaml:"dumpLogs"`

	// GenesisDebug contains debug information specific to Genesis.
	GenesisDebug GenesisDebugConfig `yaml:"genesis"`
}

type E2ETestSuite

type E2ETestSuite struct {
	testifysuite.Suite

	DockerClient *dockerclient.Client
	// contains filtered or unexported fields
}

E2ETestSuite has methods and functionality which can be shared among all test suites.

func (*E2ETestSuite) AssertHumanReadableDenom

func (s *E2ETestSuite) AssertHumanReadableDenom(ctx context.Context, chain ibc.Chain, counterpartyNativeDenom string, counterpartyChannel ibc.ChannelOutput)

AssertHumanReadableDenom asserts that a human readable denom is present for a given chain.

func (*E2ETestSuite) AssertPacketRelayed

func (s *E2ETestSuite) AssertPacketRelayed(ctx context.Context, chain ibc.Chain, portID, channelID string, sequence uint64)

AssertPacketRelayed asserts that the packet commitment does not exist on the sending chain. The packet commitment will be deleted upon a packet acknowledgement or timeout.

func (*E2ETestSuite) AssertTxFailure

func (s *E2ETestSuite) AssertTxFailure(resp sdk.TxResponse, expectedError *errorsmod.Error)

AssertTxFailure verifies that an sdk.TxResponse has failed.

func (*E2ETestSuite) AssertTxSuccess

func (s *E2ETestSuite) AssertTxSuccess(resp sdk.TxResponse)

AssertTxSuccess verifies that an sdk.TxResponse has succeeded.

func (*E2ETestSuite) BroadcastMessages

func (s *E2ETestSuite) BroadcastMessages(ctx context.Context, chain ibc.Chain, user ibc.Wallet, msgs ...sdk.Msg) sdk.TxResponse

BroadcastMessages broadcasts the provided messages to the given chain and signs them on behalf of the provided user. Once the broadcast response is returned, we wait for a few blocks to be created on both chain A and chain B.

func (*E2ETestSuite) ConfigureRelayer

func (s *E2ETestSuite) ConfigureRelayer(ctx context.Context, chainA, chainB ibc.Chain, channelOpts func(*ibc.CreateChannelOptions), buildOptions ...func(options *interchaintest.InterchainBuildOptions)) ibc.Relayer

func (*E2ETestSuite) CreateUpgradeFields

func (s *E2ETestSuite) CreateUpgradeFields(channel channeltypes.Channel) channeltypes.UpgradeFields

CreateUpgradeFields creates upgrade fields for channel with fee middleware

func (*E2ETestSuite) CreateUserOnChainA

func (s *E2ETestSuite) CreateUserOnChainA(ctx context.Context, amount int64) ibc.Wallet

CreateUserOnChainA creates a user with the given amount of funds on chain A.

func (*E2ETestSuite) CreateUserOnChainB

func (s *E2ETestSuite) CreateUserOnChainB(ctx context.Context, amount int64) ibc.Wallet

CreateUserOnChainB creates a user with the given amount of funds on chain B.

func (*E2ETestSuite) ExecuteAndPassGovV1Beta1Proposal

func (s *E2ETestSuite) ExecuteAndPassGovV1Beta1Proposal(ctx context.Context, chain ibc.Chain, user ibc.Wallet, content govtypesv1beta1.Content)

ExecuteAndPassGovV1Beta1Proposal submits the given v1beta1 governance proposal using the provided user and uses all validators to vote yes on the proposal. It ensures the proposal successfully passes.

func (*E2ETestSuite) ExecuteAndPassGovV1Proposal

func (s *E2ETestSuite) ExecuteAndPassGovV1Proposal(ctx context.Context, msg sdk.Msg, chain ibc.Chain, user ibc.Wallet)

ExecuteAndPassGovV1Proposal submits a v1 governance proposal using the provided user and message and uses all validators to vote yes on the proposal. It ensures the proposal successfully passes.

func (*E2ETestSuite) ExecuteGovV1Beta1Proposal

func (s *E2ETestSuite) ExecuteGovV1Beta1Proposal(ctx context.Context, chain ibc.Chain, user ibc.Wallet, content govtypesv1beta1.Content) sdk.TxResponse

ExecuteGovV1Beta1Proposal submits a v1beta1 governance proposal using the provided content.

func (*E2ETestSuite) ExecuteGovV1Proposal

func (s *E2ETestSuite) ExecuteGovV1Proposal(ctx context.Context, msg sdk.Msg, chain ibc.Chain, user ibc.Wallet) error

ExecuteGovV1Proposal submits a v1 governance proposal using the provided user and message and uses all validators to vote yes on the proposal.

func (*E2ETestSuite) ExtractValueFromEvents

func (*E2ETestSuite) ExtractValueFromEvents(events []abci.Event, eventType, attrKey string) (string, bool)

ExtractValueFromEvents extracts the value of an attribute from a list of events. If the attribute is not found, the function returns an empty string and false. If the attribute is found, the function returns the value and true.

func (*E2ETestSuite) FeeMiddlewareChannelOptions

func (s *E2ETestSuite) FeeMiddlewareChannelOptions() func(options *ibc.CreateChannelOptions)

FeeMiddlewareChannelOptions configures both of the chains to have fee middleware enabled.

func (*E2ETestSuite) GetChainANativeBalance

func (s *E2ETestSuite) GetChainANativeBalance(ctx context.Context, user ibc.Wallet) (int64, error)

GetChainANativeBalance gets the balance of a given user on chain A.

func (*E2ETestSuite) GetChainBNativeBalance

func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user ibc.Wallet) (int64, error)

GetChainBNativeBalance gets the balance of a given user on chain B.

func (*E2ETestSuite) GetChains

func (s *E2ETestSuite) GetChains(chainOpts ...ChainOptionConfiguration) (ibc.Chain, ibc.Chain)

GetChains returns two chains that can be used in a test. The pair returned is unique to the current test being run. Note: this function does not create containers.

func (*E2ETestSuite) GetPathName

func (s *E2ETestSuite) GetPathName(idx int64) string

GetPathName returns the name of a path at a specific index. This can be used in tests when the path name is required.

func (*E2ETestSuite) GetRelayerExecReporter

func (s *E2ETestSuite) GetRelayerExecReporter() *testreporter.RelayerExecReporter

GetRelayerExecReporter returns a testreporter.RelayerExecReporter instances using the current test's testing.T.

func (*E2ETestSuite) GetRelayerUsers

func (s *E2ETestSuite) GetRelayerUsers(ctx context.Context, chainOpts ...ChainOptionConfiguration) (ibc.Wallet, ibc.Wallet)

GetRelayerUsers returns two ibc.Wallet instances which can be used for the relayer users on the two chains.

func (*E2ETestSuite) GetRelayerWallets

func (s *E2ETestSuite) GetRelayerWallets(ibcrelayer ibc.Relayer) (ibc.Wallet, ibc.Wallet, error)

GetRelayerWallets returns the ibcrelayer wallets associated with the chains.

func (*E2ETestSuite) GetTimeoutHeight

func (s *E2ETestSuite) GetTimeoutHeight(ctx context.Context, chain ibc.Chain) clienttypes.Height

GetTimeoutHeight returns a timeout height of 1000 blocks above the current block height. This function should be used when the timeout is never expected to be reached

func (*E2ETestSuite) InitiateChannelUpgrade

func (s *E2ETestSuite) InitiateChannelUpgrade(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet, portID, channelID string, upgradeFields channeltypes.UpgradeFields)

InitiateChannelUpgrade creates and submits a governance proposal to execute the message to initiate a channel upgrade

func (*E2ETestSuite) PayPacketFeeAsync

func (s *E2ETestSuite) PayPacketFeeAsync(
	ctx context.Context,
	chain ibc.Chain,
	user ibc.Wallet,
	packetID channeltypes.PacketId,
	packetFee feetypes.PacketFee,
) sdk.TxResponse

PayPacketFeeAsync broadcasts a MsgPayPacketFeeAsync message.

func (*E2ETestSuite) PruneAcknowledgements

func (s *E2ETestSuite) PruneAcknowledgements(
	ctx context.Context,
	chain ibc.Chain,
	user ibc.Wallet,
	portID, channelID string,
	limit uint64,
) sdk.TxResponse

PruneAcknowledgements broadcasts a MsgPruneAcknowledgements message.

func (*E2ETestSuite) QueryTxsByEvents

func (*E2ETestSuite) QueryTxsByEvents(
	ctx context.Context, chain ibc.Chain,
	page, limit int, queryReq, orderBy string,
) (*sdk.SearchTxsResult, error)

QueryTxsByEvents runs the QueryTxsByEvents command on the given chain. https://github.com/cosmos/cosmos-sdk/blob/65ab2530cc654fd9e252b124ed24cbaa18023b2b/x/auth/client/cli/query.go#L33

func (*E2ETestSuite) RecoverRelayerWallets

func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, ibcrelayer ibc.Relayer) error

RecoverRelayerWallets adds the corresponding ibcrelayer address to the keychain of the chain. This is useful if commands executed on the chains expect the relayer information to present in the keychain.

func (*E2ETestSuite) RegisterCounterPartyPayee

func (s *E2ETestSuite) RegisterCounterPartyPayee(ctx context.Context, chain ibc.Chain,
	user ibc.Wallet, portID, channelID, relayerAddr, counterpartyPayeeAddr string,
) sdk.TxResponse

RegisterCounterPartyPayee broadcasts a MsgRegisterCounterpartyPayee message.

func (*E2ETestSuite) RestartRelayer

func (s *E2ETestSuite) RestartRelayer(ctx context.Context, ibcrelayer ibc.Relayer)

RestartRelayer restarts the given relayer.

func (*E2ETestSuite) SetUpgradeTimeoutParam

func (s *E2ETestSuite) SetUpgradeTimeoutParam(ctx context.Context, chain ibc.Chain, wallet ibc.Wallet)

SetUpgradeTimeoutParam creates and submits a governance proposal to execute the message to update 04-channel params with a timeout of 1s

func (*E2ETestSuite) SetupChainsRelayerAndChannel

func (s *E2ETestSuite) SetupChainsRelayerAndChannel(ctx context.Context, channelOpts func(*ibc.CreateChannelOptions), chainSpecOpts ...ChainOptionConfiguration) (ibc.Relayer, ibc.ChannelOutput)

SetupChainsRelayerAndChannel create two chains, a relayer, establishes a connection and creates a channel using the given channel options. The relayer returned by this function has not yet started. It should be started with E2ETestSuite.StartRelayer if needed. This should be called at the start of every test, unless fine grained control is required.

func (*E2ETestSuite) SetupClients

func (s *E2ETestSuite) SetupClients(ctx context.Context, ibcrelayer ibc.Relayer, opts ibc.CreateClientOptions)

SetupClients creates clients on chainA and chainB using the provided create client options

func (*E2ETestSuite) SetupSingleChain

func (s *E2ETestSuite) SetupSingleChain(ctx context.Context) ibc.Chain

SetupSingleChain creates and returns a single CosmosChain for usage in e2e tests. This is useful for testing single chain functionality when performing coordinated upgrades as well as testing localhost ibc client functionality. TODO: Actually setup a single chain. Seeing panic: runtime error: index out of range [0] with length 0 when using a single chain. issue: https://github.com/strangelove-ventures/interchaintest/issues/401

func (*E2ETestSuite) SetupTest

func (s *E2ETestSuite) SetupTest()

func (*E2ETestSuite) StartRelayer

func (s *E2ETestSuite) StartRelayer(ibcrelayer ibc.Relayer)

StartRelayer starts the given ibcrelayer.

func (*E2ETestSuite) StopRelayer

func (s *E2ETestSuite) StopRelayer(ctx context.Context, ibcrelayer ibc.Relayer)

StopRelayer stops the given ibcrelayer.

func (*E2ETestSuite) Transfer

func (s *E2ETestSuite) Transfer(ctx context.Context, chain ibc.Chain, user ibc.Wallet,
	portID, channelID string, token sdk.Coin, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, memo string,
) sdk.TxResponse

Transfer broadcasts a MsgTransfer message.

func (*E2ETestSuite) TransferChannelOptions

func (*E2ETestSuite) TransferChannelOptions() func(options *ibc.CreateChannelOptions)

TransferChannelOptions configures both of the chains to have non-incentivized transfer channels.

func (*E2ETestSuite) UpdateClients

func (s *E2ETestSuite) UpdateClients(ctx context.Context, ibcrelayer ibc.Relayer, pathName string)

UpdateClients updates clients on chainA and chainB

type GenesisDebugConfig

type GenesisDebugConfig struct {
	// DumpGenesisDebugInfo enables the output of Genesis debug files.
	DumpGenesisDebugInfo bool `yaml:"dumpGenesisDebugInfo"`

	// ExportFilePath specifies which path to export Genesis debug files to.
	ExportFilePath string `yaml:"filePath"`

	// ChainName represent which chain to get Genesis debug info for.
	ChainName string `yaml:"chainName"`
}

type TestConfig

type TestConfig struct {
	// ChainConfigs holds configuration values related to the chains used in the tests.
	ChainConfigs []ChainConfig `yaml:"chains"`
	// RelayerConfig holds all known relayer configurations that can be used in the tests.
	RelayerConfigs []relayer.Config `yaml:"relayers"`
	// ActiveRelayer specifies the relayer that will be used. It must match the ID of one of the entries in RelayerConfigs.
	ActiveRelayer string `yaml:"activeRelayer"`
	// UpgradeConfig holds values used only for the upgrade tests.
	UpgradeConfig UpgradeConfig `yaml:"upgrade"`
	// CometBFTConfig holds values for configuring CometBFT.
	CometBFTConfig CometBFTConfig `yaml:"cometbft"`
	// DebugConfig holds configuration for miscellaneous options.
	DebugConfig DebugConfig `yaml:"debug"`
}

TestConfig holds configuration used throughout the different e2e tests.

func LoadConfig

func LoadConfig() TestConfig

LoadConfig attempts to load a atest configuration from the default file path. if any environment variables are specified, they will take precedence over the individual configuration options.

func (TestConfig) GetActiveRelayerConfig

func (tc TestConfig) GetActiveRelayerConfig() *relayer.Config

GetActiveRelayerConfig returns the currently specified relayer config.

func (TestConfig) GetChainAID

func (tc TestConfig) GetChainAID() string

GetChainAID returns the chain-id for chain A.

func (TestConfig) GetChainBID

func (tc TestConfig) GetChainBID() string

GetChainBID returns the chain-id for chain B.

func (TestConfig) GetChainIndex

func (tc TestConfig) GetChainIndex(name string) (int, error)

GetChainIndex returns the index of the chain with the given name, if it exists.

func (TestConfig) GetChainName

func (tc TestConfig) GetChainName(idx int) string

GetChainName returns the name of the chain given an index.

func (TestConfig) GetChainNumFullNodes

func (tc TestConfig) GetChainNumFullNodes(idx int) int

GetChainNumFullNodes returns the number of full nodes for the specific chain index. default 0

func (TestConfig) GetChainNumValidators

func (tc TestConfig) GetChainNumValidators(idx int) int

GetChainNumValidators returns the number of validators for the specific chain index. default 1

func (TestConfig) GetGenesisChainName

func (tc TestConfig) GetGenesisChainName() string

GetGenesisChainName returns the name of the chain for which to dump Genesis files. If no chain is provided, it uses the default one (chainA).

func (TestConfig) Validate

func (tc TestConfig) Validate() error

Validate validates the test configuration is valid for use within the tests. this should be called before using the configuration.

type UpgradeConfig

type UpgradeConfig struct {
	PlanName string `yaml:"planName"`
	Tag      string `yaml:"tag"`
}

UpgradeConfig holds values relevant to upgrade tests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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