ibctesting

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 53 Imported by: 0

README

testing package for ibc

Customized version of cosmos-sdk x/ibc/testing

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxAccounts = 10
View Source
var (
	TimeIncrement = time.Second * 5
)

Functions

func AssertEvents

func AssertEvents(
	suite *suite.Suite,
	expected EventsMap,
	actual []abci.Event,
)

AssertEvents asserts that expected events are present in the actual events. Expected map needs to be a subset of actual events to pass.

func GetChainID

func GetChainID(index int) string

GetChainID returns the chainID used for the provided index.

func GetSendPackets

func GetSendPackets(evts []abci.Event) []channeltypes.Packet

func MakeBlockID

func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) cmttypes.BlockID

MakeBlockID copied unimported test functions from cmttypes to use them here

func ParseAckFromEvents

func ParseAckFromEvents(events []abci.Event) ([]byte, error)

ParseAckFromEvents parses events emitted from a MsgRecvPacket and returns the acknowledgement.

func ParseChannelIDFromEvents

func ParseChannelIDFromEvents(events []abci.Event) (string, error)

ParseChannelIDFromEvents parses events emitted from a MsgChannelOpenInit or MsgChannelOpenTry and returns the channel identifier.

func ParseChannelVersionFromEvents

func ParseChannelVersionFromEvents(events []abci.Event) (string, error)

func ParseClientIDFromEvents

func ParseClientIDFromEvents(events []abci.Event) (string, error)

ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the client identifier.

func ParseConnectionIDFromEvents

func ParseConnectionIDFromEvents(events []abci.Event) (string, error)

ParseConnectionIDFromEvents parses events emitted from a MsgConnectionOpenInit or MsgConnectionOpenTry and returns the connection identifier.

func ParsePacketFromEvent

func ParsePacketFromEvent(evt abci.Event) channeltypes.Packet

func ParsePacketFromEvents

func ParsePacketFromEvents(events []abci.Event) (channeltypes.Packet, error)

ParsePacketFromEvents parses events emitted from a MsgRecvPacket and returns the acknowledgement.

func ParsePortIDFromEvents

func ParsePortIDFromEvents(events []abci.Event) (string, error)

Types

type ChainApp

type ChainApp interface {
	servertypes.ABCI
	AppCodec() codec.Codec
	GetContextForFinalizeBlock(txBytes []byte) sdk.Context
	NewContextLegacy(isCheckTx bool, header cmtproto.Header) sdk.Context
	NewUncachedContext(isCheckTx bool, header cmtproto.Header) sdk.Context
	LastBlockHeight() int64
	LastCommitID() storetypes.CommitID
	GetBaseApp() *baseapp.BaseApp

	TxConfig() client.TxConfig
	GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper
	GetIBCKeeper() *ibckeeper.Keeper
	GetBankKeeper() bankkeeper.Keeper
	GetStakingKeeper() *stakingkeeper.Keeper
	GetAccountKeeper() authkeeper.AccountKeeper
	GetWasmKeeper() wasmkeeper.Keeper
}

ChainApp Abstract chain app definition used for testing

func DefaultWasmAppFactory

func DefaultWasmAppFactory(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) ChainApp

DefaultWasmAppFactory instantiates and sets up the default wasmd app

type ChainAppFactory

type ChainAppFactory func(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasmkeeper.Option, balances ...banktypes.Balance) ChainApp

ChainAppFactory abstract factory method that usually implemented by app.SetupWithGenesisValSet

type Coordinator

type Coordinator struct {
	CurrentTime time.Time
	Chains      map[string]*TestChain
	// contains filtered or unexported fields
}

Coordinator is a testing struct which contains N TestChain's. It handles keeping all chains in sync with regards to time.

func NewCoordinator

func NewCoordinator(t *testing.T, n int, opts ...[]wasmkeeper.Option) *Coordinator

NewCoordinator initializes Coordinator with n default wasm TestChain instances

func NewCoordinatorX

func NewCoordinatorX(t *testing.T, n int, appFactory ChainAppFactory, opts ...[]wasmkeeper.Option) *Coordinator

NewCoordinatorX initializes Coordinator with N TestChain instances using the given app factory

func (*Coordinator) ChanOpenInitOnBothChains

func (coord *Coordinator) ChanOpenInitOnBothChains(path *Path) error

ChanOpenInitOnBothChains initializes a channel on the source chain and counterparty chain with the state INIT using the OpenInit handshake call.

