Documentation ¶
Index ¶
- Variables
- func CreateSortedSignerArray(altPrivVal, suitePrivVal tmtypes.PrivValidator, ...) []tmtypes.PrivValidator
- func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) tmtypes.BlockID
- func ParseChannelIDFromEvents(events sdk.Events) (string, error)
- func ParseClientIDFromEvents(events sdk.Events) (string, error)
- func ParseConnectionIDFromEvents(events sdk.Events) (string, error)
- type TestChain
- func (chain *TestChain) ChainID() string
- func (chain *TestChain) ChannelOpenAck(ctx context.Context, msg ibctestingtypes.MsgChannelOpenAck) error
- func (chain *TestChain) ChannelOpenConfirm(ctx context.Context, msg ibctestingtypes.MsgChannelOpenConfirm) error
- func (chain *TestChain) ChannelOpenInit(ctx context.Context, msg ibctestingtypes.MsgChannelOpenInit) (string, error)
- func (chain *TestChain) ChannelOpenTry(ctx context.Context, msg ibctestingtypes.MsgChannelOpenTry) (string, error)
- func (chain *TestChain) ChannelStateCommitmentKey(portID, channelID string) []byte
- func (chain *TestChain) ClientStateCommitmentKey(clientID string) []byte
- func (chain *TestChain) ConnectionOpenAck(ctx context.Context, msg ibctestingtypes.MsgConnectionOpenAck) error
- func (chain *TestChain) ConnectionOpenConfirm(ctx context.Context, msg ibctestingtypes.MsgConnectionOpenConfirm) error
- func (chain *TestChain) ConnectionOpenInit(ctx context.Context, msg ibctestingtypes.MsgConnectionOpenInit) (string, error)
- func (chain *TestChain) ConnectionOpenTry(ctx context.Context, msg ibctestingtypes.MsgConnectionOpenTry) (string, error)
- func (chain *TestChain) ConnectionStateCommitmentKey(connectionID string) []byte
- func (chain *TestChain) ConsensusStateCommitmentKey(clientID string, height exported.Height) []byte
- func (chain *TestChain) ConstructMockMsgCreateClient() ibctestingtypes.MsgCreateClient
- func (chain *TestChain) ConstructMockMsgUpdateClient(clientID string) ibctestingtypes.MsgUpdateClient
- func (chain *TestChain) ConstructTendermintMsgCreateClient(trustLevel ibctmtypes.Fraction, ...) ibctestingtypes.MsgCreateClient
- func (chain *TestChain) ConstructTendermintUpdateTMClientHeader(counterparty ibctestingtypes.TestChainI, clientID string) ibctestingtypes.MsgUpdateClient
- func (chain *TestChain) ConstructTrustedEthereumMsgCreateClient(publicKey cryptotypes.PubKey, diversifier string) ibctestingtypes.MsgCreateClient
- func (chain *TestChain) ConstructTrustedEthereumMsgUpdateClient(clientID string, privateKey cryptotypes.PrivKey, divisifier string) ibctestingtypes.MsgUpdateClient
- func (chain *TestChain) ConstructUpdateTMClientHeader(counterparty ibctestingtypes.TestChainI, clientID string) (*ibctmtypes.Header, error)
- func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterparty ibctestingtypes.TestChainI, clientID string, ...) (*ibctmtypes.Header, error)
- func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID, channelID string)
- func (chain *TestChain) CreateClient(ctx context.Context, msg ibctestingtypes.MsgCreateClient) (string, error)
- func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID string)
- func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, ...) *ibctmtypes.Header
- func (chain *TestChain) CurrentTMClientHeader() *ibctmtypes.Header
- func (chain *TestChain) GetAcknowledgement(packet exported.PacketI) []byte
- func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability
- func (chain *TestChain) GetClientStateBytes(clientID string) []byte
- func (chain *TestChain) GetCommitmentPrefix() []byte
- func (chain *TestChain) GetConsensusState(clientID string, height exported.Height) (exported.ConsensusState, bool)
- func (chain *TestChain) GetContext() sdk.Context
- func (chain *TestChain) GetLatestHeight(clientID string, clientType string) exported.Height
- func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability
- func (chain *TestChain) GetSenderAddress() string
- func (chain *TestChain) GetSimApp() *simapp.SimApp
- func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bool)
- func (chain *TestChain) HandlePacketAcknowledgement(ctx context.Context, packet exported.PacketI, acknowledgement []byte, ...) error
- func (chain *TestChain) HandlePacketRecv(ctx context.Context, packet exported.PacketI, proof *ibctestingtypes.Proof) error
- func (chain *TestChain) Init(chainID string) error
- func (chain *TestChain) MockAcknowledgementProof(ack []byte, proof *ibctestingtypes.Proof) (*ibctestingtypes.Proof, error)
- func (chain *TestChain) MockChannelProof(portID string, channelID string, proof *ibctestingtypes.Proof) (*ibctestingtypes.Proof, error)
- func (chain *TestChain) MockConnectionProof(connectionID string, proof *ibctestingtypes.Proof) (*ibctestingtypes.Proof, error)
- func (chain *TestChain) MockPacketProof(packet exported.PacketI, proof *ibctestingtypes.Proof) (*ibctestingtypes.Proof, error)
- func (chain *TestChain) NextBlock()
- func (chain *TestChain) PacketAcknowledgementCommitmentKey(portID, channelID string, sequence uint64) []byte
- func (chain *TestChain) PacketCommitmentKey(portID, channelID string, sequence uint64) []byte
- func (chain *TestChain) QueryProofAtHeight(key []byte, height exported.Height, clientType string) (*ibctestingtypes.Proof, error)
- func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error)
- func (chain *TestChain) T() *testing.T
- func (chain *TestChain) UpdateClient(ctx context.Context, msg ibctestingtypes.MsgUpdateClient) error
- type TestingApp
Constants ¶
This section is empty.
Variables ¶
var DefaultTestingAppInit func() (TestingApp, map[string]json.RawMessage) = SetupTestingApp
Functions ¶
func CreateSortedSignerArray ¶
func CreateSortedSignerArray(altPrivVal, suitePrivVal tmtypes.PrivValidator, altVal, suiteVal *tmtypes.Validator) []tmtypes.PrivValidator
CreateSortedSignerArray takes two PrivValidators, and the corresponding Validator structs (including voting power). It returns a signer array of PrivValidators that matches the sorting of ValidatorSet. The sorting is first by .VotingPower (descending), with secondary index of .Address (ascending).
func MakeBlockID ¶
MakeBlockID copied unimported test functions from tmtypes to use them here
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.
Types ¶
type TestChain ¶
type TestChain struct { App TestingApp LastHeader *ibctmtypes.Header // header for last block height committed CurrentHeader tmproto.Header // header for current block height QueryServer types.QueryServer TxConfig client.TxConfig Codec codec.BinaryCodec Vals *tmtypes.ValidatorSet Signers []tmtypes.PrivValidator SenderAccount authtypes.AccountI // contains filtered or unexported fields }
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 ¶
NewTestChain initializes a new TestChain instance with a single validator set using a generated private key. It also creates a sender account to be used for delivering transactions.
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.
func (*TestChain) ChannelOpenAck ¶
func (chain *TestChain) ChannelOpenAck(ctx context.Context, msg ibctestingtypes.MsgChannelOpenAck) error
func (*TestChain) ChannelOpenConfirm ¶
func (chain *TestChain) ChannelOpenConfirm(ctx context.Context, msg ibctestingtypes.MsgChannelOpenConfirm) error
func (*TestChain) ChannelOpenInit ¶
func (chain *TestChain) ChannelOpenInit(ctx context.Context, msg ibctestingtypes.MsgChannelOpenInit) (string, error)
func (*TestChain) ChannelOpenTry ¶
func (chain *TestChain) ChannelOpenTry(ctx context.Context, msg ibctestingtypes.MsgChannelOpenTry) (string, error)
func (*TestChain) ChannelStateCommitmentKey ¶
func (*TestChain) ClientStateCommitmentKey ¶
func (*TestChain) ConnectionOpenAck ¶
func (chain *TestChain) ConnectionOpenAck(ctx context.Context, msg ibctestingtypes.MsgConnectionOpenAck) error
func (*TestChain) ConnectionOpenConfirm ¶
func (chain *TestChain) ConnectionOpenConfirm(ctx context.Context, msg ibctestingtypes.MsgConnectionOpenConfirm) error
func (*TestChain) ConnectionOpenInit ¶
func (chain *TestChain) ConnectionOpenInit(ctx context.Context, msg ibctestingtypes.MsgConnectionOpenInit) (string, error)
func (*TestChain) ConnectionOpenTry ¶
func (chain *TestChain) ConnectionOpenTry(ctx context.Context, msg ibctestingtypes.MsgConnectionOpenTry) (string, error)
func (*TestChain) ConnectionStateCommitmentKey ¶
func (*TestChain) ConsensusStateCommitmentKey ¶
func (*TestChain) ConstructMockMsgCreateClient ¶
func (chain *TestChain) ConstructMockMsgCreateClient() ibctestingtypes.MsgCreateClient
func (*TestChain) ConstructMockMsgUpdateClient ¶
func (chain *TestChain) ConstructMockMsgUpdateClient(clientID string) ibctestingtypes.MsgUpdateClient
func (*TestChain) ConstructTendermintMsgCreateClient ¶
func (chain *TestChain) ConstructTendermintMsgCreateClient( trustLevel ibctmtypes.Fraction, trustingPeriod, unbondingPeriod, maxClockDrift time.Duration, upgradePath []string, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour bool) ibctestingtypes.MsgCreateClient
func (*TestChain) ConstructTendermintUpdateTMClientHeader ¶
func (chain *TestChain) ConstructTendermintUpdateTMClientHeader( counterparty ibctestingtypes.TestChainI, clientID string, ) ibctestingtypes.MsgUpdateClient
func (*TestChain) ConstructTrustedEthereumMsgCreateClient ¶
func (chain *TestChain) ConstructTrustedEthereumMsgCreateClient( publicKey cryptotypes.PubKey, diversifier string, ) ibctestingtypes.MsgCreateClient
func (*TestChain) ConstructTrustedEthereumMsgUpdateClient ¶
func (chain *TestChain) ConstructTrustedEthereumMsgUpdateClient( clientID string, privateKey cryptotypes.PrivKey, divisifier string, ) ibctestingtypes.MsgUpdateClient
func (*TestChain) ConstructUpdateTMClientHeader ¶
func (chain *TestChain) ConstructUpdateTMClientHeader(counterparty ibctestingtypes.TestChainI, clientID string) (*ibctmtypes.Header, error)
ConstructUpdateTMClientHeader will construct a valid 07-tendermint Header to update the light client on the source chain.
func (*TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight ¶
func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterparty ibctestingtypes.TestChainI, clientID string, trustedHeight clienttypes.Height) (*ibctmtypes.Header, error)
ConstructUpdateTMClientHeader will construct a valid 07-tendermint Header to update the light client on the source chain.
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) CreateClient ¶
func (chain *TestChain) CreateClient(ctx context.Context, msg ibctestingtypes.MsgCreateClient) (string, error)
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 capbility 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, tmValSet, tmTrustedVals *tmtypes.ValidatorSet, signers []tmtypes.PrivValidator) *ibctmtypes.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 ¶
func (chain *TestChain) CurrentTMClientHeader() *ibctmtypes.Header
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) GetAcknowledgement ¶
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) GetClientStateBytes ¶
GetClientStateBytes retrieves the client state for the provided clientID. The client is expected to exist otherwise testing will fail.
func (*TestChain) GetCommitmentPrefix ¶
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) GetLatestHeight ¶
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) GetSenderAddress ¶
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) GetValsAtHeight ¶
func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.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) HandlePacketAcknowledgement ¶
func (*TestChain) HandlePacketRecv ¶
func (*TestChain) MockAcknowledgementProof ¶
func (chain *TestChain) MockAcknowledgementProof(ack []byte, proof *ibctestingtypes.Proof) (*ibctestingtypes.Proof, error)
func (*TestChain) MockChannelProof ¶
func (chain *TestChain) MockChannelProof(portID string, channelID string, proof *ibctestingtypes.Proof) (*ibctestingtypes.Proof, error)
func (*TestChain) MockConnectionProof ¶
func (chain *TestChain) MockConnectionProof(connectionID string, proof *ibctestingtypes.Proof) (*ibctestingtypes.Proof, error)
func (*TestChain) MockPacketProof ¶
func (chain *TestChain) MockPacketProof(packet exported.PacketI, proof *ibctestingtypes.Proof) (*ibctestingtypes.Proof, error)
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.
CONTRACT: this function must only be called after app.Commit() occurs
func (*TestChain) PacketAcknowledgementCommitmentKey ¶
func (*TestChain) PacketCommitmentKey ¶
func (*TestChain) QueryProofAtHeight ¶
func (chain *TestChain) QueryProofAtHeight(key []byte, height exported.Height, clientType string) (*ibctestingtypes.Proof, error)
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) SendMsgs ¶
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) UpdateClient ¶
func (chain *TestChain) UpdateClient(ctx context.Context, msg ibctestingtypes.MsgUpdateClient) error
type TestingApp ¶
type TestingApp interface { abci.Application // ibc-go additions GetBaseApp() *baseapp.BaseApp GetStakingKeeper() stakingkeeper.Keeper GetIBCKeeper() *keeper.Keeper GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper GetTxConfig() client.TxConfig // Implemented by SimApp AppCodec() codec.Codec // Implemented by BaseApp LastCommitID() sdk.CommitID LastBlockHeight() int64 }
func SetupTestingApp ¶
func SetupTestingApp() (TestingApp, map[string]json.RawMessage)
func SetupWithGenesisValSet ¶
func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, 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.