Documentation ¶
Overview ¶
This file contains the variables, constants, and default values used in the testing package and commonly defined in tests.
Index ¶
- Constants
- Variables
- func ApplyValSetChanges(tb testing.TB, valSet *cmttypes.ValidatorSet, ...) *cmttypes.ValidatorSet
- func AssertEvents(suite *testifysuite.Suite, expected []abci.Event, actual []abci.Event)
- func CommitHeader(proposedHeader cmttypes.Header, valSet *cmttypes.ValidatorSet, ...) (*cmtproto.SignedHeader, error)
- func GenerateKeys(t *testing.T, n uint64) ([]cryptotypes.PrivKey, []cryptotypes.PubKey, cryptotypes.PubKey)
- func GenerateString(length uint) string
- func GetChainID(index int) string
- func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) cmttypes.BlockID
- func ParseAckFromEvents(events []abci.Event) ([]byte, error)
- func ParseChannelIDFromEvents(events []abci.Event) (string, error)
- func ParseClientIDFromEvents(events []abci.Event) (string, error)
- func ParseConnectionIDFromEvents(events []abci.Event) (string, error)
- func ParsePacketFromEvents(events []abci.Event) (channeltypes.Packet, error)
- func ParsePacketSequenceFromEvents(events []abci.Event) (uint64, error)
- func ParsePacketsFromEvents(eventType string, events []abci.Event) ([]channeltypes.Packet, error)
- func ParseProposalIDFromEvents(events []abci.Event) (uint64, error)
- func ParseRecvPacketFromEvents(events []abci.Event) (channeltypes.Packet, error)
- func UnmarshalMsgResponses(cdc codec.Codec, data []byte, msgs ...codec.ProtoMarshaler) error
- func VoteAndCheckProposalStatus(endpoint *Endpoint, proposalID uint64) error
- type ChannelConfig
- type ClientConfig
- type ConnectionConfig
- type Coordinator
- func (coord *Coordinator) CommitBlock(chains ...*TestChain)
- func (coord *Coordinator) CommitNBlocks(chain *TestChain, n uint64)
- func (*Coordinator) CreateChannels(path *Path)
- func (*Coordinator) CreateConnections(path *Path)
- func (*Coordinator) CreateMockChannels(path *Path)
- func (*Coordinator) CreateTransferChannels(path *Path)
- func (coord *Coordinator) GetChain(chainID string) *TestChain
- func (coord *Coordinator) IncrementTime()
- func (coord *Coordinator) IncrementTimeBy(increment time.Duration)
- func (*Coordinator) Setup(path *Path)
- func (*Coordinator) SetupClients(path *Path)
- func (*Coordinator) SetupConnections(path *Path)
- func (coord *Coordinator) UpdateTime()
- func (coord *Coordinator) UpdateTimeForChain(chain *TestChain)
- type Endpoint
- func (endpoint *Endpoint) AcknowledgePacket(packet channeltypes.Packet, ack []byte) error
- func (endpoint *Endpoint) AcknowledgePacketWithResult(packet channeltypes.Packet, ack []byte) (*abci.ExecTxResult, error)
- func (endpoint *Endpoint) ChanCloseInit() error
- func (endpoint *Endpoint) ChanOpenAck() error
- func (endpoint *Endpoint) ChanOpenConfirm() error
- func (endpoint *Endpoint) ChanOpenInit() error
- func (endpoint *Endpoint) ChanOpenTry() error
- func (endpoint *Endpoint) ChanUpgradeAck() error
- func (endpoint *Endpoint) ChanUpgradeCancel() error
- func (endpoint *Endpoint) ChanUpgradeConfirm() error
- func (endpoint *Endpoint) ChanUpgradeInit() error
- func (endpoint *Endpoint) ChanUpgradeOpen() error
- func (endpoint *Endpoint) ChanUpgradeTimeout() error
- func (endpoint *Endpoint) ChanUpgradeTry() error
- func (endpoint *Endpoint) ConnOpenAck() error
- func (endpoint *Endpoint) ConnOpenConfirm() error
- func (endpoint *Endpoint) ConnOpenInit() error
- func (endpoint *Endpoint) ConnOpenTry() error
- func (endpoint *Endpoint) CreateClient() (err error)
- func (endpoint *Endpoint) GetChannel() channeltypes.Channel
- func (endpoint *Endpoint) GetChannelUpgrade() channeltypes.Upgrade
- func (endpoint *Endpoint) GetClientLatestHeight() exported.Height
- func (endpoint *Endpoint) GetClientState() exported.ClientState
- func (endpoint *Endpoint) GetConnection() connectiontypes.ConnectionEnd
- func (endpoint *Endpoint) GetConsensusState(height exported.Height) exported.ConsensusState
- func (endpoint *Endpoint) GetProposedUpgrade() channeltypes.Upgrade
- func (endpoint *Endpoint) IncrementNextChannelSequence()
- func (endpoint *Endpoint) QueryChannelUpgradeProof() ([]byte, []byte, clienttypes.Height)
- func (endpoint *Endpoint) QueryClientStateProof() (exported.ClientState, []byte)
- func (endpoint *Endpoint) QueryConnectionHandshakeProof() (clientState exported.ClientState, clientProof, consensusProof []byte, ...)
- func (endpoint *Endpoint) QueryProof(key []byte) ([]byte, clienttypes.Height)
- func (endpoint *Endpoint) QueryProofAtHeight(key []byte, height uint64) ([]byte, clienttypes.Height)
- func (endpoint *Endpoint) RecvPacket(packet channeltypes.Packet) error
- func (endpoint *Endpoint) RecvPacketWithResult(packet channeltypes.Packet) (*abci.ExecTxResult, error)
- func (endpoint *Endpoint) SendPacket(timeoutHeight clienttypes.Height, timeoutTimestamp uint64, data []byte) (uint64, error)
- func (endpoint *Endpoint) SetChannel(channel channeltypes.Channel)
- func (endpoint *Endpoint) SetChannelCounterpartyUpgrade(upgrade channeltypes.Upgrade)
- func (endpoint *Endpoint) SetChannelState(state channeltypes.State) errordeprecated
- func (endpoint *Endpoint) SetChannelUpgrade(upgrade channeltypes.Upgrade)
- func (endpoint *Endpoint) SetClientState(clientState exported.ClientState)
- func (endpoint *Endpoint) SetConnection(connection connectiontypes.ConnectionEnd)
- func (endpoint *Endpoint) SetConsensusState(consensusState exported.ConsensusState, height exported.Height)
- func (endpoint *Endpoint) TimeoutOnClose(packet channeltypes.Packet) error
- func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error
- func (endpoint *Endpoint) UpdateChannel(updater func(channel *channeltypes.Channel))
- func (endpoint *Endpoint) UpdateClient() (err error)
- func (endpoint *Endpoint) UpdateConnection(updater func(connection *connectiontypes.ConnectionEnd))
- func (endpoint *Endpoint) UpgradeChain() error
- func (endpoint *Endpoint) WriteAcknowledgement(ack exported.Acknowledgement, packet exported.PacketI) error
- type Path
- func (path *Path) CreateChannels()
- func (path *Path) CreateConnections()
- func (path *Path) DisableUniqueChannelIDs() *Path
- func (path *Path) RelayPacket(packet channeltypes.Packet) error
- func (path *Path) RelayPacketWithResults(packet channeltypes.Packet) (*abci.ExecTxResult, []byte, error)
- func (path *Path) SetChannelOrdered()
- func (path *Path) Setup()
- func (path *Path) SetupClients()
- func (path *Path) SetupConnections()
- type SenderAccount
- type Solomachine
- func (solo *Solomachine) AcknowledgePacket(chain *TestChain, packet channeltypes.Packet)
- func (solo *Solomachine) ChanCloseConfirm(chain *TestChain, portID, channelID string)
- func (solo *Solomachine) ChanOpenAck(chain *TestChain, channelID string)
- func (solo *Solomachine) ChanOpenInit(chain *TestChain, connectionID string) string
- func (solo *Solomachine) ClientState() *solomachine.ClientState
- func (solo *Solomachine) ConnOpenAck(chain *TestChain, clientID, connectionID string)
- func (solo *Solomachine) ConnOpenInit(chain *TestChain, clientID string) string
- func (solo *Solomachine) ConsensusState() *solomachine.ConsensusState
- func (solo *Solomachine) CreateClient(chain *TestChain) string
- func (solo *Solomachine) CreateHeader(newDiversifier string) *solomachine.Header
- func (solo *Solomachine) CreateMisbehaviour() *solomachine.Misbehaviour
- func (solo *Solomachine) GenerateAcknowledgementProof(packet channeltypes.Packet) []byte
- func (solo *Solomachine) GenerateChanClosedProof(portID, version, counterpartyChannelID string) []byte
- func (solo *Solomachine) GenerateChanOpenTryProof(portID, version, counterpartyChannelID string) []byte
- func (solo *Solomachine) GenerateClientStateProof(clientState exported.ClientState) []byte
- func (solo *Solomachine) GenerateCommitmentProof(packet channeltypes.Packet) []byte
- func (solo *Solomachine) GenerateConnOpenTryProof(counterpartyClientID, counterpartyConnectionID string) []byte
- func (solo *Solomachine) GenerateConsensusStateProof(consensusState exported.ConsensusState, consensusHeight exported.Height) []byte
- func (solo *Solomachine) GenerateProof(signBytes *solomachine.SignBytes) []byte
- func (solo *Solomachine) GenerateReceiptAbsenceProof(packet channeltypes.Packet) []byte
- func (solo *Solomachine) GenerateSignature(signBytes []byte) []byte
- func (solo *Solomachine) GetChannelStatePath(portID, channelID string) commitmenttypesv2.MerklePath
- func (solo *Solomachine) GetClientStatePath(counterpartyClientIdentifier string) commitmenttypesv2.MerklePath
- func (solo *Solomachine) GetConnectionStatePath(connID string) commitmenttypesv2.MerklePath
- func (solo *Solomachine) GetConsensusStatePath(counterpartyClientIdentifier string, consensusHeight exported.Height) commitmenttypesv2.MerklePath
- func (solo *Solomachine) GetHeight() exported.Height
- func (solo *Solomachine) GetNextSequenceRecvPath(portID, channelID string) commitmenttypesv2.MerklePath
- func (solo *Solomachine) GetPacketAcknowledgementPath(portID, channelID string, sequence uint64) commitmenttypesv2.MerklePath
- func (solo *Solomachine) GetPacketCommitmentPath(portID, channelID string, sequence uint64) commitmenttypesv2.MerklePath
- func (solo *Solomachine) GetPacketReceiptPath(portID, channelID string, sequence uint64) commitmenttypesv2.MerklePath
- func (solo *Solomachine) RecvPacket(chain *TestChain, packet channeltypes.Packet)
- func (solo *Solomachine) SendTransfer(chain *TestChain, portID, channelID string, ...) channeltypes.Packet
- func (solo *Solomachine) TimeoutPacket(chain *TestChain, packet channeltypes.Packet)
- func (solo *Solomachine) TimeoutPacketOnClose(chain *TestChain, packet channeltypes.Packet, channelID string)
- func (solo *Solomachine) UpdateClient(chain *TestChain, clientID string)
- type TendermintConfig
- type TestChain
- func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID, channelID string)
- func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID string)
- func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, ...) *ibctm.Header
- func (chain *TestChain) CurrentTMClientHeader() *ibctm.Header
- func (chain *TestChain) DeleteKey(key []byte)
- func (chain *TestChain) ExpireClient(amount time.Duration)
- func (chain *TestChain) GetAcknowledgement(packet channeltypes.Packet) []byte
- func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability
- func (chain *TestChain) GetClientLatestHeight(clientID string) exported.Height
- func (chain *TestChain) GetClientState(clientID string) exported.ClientState
- func (chain *TestChain) GetConsensusState(clientID string, height exported.Height) (exported.ConsensusState, bool)
- func (chain *TestChain) GetContext() sdk.Context
- func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability
- func (chain *TestChain) GetPrefix() commitmenttypes.MerklePrefix
- func (chain *TestChain) GetSimApp() *simapp.SimApp
- func (chain *TestChain) GetTimeoutHeight() clienttypes.Height
- func (chain *TestChain) GetTimeoutTimestamp() uint64
- func (chain *TestChain) GetTrustedValidators(trustedHeight int64) (*cmttypes.ValidatorSet, error)
- func (chain *TestChain) IBCClientHeader(header *ibctm.Header, trustedHeight clienttypes.Height) (*ibctm.Header, error)
- func (chain *TestChain) NextBlock()
- func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clienttypes.Height)
- func (chain *TestChain) QueryProof(key []byte) ([]byte, clienttypes.Height)
- func (chain *TestChain) QueryProofAtHeight(key []byte, height int64) ([]byte, clienttypes.Height)
- func (chain *TestChain) QueryProofForStore(storeKey string, key []byte, height int64) ([]byte, clienttypes.Height)
- func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, clienttypes.Height)
- func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error)
- type TestingApp
Constants ¶
const ( FirstClientID = "07-tendermint-0" SecondClientID = "07-tendermint-1" FirstChannelID = "channel-0" FirstConnectionID = "connection-0" // Default params constants used to create a TM client TrustingPeriod time.Duration = time.Hour * 24 * 7 * 2 UnbondingPeriod time.Duration = time.Hour * 24 * 7 * 3 MaxClockDrift time.Duration = time.Second * 10 DefaultDelayPeriod uint64 = 0 DefaultChannelVersion = mock.Version InvalidID = "IDisInvalid" // Application Ports TransferPort = ibctransfertypes.ModuleName MockPort = mock.ModuleName MockFeePort = simapp.MockFeePort // used for testing proposals Title = "title" Description = "description" )
Variables ¶
var ( ChainIDPrefix = "testchain" // to disable revision format, set ChainIDSuffix to "" ChainIDSuffix = "-1" TimeIncrement = time.Second * 5 )
var ( DefaultOpenInitVersion *connectiontypes.Version // DefaultTrustLevel sets params variables used to create a TM client DefaultTrustLevel = ibctm.DefaultTrustLevel DefaultTimeoutTimestampDelta = uint64(time.Hour.Nanoseconds()) TestAccAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" TestCoin = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) SecondaryDenom = "ufoo" SecondaryTestCoin = sdk.NewCoin(SecondaryDenom, sdkmath.NewInt(100)) TestCoins = sdk.NewCoins(TestCoin, SecondaryTestCoin) UpgradePath = []string{"upgrade", "upgradedIBCState"} ConnectionVersion = connectiontypes.GetCompatibleVersions()[0] MockAcknowledgement = mock.MockAcknowledgement.Acknowledgement() MockPacketData = mock.MockPacketData MockFailPacketData = mock.MockFailPacketData MockRecvCanaryCapabilityName = mock.MockRecvCanaryCapabilityName EmptyForwardingPacketData = ibctransfertypes.ForwardingPacketData{} )
var DefaultSolomachineClientID = "06-solomachine-0"
DefaultSolomachineClientID is the default solo machine client id used for testing
var DefaultTestingAppInit = SetupTestingApp
var MaxAccounts = 10
Functions ¶
func ApplyValSetChanges ¶
func ApplyValSetChanges(tb testing.TB, valSet *cmttypes.ValidatorSet, valUpdates []abci.ValidatorUpdate) *cmttypes.ValidatorSet
ApplyValSetChanges takes in cmttypes.ValidatorSet and []abci.ValidatorUpdate and will return a new cmttypes.ValidatorSet which has the provided validator updates applied to the provided validator set.
func AssertEvents ¶
AssertEvents asserts that expected events are present in the actual events.
func CommitHeader ¶
func CommitHeader(proposedHeader cmttypes.Header, valSet *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator) (*cmtproto.SignedHeader, error)
CommitHeader takes in a proposed header and returns a signed cometbft header. The signers passed in must match the validator set provided. The signers will be used to sign over the proposed header.
func GenerateKeys ¶
func GenerateKeys(t *testing.T, n uint64) ([]cryptotypes.PrivKey, []cryptotypes.PubKey, cryptotypes.PubKey)
GenerateKeys generates a new set of secp256k1 private keys and public keys. If the number of keys is greater than one then the public key returned represents a multisig public key. The private keys are used for signing, the public keys are used for generating the public key and the public key is used for solo machine verification. The usage of secp256k1 is entirely arbitrary. The key type can be swapped for any key type supported by the PublicKey interface, if needed. The same is true for the amino based Multisignature public key.
func GenerateString ¶
GenerateString generates a random string of the given length in bytes
func GetChainID ¶
GetChainID returns the chainID used for the provided index.
func MakeBlockID ¶
MakeBlockID copied unimported test functions from cmttypes to use them here
func ParseAckFromEvents ¶
ParseAckFromEvents parses events emitted from a MsgRecvPacket and returns the acknowledgement.
func ParseChannelIDFromEvents ¶
ParseChannelIDFromEvents parses events emitted from a MsgChannelOpenInit or MsgChannelOpenTry and returns the channel identifier.
func ParseClientIDFromEvents ¶
ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the client identifier.
func ParseConnectionIDFromEvents ¶
ParseConnectionIDFromEvents parses events emitted from a MsgConnectionOpenInit or MsgConnectionOpenTry and returns the connection identifier.
func ParsePacketFromEvents ¶
func ParsePacketFromEvents(events []abci.Event) (channeltypes.Packet, error)
ParsePacketFromEvents parses events emitted from a MsgRecvPacket and returns the first EventTypeSendPacket packet found. Returns an error if no packet is found.
func ParsePacketSequenceFromEvents ¶
ParsePacketSequenceFromEvents parses events emitted from MsgRecvPacket and returns the packet sequence
func ParsePacketsFromEvents ¶
ParsePacketsFromEvents parses events emitted from a MsgRecvPacket and returns all the packets found. Returns an error if no packet is found.
func ParseProposalIDFromEvents ¶
ParseProposalIDFromEvents parses events emitted from MsgSubmitProposal and returns proposalID
func ParseRecvPacketFromEvents ¶
func ParseRecvPacketFromEvents(events []abci.Event) (channeltypes.Packet, error)
ParseRecvPacketFromEvents parses events emitted from a MsgRecvPacket and returns the first EventTypeRecvPacket packet found. Returns an error if no packet is found.
func UnmarshalMsgResponses ¶
UnmarshalMsgResponses parse out msg responses from a transaction result
func VoteAndCheckProposalStatus ¶
VoteAndCheckProposalStatus votes on a gov proposal, checks if the proposal has passed, and returns an error if it has not with the failure reason.
Types ¶
type ChannelConfig ¶
type ChannelConfig struct { PortID string Version string Order channeltypes.Order ProposedUpgrade channeltypes.Upgrade }
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 ¶
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) *Coordinator
NewCoordinator initializes Coordinator with N TestChain's
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) CreateChannels ¶
func (*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. Deprecated: please use path.CreateChannels(), this function will be removed in v10
func (*Coordinator) CreateConnections ¶
func (*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. Deprecated: please use path.CreateConnections(), this function will be removed in v10
func (*Coordinator) CreateMockChannels ¶
func (*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 (*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) Setup ¶
func (*Coordinator) Setup(path *Path)
Setup constructs a TM client, connection, and channel on both chains provided. It will fail if any error occurs. Deprecated: please use path.Setup(), this function will be removed in v10
func (*Coordinator) SetupClients ¶
func (*Coordinator) SetupClients(path *Path)
SetupClients is a helper function to create clients on both chains. It assumes the caller does not anticipate any errors. Deprecated: please use path.SetupClients(), this function will be removed in v10
func (*Coordinator) SetupConnections ¶
func (*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. Deprecated: please use path.SetupConnections(), this function will be removed in v10
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 ClientConfig ConnectionConfig *ConnectionConfig ChannelConfig *ChannelConfig // contains filtered or unexported fields }
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 ¶
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 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(packet channeltypes.Packet, ack []byte) error
AcknowledgePacket sends a MsgAcknowledgement to the channel associated with the endpoint.
func (*Endpoint) AcknowledgePacketWithResult ¶
func (endpoint *Endpoint) AcknowledgePacketWithResult(packet channeltypes.Packet, ack []byte) (*abci.ExecTxResult, error)
AcknowledgePacket sends a MsgAcknowledgement to the channel associated with the endpoint and returns the result.
func (*Endpoint) ChanCloseInit ¶
ChanCloseInit will construct and execute a MsgChannelCloseInit on the associated endpoint.
NOTE: does not work with ibc-transfer module
func (*Endpoint) ChanOpenAck ¶
ChanOpenAck will construct and execute a MsgChannelOpenAck on the associated endpoint.
func (*Endpoint) ChanOpenConfirm ¶
ChanOpenConfirm will construct and execute a MsgChannelOpenConfirm on the associated endpoint.
func (*Endpoint) ChanOpenInit ¶
ChanOpenInit will construct and execute a MsgChannelOpenInit on the associated endpoint.
func (*Endpoint) ChanOpenTry ¶
ChanOpenTry will construct and execute a MsgChannelOpenTry on the associated endpoint.
func (*Endpoint) ChanUpgradeAck ¶
ChanUpgradeAck sends a MsgChannelUpgradeAck to the associated endpoint.
func (*Endpoint) ChanUpgradeCancel ¶
ChanUpgradeCancel sends a MsgChannelUpgradeCancel to the associated endpoint.
func (*Endpoint) ChanUpgradeConfirm ¶
ChanUpgradeConfirm sends a MsgChannelUpgradeConfirm to the associated endpoint.
func (*Endpoint) ChanUpgradeInit ¶
ChanUpgradeInit sends a MsgChannelUpgradeInit on the associated endpoint. A default upgrade proposal is used with overrides from the ProposedUpgrade in the channel config, and submitted via governance proposal
func (*Endpoint) ChanUpgradeOpen ¶
ChanUpgradeOpen sends a MsgChannelUpgradeOpen to the associated endpoint.
func (*Endpoint) ChanUpgradeTimeout ¶
ChanUpgradeTimeout sends a MsgChannelUpgradeTimeout to the associated endpoint.
func (*Endpoint) ChanUpgradeTry ¶
ChanUpgradeTry sends a MsgChannelUpgradeTry on the associated endpoint.
func (*Endpoint) ConnOpenAck ¶
ConnOpenAck will construct and execute a MsgConnectionOpenAck on the associated endpoint.
func (*Endpoint) ConnOpenConfirm ¶
ConnOpenConfirm will construct and execute a MsgConnectionOpenConfirm on the associated endpoint.
func (*Endpoint) ConnOpenInit ¶
ConnOpenInit will construct and execute a MsgConnectionOpenInit on the associated endpoint.
func (*Endpoint) ConnOpenTry ¶
ConnOpenTry will construct and execute a MsgConnectionOpenTry on the associated endpoint.
func (*Endpoint) CreateClient ¶
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) GetChannelUpgrade ¶
func (endpoint *Endpoint) GetChannelUpgrade() channeltypes.Upgrade
GetChannelUpgrade retrieves an IBC Channel Upgrade for the endpoint. The upgrade is expected to exist otherwise testing will fail.
func (*Endpoint) GetClientLatestHeight ¶
GetClientLatestHeight returns the latest height for the client state for this endpoint. The client state 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) GetProposedUpgrade ¶
func (endpoint *Endpoint) GetProposedUpgrade() channeltypes.Upgrade
GetProposedUpgrade returns a valid upgrade which can be used for UpgradeInit and UpgradeTry. By default, the endpoint's existing channel fields will be used for the upgrade fields and a sane default timeout will be used by querying the counterparty's latest height. If any non-empty values are specified in the ChannelConfig's ProposedUpgrade, those values will be used in the returned upgrade.
func (*Endpoint) IncrementNextChannelSequence ¶
func (endpoint *Endpoint) IncrementNextChannelSequence()
IncrementNextChannelSequence incrementes the value "nextChannelSequence" in the store, which is used to determine the next channel ID. This guarantees that we'll have always different IDs while running tests.
func (*Endpoint) QueryChannelUpgradeProof ¶
func (endpoint *Endpoint) QueryChannelUpgradeProof() ([]byte, []byte, clienttypes.Height)
QueryChannelUpgradeProof returns all the proofs necessary to execute UpgradeTry/UpgradeAck/UpgradeOpen. It returns the proof for the channel on the endpoint's chain, the proof for the upgrade attempt on the endpoint's chain, and the height at which the proof was queried.
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, clientProof, consensusProof []byte, consensusHeight clienttypes.Height, connectionProof []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 latest 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) SetChannelCounterpartyUpgrade ¶
func (endpoint *Endpoint) SetChannelCounterpartyUpgrade(upgrade channeltypes.Upgrade)
SetChannelCounterpartyUpgrade sets the channel counterparty upgrade for this endpoint.
func (*Endpoint) SetChannelState
deprecated
func (endpoint *Endpoint) SetChannelState(state channeltypes.State) error
Deprecated: usage of this function should be replaced by `UpdateChannelState` SetChannelState sets a channel state
func (*Endpoint) SetChannelUpgrade ¶
func (endpoint *Endpoint) SetChannelUpgrade(upgrade channeltypes.Upgrade)
SetChannelUpgrade sets the channel upgrade for this endpoint.
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) UpdateChannel ¶
func (endpoint *Endpoint) UpdateChannel(updater func(channel *channeltypes.Channel))
UpdateChannel updates the channel associated with the given endpoint. It accepts a closure which takes a channel allowing the caller to modify its fields.
func (*Endpoint) UpdateClient ¶
UpdateClient updates the IBC client associated with the endpoint.
func (*Endpoint) UpdateConnection ¶
func (endpoint *Endpoint) UpdateConnection(updater func(connection *connectiontypes.ConnectionEnd))
UpdateConnection updates the connection associated with the given endpoint. It accepts a closure which takes a connection allowing the caller to modify the connection fields.
func (*Endpoint) UpgradeChain ¶
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 Path ¶
Path contains two endpoints representing two chains connected over IBC
func EnableFeeOnPath ¶
EnableFeeOnPath enables fee on a channel given a path.
func NewPath ¶
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 NewPathWithFeeEnabled ¶
NewPathWithFeeEnabled 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. It also enables fee on the path
func NewTransferPath ¶
NewTransferPath constructs a new path between each chain suitable for use with the transfer module.
func NewTransferPathWithFeeEnabled ¶
NewTransferPathWithFeeEnabled constructs a new path between each chain suitable for use with the transfer module, and it enables fee on it.
func (*Path) CreateChannels ¶
func (path *Path) CreateChannels()
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 (*Path) CreateConnections ¶
func (path *Path) CreateConnections()
CreateConnections constructs and executes connection handshake messages in order to create OPEN connections on chainA and chainB. The function expects the connections to be successfully opened otherwise testing will fail.
func (*Path) DisableUniqueChannelIDs ¶
DisableUniqueChannelIDs provides an opt-out way to not have all channel IDs be different while testing.
func (*Path) RelayPacket ¶
func (path *Path) RelayPacket(packet channeltypes.Packet) 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) RelayPacketWithResults ¶
func (path *Path) RelayPacketWithResults(packet channeltypes.Packet) (*abci.ExecTxResult, []byte, error)
RelayPacketWithResults attempts to relay the packet first on EndpointA and then on EndpointB if EndpointA does not contain a packet commitment for that packet. The function returns: - The result of the packet receive transaction. - The acknowledgement written on the receiving chain. - An error if a relay step fails or the packet commitment does not exist on either endpoint.
func (*Path) SetChannelOrdered ¶
func (path *Path) SetChannelOrdered()
SetChannelOrdered sets the channel order for both endpoints to ORDERED.
func (*Path) Setup ¶
func (path *Path) Setup()
Setup constructs a TM client, connection, and channel on both chains provided. It will fail if any error occurs.
func (*Path) SetupClients ¶
func (path *Path) SetupClients()
SetupClients is a helper function to create clients on both chains. It assumes the caller does not anticipate any errors.
func (*Path) SetupConnections ¶
func (path *Path) SetupConnections()
SetupConnections 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 SenderAccount ¶
type SenderAccount struct { SenderPrivKey cryptotypes.PrivKey SenderAccount sdk.AccountI }
type Solomachine ¶
type Solomachine struct { ClientID string PrivateKeys []cryptotypes.PrivKey // keys used for signing PublicKeys []cryptotypes.PubKey // keys used for generating solo machine pub key PublicKey cryptotypes.PubKey // key used for verification Sequence uint64 Time uint64 Diversifier string // contains filtered or unexported fields }
Solomachine is a testing helper used to simulate a counterparty solo machine client.
func NewSolomachine ¶
func NewSolomachine(t *testing.T, cdc codec.BinaryCodec, clientID, diversifier string, nKeys uint64) *Solomachine
NewSolomachine returns a new solomachine instance with an `nKeys` amount of generated private/public key pairs and a sequence starting at 1. If nKeys is greater than 1 then a multisig public key is used.
func (*Solomachine) AcknowledgePacket ¶
func (solo *Solomachine) AcknowledgePacket(chain *TestChain, packet channeltypes.Packet)
AcknowledgePacket creates an acknowledgement proof and broadcasts a MsgAcknowledgement.
func (*Solomachine) ChanCloseConfirm ¶
func (solo *Solomachine) ChanCloseConfirm(chain *TestChain, portID, channelID string)
ChanCloseConfirm performs the channel close confirm handshake step on the tendermint chain for the associated solo machine client.
func (*Solomachine) ChanOpenAck ¶
func (solo *Solomachine) ChanOpenAck(chain *TestChain, channelID string)
ChanOpenAck performs the channel open ack handshake step on the tendermint chain for the associated solo machine client.
func (*Solomachine) ChanOpenInit ¶
func (solo *Solomachine) ChanOpenInit(chain *TestChain, connectionID string) string
ChanOpenInit initializes a channel on the provided chain given a solo machine connectionID.
func (*Solomachine) ClientState ¶
func (solo *Solomachine) ClientState() *solomachine.ClientState
ClientState returns a new solo machine ClientState instance.
func (*Solomachine) ConnOpenAck ¶
func (solo *Solomachine) ConnOpenAck(chain *TestChain, clientID, connectionID string)
ConnOpenAck performs the connection open ack handshake step on the tendermint chain for the associated solo machine client.
func (*Solomachine) ConnOpenInit ¶
func (solo *Solomachine) ConnOpenInit(chain *TestChain, clientID string) string
ConnOpenInit initializes a connection on the provided chain given a solo machine clientID.
func (*Solomachine) ConsensusState ¶
func (solo *Solomachine) ConsensusState() *solomachine.ConsensusState
ConsensusState returns a new solo machine ConsensusState instance
func (*Solomachine) CreateClient ¶
func (solo *Solomachine) CreateClient(chain *TestChain) string
CreateClient creates an on-chain client on the provided chain.
func (*Solomachine) CreateHeader ¶
func (solo *Solomachine) CreateHeader(newDiversifier string) *solomachine.Header
CreateHeader generates a new private/public key pair and creates the necessary signature to construct a valid solo machine header. A new diversifier will be used as well
func (*Solomachine) CreateMisbehaviour ¶
func (solo *Solomachine) CreateMisbehaviour() *solomachine.Misbehaviour
CreateMisbehaviour constructs testing misbehaviour for the solo machine client by signing over two different data bytes at the same sequence.
func (*Solomachine) GenerateAcknowledgementProof ¶
func (solo *Solomachine) GenerateAcknowledgementProof(packet channeltypes.Packet) []byte
GenerateAcknowledgementProof generates an acknowledgement proof.
func (*Solomachine) GenerateChanClosedProof ¶
func (solo *Solomachine) GenerateChanClosedProof(portID, version, counterpartyChannelID string) []byte
GenerateChanClosedProof generates a channel closed proof. The channelID provided represents the channelID created on the counterparty chain, that is the tendermint chain.
func (*Solomachine) GenerateChanOpenTryProof ¶
func (solo *Solomachine) GenerateChanOpenTryProof(portID, version, counterpartyChannelID string) []byte
GenerateChanOpenTryProof generates the proofTry required for the channel open ack handshake step. The channelID provided represents the channelID created on the counterparty chain, that is the tendermint chain.
func (*Solomachine) GenerateClientStateProof ¶
func (solo *Solomachine) GenerateClientStateProof(clientState exported.ClientState) []byte
GenerateClientStateProof generates the proof of the client state required for the connection open try and ack handshake steps. The client state should be the self client states of the tendermint chain.
func (*Solomachine) GenerateCommitmentProof ¶
func (solo *Solomachine) GenerateCommitmentProof(packet channeltypes.Packet) []byte
GenerateCommitmentProof generates a commitment proof for the provided packet.
func (*Solomachine) GenerateConnOpenTryProof ¶
func (solo *Solomachine) GenerateConnOpenTryProof(counterpartyClientID, counterpartyConnectionID string) []byte
GenerateConnOpenTryProof generates the proofTry required for the connection open ack handshake step. The clientID, connectionID provided represent the clientID and connectionID created on the counterparty chain, that is the tendermint chain.
func (*Solomachine) GenerateConsensusStateProof ¶
func (solo *Solomachine) GenerateConsensusStateProof(consensusState exported.ConsensusState, consensusHeight exported.Height) []byte
GenerateConsensusStateProof generates the proof of the consensus state required for the connection open try and ack handshake steps. The consensus state should be the self consensus states of the tendermint chain.
func (*Solomachine) GenerateProof ¶
func (solo *Solomachine) GenerateProof(signBytes *solomachine.SignBytes) []byte
GenerateProof takes in solo machine sign bytes, generates a signature and marshals it as a proof. The solo machine sequence is incremented.
func (*Solomachine) GenerateReceiptAbsenceProof ¶
func (solo *Solomachine) GenerateReceiptAbsenceProof(packet channeltypes.Packet) []byte
GenerateReceiptAbsenceProof generates a receipt absence proof for the provided packet.
func (*Solomachine) GenerateSignature ¶
func (solo *Solomachine) GenerateSignature(signBytes []byte) []byte
GenerateSignature uses the stored private keys to generate a signature over the sign bytes with each key. If the amount of keys is greater than 1 then a multisig data type is returned.
func (*Solomachine) GetChannelStatePath ¶
func (solo *Solomachine) GetChannelStatePath(portID, channelID string) commitmenttypesv2.MerklePath
GetChannelStatePath returns the commitment path for that channel state.
func (*Solomachine) GetClientStatePath ¶
func (solo *Solomachine) GetClientStatePath(counterpartyClientIdentifier string) commitmenttypesv2.MerklePath
GetClientStatePath returns the commitment path for the client state.
func (*Solomachine) GetConnectionStatePath ¶
func (solo *Solomachine) GetConnectionStatePath(connID string) commitmenttypesv2.MerklePath
GetConnectionStatePath returns the commitment path for the connection state.
func (*Solomachine) GetConsensusStatePath ¶
func (solo *Solomachine) GetConsensusStatePath(counterpartyClientIdentifier string, consensusHeight exported.Height) commitmenttypesv2.MerklePath
GetConsensusStatePath returns the commitment path for the consensus state.
func (*Solomachine) GetHeight ¶
func (solo *Solomachine) GetHeight() exported.Height
GetHeight returns an exported.Height with Sequence as RevisionHeight
func (*Solomachine) GetNextSequenceRecvPath ¶
func (solo *Solomachine) GetNextSequenceRecvPath(portID, channelID string) commitmenttypesv2.MerklePath
GetNextSequenceRecvPath returns the commitment path for the next sequence recv counter.
func (*Solomachine) GetPacketAcknowledgementPath ¶
func (solo *Solomachine) GetPacketAcknowledgementPath(portID, channelID string, sequence uint64) commitmenttypesv2.MerklePath
GetPacketAcknowledgementPath returns the commitment path for a packet acknowledgement.
func (*Solomachine) GetPacketCommitmentPath ¶
func (solo *Solomachine) GetPacketCommitmentPath(portID, channelID string, sequence uint64) commitmenttypesv2.MerklePath
GetPacketCommitmentPath returns the commitment path for a packet commitment.
func (*Solomachine) GetPacketReceiptPath ¶
func (solo *Solomachine) GetPacketReceiptPath(portID, channelID string, sequence uint64) commitmenttypesv2.MerklePath
GetPacketReceiptPath returns the commitment path for a packet receipt and an absent receipts.
func (*Solomachine) RecvPacket ¶
func (solo *Solomachine) RecvPacket(chain *TestChain, packet channeltypes.Packet)
RecvPacket creates a commitment proof and broadcasts a new MsgRecvPacket.
func (*Solomachine) SendTransfer ¶
func (solo *Solomachine) SendTransfer(chain *TestChain, portID, channelID string, fns ...func(*transfertypes.MsgTransfer)) channeltypes.Packet
SendTransfer constructs a MsgTransfer and sends the message to the given chain. Any number of optional functions can be provided which will modify the MsgTransfer before SendMsgs is called.
func (*Solomachine) TimeoutPacket ¶
func (solo *Solomachine) TimeoutPacket(chain *TestChain, packet channeltypes.Packet)
TimeoutPacket creates a unreceived packet proof and broadcasts a MsgTimeout.
func (*Solomachine) TimeoutPacketOnClose ¶
func (solo *Solomachine) TimeoutPacketOnClose(chain *TestChain, packet channeltypes.Packet, channelID string)
TimeoutPacketOnClose creates a channel closed and unreceived packet proof and broadcasts a MsgTimeoutOnClose.
func (*Solomachine) UpdateClient ¶
func (solo *Solomachine) UpdateClient(chain *TestChain, clientID string)
UpdateClient sends a MsgUpdateClient to the provided chain and updates the given clientID.
type TendermintConfig ¶
type TendermintConfig struct { TrustLevel ibctm.Fraction TrustingPeriod time.Duration UnbondingPeriod time.Duration MaxClockDrift time.Duration }
func NewTendermintConfig ¶
func NewTendermintConfig() *TendermintConfig
func (*TendermintConfig) GetClientType ¶
func (*TendermintConfig) GetClientType() string
type TestChain ¶
type TestChain struct { testing.TB Coordinator *Coordinator App TestingApp ChainID string LatestCommittedHeader *ibctm.Header // header for last block height committed ProposedHeader cmtproto.Header // proposed (uncommitted) header for current block height 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 // Short-term solution to override the logic of the standard SendMsgs function. // See issue https://github.com/cosmos/ibc-go/issues/3123 for more information. SendMsgsOverride func(msgs ...sdk.Msg) (*abci.ExecTxResult, error) }
TestChain is a testing struct that wraps a simapp with the last TM 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 NewTestChain ¶
func NewTestChain(t *testing.T, coord *Coordinator, chainID string) *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(tb testing.TB, coord *Coordinator, chainID string, valSet *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator) *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) 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) 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) CreateTMClientHeader ¶
func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, cmtValSet, nextVals, cmtTrustedVals *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator) *ibctm.Header
CreateTMClientHeader creates a TM header to update the TM client. Args are passed in to allow caller flexibility to use params that differ from the chain.
func (*TestChain) CurrentTMClientHeader ¶
CurrentTMClientHeader creates a TM header using the current header parameters on the chain. The trusted fields in the header are set to nil.
func (*TestChain) ExpireClient ¶
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) GetAcknowledgement ¶
func (chain *TestChain) GetAcknowledgement(packet channeltypes.Packet) []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) GetClientLatestHeight ¶
GetClientLatestHeight returns the latest height for the client state with the given client identifier. If an invalid client identifier is provided then a zero value height will be returned and 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 ¶
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) GetSimApp ¶
GetSimApp returns the SimApp to allow usage ofnon-interface fields. CONTRACT: This function should not be called by third parties implementing their own SimApp.
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) GetTimeoutTimestamp ¶
GetTimeoutTimestamp is a convenience function which returns a IBC packet timeout timestamp to be used for testing. It returns the current block timestamp + default timestamp delta (1 hour).
func (*TestChain) GetTrustedValidators ¶
func (chain *TestChain) GetTrustedValidators(trustedHeight int64) (*cmttypes.ValidatorSet, error)
GetTrustedValidators will return the trusted validator set of the chain for the given trusted height. Otherwise it will return an error.
func (*TestChain) IBCClientHeader ¶
func (chain *TestChain) IBCClientHeader(header *ibctm.Header, trustedHeight clienttypes.Height) (*ibctm.Header, error)
IBCClientHeader will construct a 07-tendermint Header to update the light client on the counterparty chain. The trustedHeight must be passed in as a non-zero height.
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 Tendermint protocol of applying valset changes returned on block `n` to the validators of block `n+2`. It calls BeginBlock 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 ¶
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 ¶
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.
type TestingApp ¶
type TestingApp interface { servertypes.ABCI // ibc-go additions GetBaseApp() *baseapp.BaseApp GetStakingKeeper() ibctestingtypes.StakingKeeper GetIBCKeeper() *keeper.Keeper GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper GetTxConfig() client.TxConfig // Implemented by SimApp AppCodec() codec.Codec // Implemented by BaseApp LastCommitID() storetypes.CommitID LastBlockHeight() int64 }
func SetupTestingApp ¶
func SetupTestingApp() (TestingApp, map[string]json.RawMessage)
func SetupWithGenesisValSet ¶
func SetupWithGenesisValSet(tb testing.TB, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction sdkmath.Int, balances ...banktypes.Balance) TestingApp
SetupWithGenesisValSet initializes a new SimApp with a validator set and genesis accounts that also act as delegators. For simplicity, each validator is bonded with a delegation of one consensus engine unit (10^6) in the default token of the simapp from first genesis account. A Nop logger is set in SimApp.