func (*Coordinator) CloseChannel

func (coord *Coordinator) CloseChannel(path *Path)

CloseChannel close channel on both sides

func (*Coordinator) CommitBlock

func (coord *Coordinator) CommitBlock(chains ...*TestChain)

CommitBlock commits a block on the provided indexes and then increments the global time.

CONTRACT: the passed in list of indexes must not contain duplicates

func (*Coordinator) CommitNBlocks

func (coord *Coordinator) CommitNBlocks(chain *TestChain, n uint64)

CommitNBlocks commits n blocks to state and updates the block height by 1 for each commit.

func (*Coordinator) ConnOpenInitOnBothChains

func (coord *Coordinator) ConnOpenInitOnBothChains(path *Path) error

ConnOpenInitOnBothChains initializes a connection on both endpoints with the state INIT using the OpenInit handshake call.

func (*Coordinator) CreateChannels

func (coord *Coordinator) CreateChannels(path *Path)

CreateChannel 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(path *Path)

CreateConnection 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) CreateMockChannels

func (coord *Coordinator) CreateMockChannels(path *Path)

CreateMockChannels constructs and executes channel handshake messages to create OPEN channels that use a mock application module that returns nil on all callbacks. This function is expects the channels to be successfully opened otherwise testing will fail.

func (*Coordinator) CreateTransferChannels

func (coord *Coordinator) CreateTransferChannels(path *Path)

CreateTransferChannels constructs and executes channel handshake messages to create OPEN ibc-transfer channels on chainA and chainB. The function expects the channels to be successfully opened otherwise testing will fail.

func (*Coordinator) GetChain

func (coord *Coordinator) GetChain(chainID string) *TestChain

GetChain returns the TestChain using the given chainID and returns an error if it does not exist.

func (*Coordinator) IncrementTime

func (coord *Coordinator) IncrementTime()

IncrementTime iterates through all the TestChain's and increments their current header time by 5 seconds.

CONTRACT: this function must be called after every Commit on any TestChain.

func (*Coordinator) IncrementTimeBy

func (coord *Coordinator) IncrementTimeBy(increment time.Duration)

IncrementTimeBy iterates through all the TestChain's and increments their current header time by specified time.

func (*Coordinator) RelayAndAckPendingPackets

func (coord *Coordinator) RelayAndAckPendingPackets(path *Path) error

RelayAndAckPendingPackets sends pending packages from path.EndpointA to the counterparty chain and acks

func (*Coordinator) Setup

