types

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

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

Go to latest
Published: May 1, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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 ChannelCounterparty struct {
	PortID    string `json:"port_id"`
	ChannelID string `json:"channel_id"`
}

type ChannelFilter

type ChannelFilter struct {
	Rule        string
	ChannelList []string
}

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 ChannelOutput struct {
	State          string              `json:"state"`
	Ordering       string              `json:"ordering"`
	Counterparty   ChannelCounterparty `json:"counterparty"`
	ConnectionHops []string            `json:"connection_hops"`
	Version        string              `json:"version"`
	PortID         string              `json:"port_id"`
	ChannelID      string              `json:"channel_id"`
}

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

func (c Config) Clone() Config

func (Config) IsFullyConfigured

func (c Config) IsFullyConfigured() bool

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 (c Config) MergeChainSpecConfig(other Config) Config

func (Config) VerifyCoinType

func (c Config) VerifyCoinType() (string, error)

func (*Config) WithCodeCoverage

func (c *Config) WithCodeCoverage(override ...string)

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

func (i DockerImage) PullImage(ctx context.Context, client *client.Client) error

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 IBCTimeout struct {
	NanoSeconds uint64
	Height      int64
}

type ICSConfig

type ICSConfig struct {
	ProviderVerOverride     string         `yaml:"provider,omitempty" json:"provider,omitempty"`
	ConsumerVerOverride     string         `yaml:"consumer,omitempty" json:"consumer,omitempty"`
	ConsumerCopyProviderKey func(int) bool `yaml:"-" json:"-"`
}

type PathUpdateOptions

type PathUpdateOptions struct {
	ChannelFilter *ChannelFilter
	SrcClientID   *string
	SrcConnID     *string
	SrcChainID    *string
	DstClientID   *string
	DstConnID     *string
	DstChainID    *string
}

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.

type Wallet

type Wallet interface {
	KeyName() string
	FormattedAddress() string
	Mnemonic() string
	Address() []byte
}

type WalletAmount

type WalletAmount struct {
	Address string
	Denom   string
	Amount  math.Int
}

Jump to

Keyboard shortcuts

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