Documentation
¶
Index ¶
- Constants
- type Chain
- type ChannelCounterparty
- type ChannelFilter
- type ChannelOutput
- type ClientOutput
- type ClientOutputs
- type ClientState
- type CometMockConfig
- type Config
- type DockerImage
- type GenesisConfig
- type IBCTimeout
- type ICSConfig
- type PathUpdateOptions
- type RelayerImplementation
- type SidecarConfig
- type TransferOptions
- type Wallet
- type WalletAmount
Constants ¶
const (
Cosmos = "cosmos"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain interface {
// Config fetches the chain configuration.
Config() Config
// Initialize initializes node structs so that things like initializing keys can be done before starting the chain
Initialize(ctx context.Context, testName string, cli *client.Client, networkID string) error
// Start sets up everything needed (validators, gentx, fullnodes, peering, additional accounts) for chain to start from genesis.
Start(ctx context.Context, additionalGenesisWallets ...WalletAmount) error
// Stop stops the running chain and gracefully cleans up associated resources. It returns an error if the operation fails.
Stop(ctx context.Context) error
// Exec runs an arbitrary command using Chain's docker environment.
// Whether the invoked command is run in a one-off container or execing into an already running container
// is up to the chain implementation.
//
// "env" are environment variables in the format "MY_ENV_VAR=value"
Exec(ctx context.Context, cmd []string, env []string) (stdout, stderr []byte, err error)
// ExportState exports the chain state at specific height.
ExportState(ctx context.Context, height int64) (string, error)
// GetRPCAddress retrieves the rpc address that can be reached by other containers in the docker network.
GetRPCAddress() string
// GetGRPCAddress retrieves the grpc address that can be reached by other containers in the docker network.
GetGRPCAddress() string
// GetHostRPCAddress returns the rpc address that can be reached by processes on the host machine.
// Note that this will not return a valid value until after Start returns.
GetHostRPCAddress() string
// GetHostPeerAddress returns the p2p address that can be reached by processes on the host machine.
// Note that this will not return a valid value until after Start returns.
GetHostPeerAddress() string
// GetHostGRPCAddress returns the grpc address that can be reached by processes on the host machine.
// Note that this will not return a valid value until after Start returns.
GetHostGRPCAddress() string
// HomeDir is the home directory of a node running in a docker container. Therefore, this maps to
// the container's filesystem (not the host).
HomeDir() string
// CreateKey creates a test key in the "user" node (either the first fullnode or the first validator if no fullnodes).
CreateKey(ctx context.Context, keyName string) error
// RecoverKey recovers an existing user from a given mnemonic.
RecoverKey(ctx context.Context, name, mnemonic string) error
// GetAddress fetches the bech32 address for a test key on the "user" node (either the first fullnode or the first validator if no fullnodes).
GetAddress(ctx context.Context, keyName string) ([]byte, error)
// SendFunds sends funds to a wallet from a user account.
SendFunds(ctx context.Context, keyName string, amount WalletAmount) error
// Height returns the current block height or an error if unable to get current height.
Height(ctx context.Context) (int64, error)
// GetBalance fetches the current balance for a specific account address and denom.
GetBalance(ctx context.Context, address string, denom string) (math.Int, error)
// GetGasFeesInNativeDenom gets the fees in native denom for an amount of spent gas.
GetGasFeesInNativeDenom(gasPaid int64) int64
// BuildWallet will return a chain-specific wallet
// If mnemonic != "", it will restore using that mnemonic
// If mnemonic == "", it will create a new key, mnemonic will not be populated
BuildWallet(ctx context.Context, keyName string, mnemonic string) (Wallet, error)
}
type ChannelCounterparty ¶
type ChannelFilter ¶
ChannelFilter provides the means for either creating an allowlist or a denylist of channels on the src chain which will be used to narrow down the list of channels a user wants to relay on.
type ChannelOutput ¶
type ClientOutput ¶
type ClientOutput struct {
ClientID string `json:"client_id"`
ClientState ClientState `json:"client_state"`
}
type ClientOutputs ¶
type ClientOutputs []*ClientOutput
type ClientState ¶
type ClientState struct {
ChainID string `json:"chain_id"`
}
type CometMockConfig ¶
type CometMockConfig struct {
Image DockerImage `yaml:"image"`
BlockTimeMs int `yaml:"block-time"`
}
type Config ¶
type Config struct {
// Chain type, e.g. cosmos.
Type string `yaml:"type"`
// Chain name, e.g. cosmoshub.
Name string `yaml:"name"`
// Chain ID, e.g. cosmoshub-4
ChainID string `yaml:"chain-id"`
// Docker images required for running chain nodes.
Images []DockerImage `yaml:"images"`
// Binary to execute for the chain node daemon.
Bin string `yaml:"bin"`
// Bech32 prefix for chain addresses, e.g. cosmos.
Bech32Prefix string `yaml:"bech32-prefix"`
// Denomination of native currency, e.g. uatom.
Denom string `yaml:"denom"`
// Coin type
CoinType string `default:"118" yaml:"coin-type"`
// Minimum gas prices for sending transactions, in native currency denom.
GasPrices string `yaml:"gas-prices"`
// Adjustment multiplier for gas fees.
GasAdjustment float64 `yaml:"gas-adjustment"`
// Default gas limit for transactions. May be empty, "auto", or a number.
Gas string `yaml:"gas" default:"auto"`
// Trusting period of the chain.
TrustingPeriod string `yaml:"trusting-period"`
// Do not use docker host mount.
NoHostMount bool `yaml:"no-host-mount"`
// When true, will skip validator gentx flow
SkipGenTx bool
// When provided, will run before performing gentx and genesis file creation steps for validators.
PreGenesis func(Chain) error
// When provided, genesis file contents will be altered before sharing for genesis.
ModifyGenesis func(Config, []byte) ([]byte, error)
// Override config parameters for files at filepath.
ConfigFileOverrides map[string]any
// Non-nil will override the encoding config, used for cosmos chains only.
EncodingConfig *testutil.TestEncodingConfig
// To avoid port binding conflicts, ports are only exposed on the 0th validator.
HostPortOverride map[int]int `yaml:"host-port-override"`
// ExposeAdditionalPorts exposes each port id to the host on a random port. ex: "8080/tcp"
// Access the address with ChainNode.GetHostAddress
ExposeAdditionalPorts []string
// Additional start command arguments
AdditionalStartArgs []string
// Environment variables for chain nodes
Env []string
}
Config defines the chain parameters requires to run an interchaintest testnet for a chain.
func (Config) IsFullyConfigured ¶
IsFullyConfigured reports whether all required fields have been set on c. It is possible for some fields, such as GasAdjustment and NoHostMount, to be their respective zero values and for IsFullyConfigured to still report true.
func (Config) MergeChainSpecConfig ¶
func (Config) VerifyCoinType ¶
func (*Config) WithCodeCoverage ¶
WithCodeCoverage enables Go Code Coverage from the chain node directory.
type DockerImage ¶
type DockerImage struct {
Repository string `json:"repository" yaml:"repository"`
Version string `json:"version" yaml:"version"`
UIDGID string `json:"uid-gid" yaml:"uid-gid"`
}
func NewDockerImage ¶
func NewDockerImage(repository, version, uidGID string) DockerImage
func (DockerImage) IsFullyConfigured ¶
func (i DockerImage) IsFullyConfigured() bool
IsFullyConfigured reports whether all of i's required fields are present. Version is not required, as it can be superseded by a ChainSpec version.
func (DockerImage) Ref ¶
func (i DockerImage) Ref() string
Ref returns the reference to use when e.g. creating a container.
func (DockerImage) Validate ¶
func (i DockerImage) Validate() error
Validate returns an error describing which of i's required fields are missing and returns nil if all required fields are present. Version is not required, as it can be superseded by a ChainSpec version.
type GenesisConfig ¶
type GenesisConfig struct {
// Genesis file contents for the chain (e.g. genesis.json for CometBFT chains).
Contents []byte
// If true, all validators will be emulated in the genesis file.
// By default, only the first 2/3 (sorted by Voting Power desc) of validators will be emulated.
AllValidators bool
// MaxVals is a safeguard so that we don't accidentally emulate too many validators. Defaults to 10.
// If more than MaxVals validators are required to meet 2/3 VP, the test will fail.
MaxVals int
}
GenesisConfig is used to start a chain from a pre-defined genesis state.
type IBCTimeout ¶
type PathUpdateOptions ¶
type RelayerImplementation ¶
type RelayerImplementation int64
const ( CosmosRly RelayerImplementation = iota Hermes Hyperspace )
type SidecarConfig ¶
type SidecarConfig struct {
ProcessName string
Image DockerImage
HomeDir string
Ports []string
StartCmd []string
Env []string
PreStart bool
ValidatorProcess bool
}
SidecarConfig describes the configuration options for instantiating a new sidecar process.
type TransferOptions ¶
type TransferOptions struct {
Timeout *IBCTimeout
Memo string
AbsoluteTimeouts bool
Port string // default: transfer
}
TransferOptions defines the options for an IBC packet transfer.