ibctesting

package
v0.0.0-...-5628e88 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ChainIDPrefix = "testchain"

Variables

This section is empty.

Functions

func GetChainID

func GetChainID(index int) string

GetChainID returns the chainID used for the provided index.

Types

type ChannelConfig

type ChannelConfig struct {
	PortID  string
	Version string
	Order   types.ChannelOrder
}

func NewChannelConfig

func NewChannelConfig() *ChannelConfig

type ClientConfig

type ClientConfig interface {
	GetClientType() string
}

type ConnectionConfig

type ConnectionConfig struct {
	DelayPeriod uint64
	Version     *connectiontypes.Version
}

func NewConnectionConfig

func NewConnectionConfig() *ConnectionConfig

type Coordinator

type Coordinator struct {
	Chains map[string]types.TestChainI
	// contains filtered or unexported fields
}

func NewCoordinator

func NewCoordinator(t *testing.T, chains ...types.TestChainI) *Coordinator

func (*Coordinator) CreateChannels

func (coord *Coordinator) CreateChannels(ctx context.Context, path *Path)

CreateChannels constructs and executes channel handshake messages in order to create OPEN channels on chainA and chainB. The function expects the channels to be successfully opened otherwise testing will fail.

func (*Coordinator) CreateConnections

func (coord *Coordinator) CreateConnections(ctx context.Context, path *Path)

CreateConnections constructs and executes connection handshake messages in order to create OPEN channels on chainA and chainB. The connection information of for chainA and chainB are returned within a TestConnection struct. The function expects the connections to be successfully opened otherwise testing will fail.

func (Coordinator) GetChain

func (coord Coordinator) GetChain(chainID string) types.TestChainI

func (*Coordinator) Setup

func (coord *Coordinator) Setup(ctx context.Context, path *Path)

Setup constructs a TM client, connection, and channel on both Chains provided. It will fail if any error occurs. The clientID's, TestConnections, and TestChannels are returned for both Chains. The channels created are connected to the ibc-transfer application.

func (*Coordinator) SetupClients

func (coord *Coordinator) SetupClients(ctx context.Context, path *Path)

SetupClients is a helper function to create clients on both Chains. It assumes the caller does not anticipate any errors.

func (*Coordinator) SetupConnections

func (coord *Coordinator) SetupConnections(ctx context.Context, path *Path)

SetupClientConnections is a helper function to create clients and the appropriate connections on both the source and counterparty chain. It assumes the caller does not anticipate any errors.

type Endpoint

type Endpoint struct {
	Chain        ibctestingtypes.TestChainI
	Counterparty *Endpoint
	ClientID     string
	ConnectionID string
	ChannelID    string

	ClientConfig     ClientConfig
	ConnectionConfig *ConnectionConfig
	ChannelConfig    *ChannelConfig
}

Endpoint is a which represents a channel endpoint and its associated client and connections. It contains client, connection, and channel configuration parameters. Endpoint functions will utilize the parameters set in the configuration structs when executing IBC messages.

func NewDefaultEndpoint

func NewDefaultEndpoint(chain ibctestingtypes.TestChainI) *Endpoint

NewDefaultEndpoint constructs a new endpoint using default values. CONTRACT: the counterparty endpoint must be set by the caller.

func NewEndpoint

func NewEndpoint(
	chain *ethereum.TestChain,
	clientConfig ClientConfig,
	connectionConfig *ConnectionConfig,
	channelConfig *ChannelConfig,
) *Endpoint

NewEndpoint constructs a new endpoint without the counterparty. CONTRACT: the counterparty endpoint must be set by the caller.

func (*Endpoint) AcknowledgePacket

func (endpoint *Endpoint) AcknowledgePacket(ctx context.Context, packet exported.PacketI, ack []byte) error

AcknowledgePacket sends a MsgAcknowledgement to the channel associated with the endpoint.

func (*Endpoint) ChanOpenAck

func (endpoint *Endpoint) ChanOpenAck(ctx context.Context) error

ChanOpenAck will construct and execute a MsgChannelOpenAck on the associated endpoint.

func (*Endpoint) ChanOpenConfirm

func (endpoint *Endpoint) ChanOpenConfirm(ctx context.Context) error

ChanOpenConfirm will construct and execute a MsgChannelOpenConfirm on the associated endpoint.

func (*Endpoint) ChanOpenInit

func (endpoint *Endpoint) ChanOpenInit(ctx context.Context) error

ChanOpenInit will construct and execute a MsgChannelOpenInit on the associated endpoint.

func (*Endpoint) ChanOpenTry

func (endpoint *Endpoint) ChanOpenTry(ctx context.Context) error

ChanOpenTry will construct and execute a MsgChannelOpenTry on the associated endpoint.

func (*Endpoint) ConnOpenAck

func (endpoint *Endpoint) ConnOpenAck(ctx context.Context) error

ConnOpenAck will construct and execute a MsgConnectionOpenAck on the associated endpoint.