func (coord *Coordinator) Setup(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(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(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.

func (*Coordinator) TimeoutPendingPackets

func (coord *Coordinator) TimeoutPendingPackets(path *Path) error

TimeoutPendingPackets returns the package to source chain to let the IBC app revert any operation. from A to B

func (*Coordinator) UpdateTime

func (coord *Coordinator) UpdateTime()

UpdateTime updates all clocks for the TestChains to the current global time.

func (*Coordinator) UpdateTimeForChain

func (coord *Coordinator) UpdateTimeForChain(chain *TestChain)

UpdateTimeForChain updates the clock for a specific chain.

type Endpoint

type Endpoint struct {
	Chain        *TestChain
	Counterparty *Endpoint
	ClientID     string
	ConnectionID string
	ChannelID    string

	ClientConfig     ibctesting.ClientConfig
	ConnectionConfig *ibctesting.ConnectionConfig
	ChannelConfig    *ibctesting.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 *TestChain) *Endpoint

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

func NewEndpoint

func NewEndpoint(
	chain *TestChain, clientConfig ibctesting.ClientConfig,
	connectionConfig *ibctesting.ConnectionConfig, channelConfig *ibctesting.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(packet channeltypes.Packet, ack []byte) error

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

func (*Endpoint) ChanCloseConfirm

func (endpoint *Endpoint) ChanCloseConfirm() error

ChanCloseConfirm will construct and execute a NewMsgChannelCloseConfirm on the associated endpoint.

func (*Endpoint) ChanCloseInit

func (endpoint *Endpoint) ChanCloseInit() error

ChanCloseInit will construct and execute a MsgChannelCloseInit on the associated endpoint.

NOTE: does not work with ibc-transfer module

func (*Endpoint) ChanOpenAck

func (endpoint *Endpoint) ChanOpenAck() error

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

func (*Endpoint) ChanOpenConfirm

func (endpoint *Endpoint) ChanOpenConfirm() error

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

func (*Endpoint) ChanOpenInit

func (endpoint *Endpoint) ChanOpenInit() error

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

func (*Endpoint) ChanOpenTry

func (endpoint *Endpoint) ChanOpenTry() error

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

func (*Endpoint) ConnOpenAck

func (endpoint *Endpoint) ConnOpenAck() error

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

func (*Endpoint) ConnOpenConfirm

func (endpoint *Endpoint) ConnOpenConfirm() error

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

func (*Endpoint) ConnOpenInit

func (endpoint *Endpoint) ConnOpenInit() error

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

func (*Endpoint) ConnOpenTry

func (endpoint *Endpoint) ConnOpenTry() error

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

func (*Endpoint) CreateClient

func (endpoint *Endpoint) CreateClient() (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) GetChannel

func (endpoint *Endpoint) GetChannel() channeltypes.Channel

GetChannel retrieves an IBC Channel for the endpoint. The channel is expected to exist otherwise testing will fail.

func (*Endpoint) GetClientState

func (endpoint *Endpoint) GetClientState() exported.ClientState

GetClientState retrieves the Client State for this endpoint. The client state is expected to exist otherwise testing will fail.

func (*Endpoint) GetConnection

func (endpoint *Endpoint) GetConnection() connectiontypes.ConnectionEnd

GetConnection retrieves an IBC Connection for the endpoint. The connection is expected to exist otherwise testing will fail.

func (*Endpoint) GetConsensusState

func (endpoint *Endpoint) GetConsensusState(height exported.Height) exported.ConsensusState

GetConsensusState retrieves the Consensus State for this endpoint at the provided height. The consensus state is expected to exist otherwise testing will fail.

func (*Endpoint) QueryClientStateProof

func (endpoint *Endpoint) QueryClientStateProof() (exported.ClientState, []byte)

QueryClientStateProof performs and abci query for a client stat associated with this endpoint and returns the ClientState along with the proof.

func (*Endpoint) QueryConnectionHandshakeProof

func (endpoint *Endpoint) QueryConnectionHandshakeProof() (
	clientState exported.ClientState, proofClient,
	proofConsensus []byte, consensusHeight clienttypes.Height,
	proofConnection []byte, proofHeight clienttypes.Height,
)

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

func (endpoint *Endpoint) QueryProof(key []byte) ([]byte, clienttypes.Height)

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 uint64) ([]byte, clienttypes.Height)

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

func (*Endpoint) RecvPacket

func (endpoint *Endpoint) RecvPacket(packet channeltypes.Packet) error

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

func (*Endpoint) RecvPacketWithResult

func (endpoint *Endpoint) RecvPacketWithResult(packet channeltypes.Packet) (*abci.ExecTxResult, error)

RecvPacketWithResult receives a packet on the associated endpoint and the result of the transaction is returned. The counterparty client is updated.

func (*Endpoint) SendPacket

func (endpoint *Endpoint) SendPacket(
	timeoutHeight clienttypes.Height,
	timeoutTimestamp uint64,
	data []byte,
) (uint64, error)

SendPacket sends a packet through the channel keeper using the associated endpoint The counterparty client is updated so proofs can be sent to the counterparty chain. The packet sequence generated for the packet to be sent is returned. An error is returned if one occurs.

func (*Endpoint) SetChannel

func (endpoint *Endpoint) SetChannel(channel channeltypes.Channel)

SetChannel sets the channel for this endpoint.

func (*Endpoint) SetChannelClosed

func (endpoint *Endpoint) SetChannelClosed() error

SetChannelClosed sets a channel state to CLOSED.

func (*Endpoint) SetClientState

func (endpoint *Endpoint) SetClientState(clientState exported.ClientState)

SetClientState sets the client state for this endpoint.

func (*Endpoint) SetConnection

func (endpoint *Endpoint) SetConnection(connection connectiontypes.ConnectionEnd)

SetConnection sets the connection for this endpoint.

func (*Endpoint) SetConsensusState

func (endpoint *Endpoint) SetConsensusState(consensusState exported.ConsensusState, height exported.Height)

SetConsensusState sets the consensus state for this endpoint.

func (*Endpoint) TimeoutOnClose

func (endpoint *Endpoint) TimeoutOnClose(packet channeltypes.Packet) error

TimeoutOnClose sends a MsgTimeoutOnClose to the channel associated with the endpoint.

func (*Endpoint) TimeoutPacket

func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error

TimeoutPacket sends a MsgTimeout to the channel associated with the endpoint.

func (*Endpoint) UpdateClient

func (endpoint *Endpoint) UpdateClient() (err error)

UpdateClient updates the IBC client associated with the endpoint.

func (*Endpoint) UpgradeChain

func (endpoint *Endpoint) UpgradeChain() error

UpgradeChain will upgrade a chain's chainID to the next revision number. It will also update the counterparty client. TODO: implement actual upgrade chain functionality via scheduling an upgrade and upgrading the client via MsgUpgradeClient see reference https://github.com/cosmos/ibc-go/pull/1169

func (*Endpoint) WriteAcknowledgement

func (endpoint *Endpoint) WriteAcknowledgement(ack exported.Acknowledgement, packet exported.PacketI) error

WriteAcknowledgement writes an acknowledgement on the channel associated with the endpoint. The counterparty client is updated.

type EventsMap

type EventsMap map[string]map[string]string

type PacketAck

type PacketAck struct {
	Packet channeltypes.Packet
	Ack    []byte
}

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 *TestChain) *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.

func (*Path) Invert

func (path *Path) Invert() *Path

func (*Path) RelayPacket

func (path *Path) RelayPacket(packet channeltypes.Packet, _ []byte) error

RelayPacket attempts to relay the packet first on EndpointA and then on EndpointB if EndpointA does not contain a packet commitment for that packet. An error is returned if a relay step fails or the packet commitment does not exist on either endpoint.

func (*Path) SendMsg

func (path *Path) SendMsg(msgs ...sdk.Msg) error

SendMsg delivers the provided messages to the chain. The counterparty client is updated with the new source consensus state.

func (*Path) SetChannelOrdered

func (path *Path) SetChannelOrdered()

SetChannelOrdered sets the channel order for both endpoints to ORDERED.

type SenderAccount

type SenderAccount struct {
	SenderPrivKey cryptotypes.PrivKey
	SenderAccount sdk.AccountI
}

type TestChain

type TestChain struct {
	Coordinator   *Coordinator
	App           ChainApp
	ChainID       string
	LastHeader    *ibctm.Header   // header for last block height committed
	CurrentHeader cmtproto.Header // header for current block height
	QueryServer   types.QueryServer
	TxConfig      client.TxConfig
	Codec         codec.Codec

	Vals     *cmttypes.ValidatorSet
	NextVals *cmttypes.ValidatorSet

	// Signers is a map from validator address to the PrivValidator
	// The map is converted into an array that is the same order as the validators right before signing commit
	// This ensures that signers will always be in correct order even as validator powers change.
	// If a test adds a new validator after chain creation, then the signer map must be updated to include
	// the new PrivValidator entry.
	Signers map[string]cmttypes.PrivValidator

	// autogenerated sender private key
	SenderPrivKey  cryptotypes.PrivKey
	SenderAccount  sdk.AccountI
	SenderAccounts []SenderAccount

	PendingSendPackets []channeltypes.Packet
	DefaultMsgFees     sdk.Coins
	// contains filtered or unexported fields
}

TestChain is a testing struct that wraps a simapp with the last CMT header, the current ABCI header and the validators of the TestChain. It also contains a field called ChainID. This is the clientID that *other* chains use to refer to this TestChain. The SenderAccount is used for delivering transactions through the application state. NOTE: the actual application uses an empty chain-id for ease of testing.

func NewDefaultTestChain

func NewDefaultTestChain(t *testing.T, coord *Coordinator, chainID string, opts ...wasmkeeper.Option) *TestChain

NewDefaultTestChain initializes a new test chain with a default of 4 validators Use this function if the tests do not need custom control over the validator set

func NewTestChain

func NewTestChain(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, chainID string, opts ...wasmkeeper.Option) *TestChain

NewTestChain initializes a new test chain with a default of 4 validators Use this function if the tests do not need custom control over the validator set

func NewTestChainWithValSet

func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appFactory ChainAppFactory, chainID string, valSet *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator, opts ...wasmkeeper.Option) *TestChain

NewTestChainWithValSet initializes a new TestChain instance with the given validator set and signer array. It also initializes 10 Sender accounts with a balance of 10000000000000000000 coins of bond denom to use for tests.

The first block height is committed to state in order to allow for client creations on counterparty chains. The TestChain will return with a block height starting at 2.

Time management is handled by the Coordinator in order to ensure synchrony between chains. Each update of any chain increments the block header time for all chains by 5 seconds.

NOTE: to use a custom sender privkey and account for testing purposes, replace and modify this constructor function.

CONTRACT: Validator array must be provided in the order expected by Tendermint. i.e. sorted first by power and then lexicographically by address.

func (*TestChain) AllBalances

func (chain *TestChain) AllBalances(acc sdk.AccAddress) sdk.Coins

func (*TestChain) Balance

func (chain *TestChain) Balance(acc sdk.AccAddress, denom string) sdk.Coin

func (*TestChain) CaptureIBCEvents

func (chain *TestChain) CaptureIBCEvents(r *abci.ExecTxResult)

func (*TestChain) ConstructUpdateCMTClientHeaderWithTrustedHeight

func (chain *TestChain) ConstructUpdateCMTClientHeaderWithTrustedHeight(counterparty *TestChain, clientID string, trustedHeight clienttypes.Height) (*ibctm.Header, error)

ConstructUpdateCMTClientHeaderWithTrustedHeight will construct a valid 07-tendermint Header to update the light client on the source chain.

func (*TestChain) ConstructUpdateTMClientHeader

func (chain *TestChain) ConstructUpdateTMClientHeader(counterparty *TestChain, clientID string) (*ibctm.Header, error)

ConstructUpdateTMClientHeader will construct a valid 07-tendermint Header to update the light client on the source chain.

func (*TestChain) ContractInfo

func (chain *TestChain) ContractInfo(contractAddr sdk.AccAddress) *types.ContractInfo

ContractInfo is a helper function to returns the ContractInfo for the given contract address

func (*TestChain) CreateChannelCapability

func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID, channelID string)