func (*Endpoint) ConnOpenConfirm

func (endpoint *Endpoint) ConnOpenConfirm(ctx context.Context) error

ConnOpenConfirm will construct and execute a MsgConnectionOpenConfirm on the associated endpoint.

func (*Endpoint) ConnOpenInit

func (endpoint *Endpoint) ConnOpenInit(ctx context.Context) error

ConnOpenInit will construct and execute a MsgConnectionOpenInit on the associated endpoint.

func (*Endpoint) ConnOpenTry

func (endpoint *Endpoint) ConnOpenTry(ctx context.Context) error

ConnOpenTry will construct and execute a MsgConnectionOpenTry on the associated endpoint.

func (*Endpoint) CreateClient

func (endpoint *Endpoint) CreateClient(ctx context.Context) (err error)

CreateClient creates an IBC client on the endpoint. It will update the clientID for the endpoint if the message is successfully executed. NOTE: a solo machine client will be created with an empty diversifier.

func (*Endpoint) QueryAcknowledgePacketProof

func (endpoint *Endpoint) QueryAcknowledgePacketProof(packet exported.PacketI, ack []byte) *ibctestingtypes.Proof

func (*Endpoint) QueryChannelProof

func (endpoint *Endpoint) QueryChannelProof() (*ibctestingtypes.Proof, error)

func (*Endpoint) QueryClientProof

func (endpoint *Endpoint) QueryClientProof() ([]byte, *ibctestingtypes.Proof)

func (*Endpoint) QueryConnectionHandshakeProof

func (endpoint *Endpoint) QueryConnectionHandshakeProof() (
	clientState []byte,
	proofClient *ibctestingtypes.Proof,
	proofConsensus *ibctestingtypes.Proof,
	consensusHeight exported.Height,
	proofConnection *ibctestingtypes.Proof,
)

QueryConnectionHandshakeProof returns all the proofs necessary to execute OpenTry or Open Ack of the connection handshakes. It returns the counterparty client state, proof of the counterparty client state, proof of the counterparty consensus state, the consensus state height, proof of the counterparty connection, and the proof height for all the proofs returned.

func (*Endpoint) QueryConnectionProof

func (endpoint *Endpoint) QueryConnectionProof(height exported.Height) (*ibctestingtypes.Proof, error)

func (*Endpoint) QueryConsensusProof

func (endpoint *Endpoint) QueryConsensusProof(consensusHeight exported.Height, proofHeight exported.Height) *ibctestingtypes.Proof

func (*Endpoint) QueryPacketProof

func (endpoint *Endpoint) QueryPacketProof(packet exported.PacketI) (*ibctestingtypes.Proof, error)

func (*Endpoint) QueryProof

func (endpoint *Endpoint) QueryProof(key []byte) *ibctestingtypes.Proof

QueryProof queries proof associated with this endpoint using the lastest client state height on the counterparty chain.

func (*Endpoint) QueryProofAtHeight

func (endpoint *Endpoint) QueryProofAtHeight(key []byte, height exported.Height) *ibctestingtypes.Proof

QueryProofAtHeight queries proof associated with this endpoint using the proof height providied

func (*Endpoint) RecvPacket

func (endpoint *Endpoint) RecvPacket(ctx context.Context, packet exported.PacketI) error

RecvPacket receives a packet on the associated endpoint. The counterparty client is updated.

func (*Endpoint) UpdateClient

func (endpoint *Endpoint) UpdateClient(ctx context.Context) (err error)

UpdateClient updates the IBC client associated with the endpoint.

type MockConfig

type MockConfig struct {
}

func NewMockConfig

func NewMockConfig() *MockConfig

func (*MockConfig) GetClientType

func (cfg *MockConfig) GetClientType() string

type Path

type Path struct {
	EndpointA *Endpoint
	EndpointB *Endpoint
}

Path contains two endpoints representing two Chains connected over IBC

func NewPath

func NewPath(chainA, chainB types.TestChainI) *Path

NewPath constructs an endpoint for each chain using the default values for the endpoints. Each endpoint is updated to have a pointer to the counterparty endpoint.

type TendermintConfig

type TendermintConfig struct {
	TrustLevel                   ibctmtypes.Fraction
	TrustingPeriod               time.Duration
	UnbondingPeriod              time.Duration
	MaxClockDrift                time.Duration
	AllowUpdateAfterExpiry       bool
	AllowUpdateAfterMisbehaviour bool
}

func NewTendermintConfig

func NewTendermintConfig() *TendermintConfig

func (*TendermintConfig) GetClientType

func (tmcfg *TendermintConfig) GetClientType() string

type TrustedEthereumConfig

type TrustedEthereumConfig struct {
	Diversifier string
	PrivateKey  *secp256k1.PrivKey
}

func NewTrustedEthereumConfig

func NewTrustedEthereumConfig(diversifier string) *TrustedEthereumConfig

func (*TrustedEthereumConfig) GetClientType

func (cfg *TrustedEthereumConfig) GetClientType() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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