CreateChannelCapability binds and claims a capability for the given portID and channelID if it does not already exist. This function will fail testing on any resulting error. The scoped keeper passed in will claim the new capability.

func (*TestChain) CreateCmtClientHeader

func (chain *TestChain) CreateCmtClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, cmtValSet, nextVals, cmtTrustedVals *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator) *ibctm.Header

CreateCmtClientHeader creates a CMT header to update the CMT client. Args are passed in to allow caller flexibility to use params that differ from the chain.

func (*TestChain) CreatePortCapability

func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID string)

CreatePortCapability binds and claims a capability for the given portID if it does not already exist. This function will fail testing on any resulting error. NOTE: only creation of a capability for a transfer or mock port is supported Other applications must bind to the port in InitGenesis or modify this code.

func (*TestChain) CurrentCmtClientHeader

func (chain *TestChain) CurrentCmtClientHeader() *ibctm.Header

CurrentCmtClientHeader creates a CMT header using the current header parameters on the chain. The trusted fields in the header are set to nil.

func (*TestChain) ExpireClient

func (chain *TestChain) ExpireClient(amount time.Duration)

ExpireClient fast forwards the chain's block time by the provided amount of time which will expire any clients with a trusting period less than or equal to this amount of time.

func (*TestChain) Fund

func (chain *TestChain) Fund(addr sdk.AccAddress, amount math.Int)

Fund an address with the given amount in default denom

func (*TestChain) GetAcknowledgement

func (chain *TestChain) GetAcknowledgement(packet exported.PacketI) []byte

GetAcknowledgement retrieves an acknowledgement for the provided packet. If the acknowledgement does not exist then testing will fail.

func (*TestChain) GetChannelCapability

func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability

GetChannelCapability returns the channel capability for the given portID and channelID. The capability must exist, otherwise testing will fail.

func (*TestChain) GetClientState

func (chain *TestChain) GetClientState(clientID string) exported.ClientState

GetClientState retrieves the client state for the provided clientID. The client is expected to exist otherwise testing will fail.

func (*TestChain) GetConsensusState

func (chain *TestChain) GetConsensusState(clientID string, height exported.Height) (exported.ConsensusState, bool)

GetConsensusState retrieves the consensus state for the provided clientID and height. It will return a success boolean depending on if consensus state exists or not.

func (*TestChain) GetContext

func (chain *TestChain) GetContext() sdk.Context

GetContext returns the current context for the application.

func (*TestChain) GetPortCapability

func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability

GetPortCapability returns the port capability for the given portID. The capability must exist, otherwise testing will fail.

func (*TestChain) GetPrefix

func (chain *TestChain) GetPrefix() commitmenttypes.MerklePrefix

GetPrefix returns the prefix for used by a chain in connection creation

func (*TestChain) GetTimeoutHeight

func (chain *TestChain) GetTimeoutHeight() clienttypes.Height

GetTimeoutHeight is a convenience function which returns a IBC packet timeout height to be used for testing. It returns the current IBC height + 100 blocks

func (*TestChain) GetValsAtHeight

func (chain *TestChain) GetValsAtHeight(height int64) (*cmttypes.ValidatorSet, bool)

GetValsAtHeight will return the validator set of the chain at a given height. It will return a success boolean depending on if the validator set exists or not at that height.

func (*TestChain) InstantiateContract

func (chain *TestChain) InstantiateContract(codeID uint64, initMsg []byte) sdk.AccAddress

func (*TestChain) NextBlock

func (chain *TestChain) NextBlock()

NextBlock sets the last header to the current header and increments the current header to be at the next block height. It does not update the time as that is handled by the Coordinator. It will call FinalizeBlock and Commit and apply the validator set changes to the next validators of the next block being created. This follows the CometBFT protocol of applying valset changes returned on block `n` to the validators of block `n+2`. It updates the current header with the new block created before returning.

func (*TestChain) QueryConsensusStateProof

func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clienttypes.Height)

QueryConsensusStateProof performs an abci query for a consensus state stored on the given clientID. The proof and consensusHeight are returned.

func (*TestChain) QueryProof

func (chain *TestChain) QueryProof(key []byte) ([]byte, clienttypes.Height)

QueryProof performs an abci query with the given key and returns the proto encoded merkle proof for the query and the height at which the proof will succeed on a tendermint verifier.

func (*TestChain) QueryProofAtHeight

func (chain *TestChain) QueryProofAtHeight(key []byte, height int64) ([]byte, clienttypes.Height)

QueryProofAtHeight performs an abci query with the given key and returns the proto encoded merkle proof for the query and the height at which the proof will succeed on a tendermint verifier. Only the IBC store is supported

func (*TestChain) QueryProofForStore

func (chain *TestChain) QueryProofForStore(storeKey string, key []byte, height int64) ([]byte, clienttypes.Height)

QueryProofForStore performs an abci query with the given key and returns the proto encoded merkle proof for the query and the height at which the proof will succeed on a tendermint verifier.

func (*TestChain) QueryUpgradeProof

func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, clienttypes.Height)

QueryUpgradeProof performs an abci query with the given key and returns the proto encoded merkle proof for the query and the height at which the proof will succeed on a tendermint verifier.

func (*TestChain) RawQuery

func (chain *TestChain) RawQuery(contractAddr string, queryData []byte) ([]byte, error)

func (*TestChain) SeedNewContractInstance

func (chain *TestChain) SeedNewContractInstance() sdk.AccAddress

SeedNewContractInstance stores some wasm code and instantiates a new contract on this chain. This method can be called to prepare the store with some valid CodeInfo and ContractInfo. The returned Address is the contract address for this instance. Test should make use of this data and/or use NewIBCContractMockWasmEngine for using a contract mock in Go.

func (*TestChain) SendMsgs

func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error)

SendMsgs delivers a transaction through the application. It updates the senders sequence number and updates the TestChain's headers. It returns the result and error if one occurred.

func (*TestChain) SendNonDefaultSenderMsgs

func (chain *TestChain) SendNonDefaultSenderMsgs(senderPrivKey cryptotypes.PrivKey, msgs ...sdk.Msg) (*abci.ExecTxResult, error)

SendNonDefaultSenderMsgs is the same as SendMsgs but with a custom signer/account

func (*TestChain) SmartQuery

func (chain *TestChain) SmartQuery(contractAddr string, queryMsg, response interface{}) error

SmartQuery This will serialize the query message and submit it to the contract. The response is parsed into the provided interface. Usage: SmartQuery(addr, QueryMsg{Foo: 1}, &response)

func (*TestChain) StoreCode

func (chain *TestChain) StoreCode(byteCode []byte) types.MsgStoreCodeResponse

func (*TestChain) StoreCodeFile

func (chain *TestChain) StoreCodeFile(filename string) types.MsgStoreCodeResponse

func (*TestChain) UnwrapExecTXResult

func (chain *TestChain) UnwrapExecTXResult(r *abci.ExecTxResult, target proto.Message)

UnwrapExecTXResult is a helper to unpack execution result from proto any type

Jump to

Keyboard shortcuts

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