ibctesting

package
v0.61.8 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 32 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 (
	TimeIncrement = time.Second * 5

	MaxAccounts = 10
)

Functions

func CloseChannel

func CloseChannel(coord *ibctesting.Coordinator, path *ibctesting.Path)

CloseChannel close channel on both sides

func MsgRecvPacketWithResultV2 added in v0.61.0

func MsgRecvPacketWithResultV2(endpoint *ibctesting.Endpoint, packet channeltypesv2.Packet) (*abci.ExecTxResult, error)

func NewCoordinator

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

NewCoordinator initializes Coordinator with N TestChain's

func NewDefaultTestChain

func NewDefaultTestChain(t *testing.T, coord *ibctesting.Coordinator, chainID string, opts ...wasmkeeper.Option) *ibctesting.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 *ibctesting.Coordinator, appFactory ChainAppFactory, chainID string, opts ...wasmkeeper.Option) *ibctesting.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 *ibctesting.Coordinator, appFactory ChainAppFactory, chainID string, valSet *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator, opts ...wasmkeeper.Option) *ibctesting.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 ParseAckFromEvents

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

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

func ParseAckFromEventsV2 added in v0.61.0

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

ParseAckFromEventsV2 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 ParsePortIDFromEvents

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

func RelayAndAckPendingPackets

func RelayAndAckPendingPackets(path *WasmPath) error

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

func RelayPacketV2 added in v0.61.0

func RelayPacketV2(path *WasmPath, packet channeltypesv2.Packet, srcEndpoint, dstEndpoint *ibctesting.Endpoint, packetToAck *channeltypesv2.Packet) error

func RelayPacketWithoutAck

func RelayPacketWithoutAck(path *ibctesting.Path, packet channeltypes.Packet, dstEndpoint *ibctesting.Endpoint) error

func RelayPacketWithoutAckV2 added in v0.61.0

func RelayPacketWithoutAckV2(path *WasmPath, packet channeltypesv2.Packet, dstEndpoint *ibctesting.Endpoint) error

RelayPacketWithoutAckV2 attempts to relay the packet to the destination IBCv2 Endpoint.

func RelayPendingPacketsV2 added in v0.61.0

func RelayPendingPacketsV2(path *WasmPath) error

RelayPendingPacketsV2 sends pending packages from path.EndpointA to the counterparty chain. It does not relay ACKs even if they appear.

func RelayPendingPacketsWithAcksV2 added in v0.61.0

func RelayPendingPacketsWithAcksV2(path *WasmPath) error

RelayPendingPacketsWithAcksV2 sends pending packages between path.EndpointA and path.EndpointB along with ACKs

func TimeoutPendingPackets

func TimeoutPendingPackets(coord *ibctesting.Coordinator, path *WasmPath) error

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

func TimeoutPendingPacketsV2 added in v0.61.0

func TimeoutPendingPacketsV2(coord *ibctesting.Coordinator, path *WasmPath) error

TimeoutPendingPacketsV2 returns the package to source chain to let the IBCv2 app revert any operation. from A to B

Types

type ChainAppFactory

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

ChainAppFactory abstract factory method that usually implemented by app.SetupWithGenesisValSet

type PendingAckPacketV2 added in v0.61.0

type PendingAckPacketV2 struct {
	channeltypesv2.Packet
	Ack []byte
}

type WasmPath

type WasmPath struct {
	ibctesting.Path
	// contains filtered or unexported fields
}

func NewWasmPath

func NewWasmPath(chainA, chainB *WasmTestChain) *WasmPath

type WasmTestApp

type WasmTestApp struct {
	*app.WasmApp
}

func DefaultWasmAppFactory

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

DefaultWasmAppFactory instantiates and sets up the default wasmd app

func (WasmTestApp) GetTxConfig

func (app WasmTestApp) GetTxConfig() client.TxConfig

type WasmTestChain

type WasmTestChain struct {
	*ibctesting.TestChain

	PendingSendPackets   *[]channeltypes.Packet
	PendingSendPacketsV2 *[]channeltypesv2.Packet
}

func NewWasmTestChain

func NewWasmTestChain(chain *ibctesting.TestChain) *WasmTestChain

func (*WasmTestChain) AllBalances

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

func (*WasmTestChain) Balance

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

func (*WasmTestChain) CaptureIBCEvents

func (chain *WasmTestChain) CaptureIBCEvents(result *abci.ExecTxResult)

func (*WasmTestChain) CaptureIBCEventsV2 added in v0.61.0

func (chain *WasmTestChain) CaptureIBCEventsV2(result *abci.ExecTxResult)

func (*WasmTestChain) ContractInfo

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

func (*WasmTestChain) Fund

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

Fund an address with the given amount in default denom

func (*WasmTestChain) GetTimeoutHeight

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

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

func (*WasmTestChain) GetWasmApp

func (chain *WasmTestChain) GetWasmApp() *app.WasmApp

func (*WasmTestChain) InstantiateContract

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

func (*WasmTestChain) OverrideSendMsgs

func (chain *WasmTestChain) OverrideSendMsgs(msgs ...sdk.Msg) (*abci.ExecTxResult, error)

func (*WasmTestChain) SeedNewContractInstance

func (chain *WasmTestChain) 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 (*WasmTestChain) SendNonDefaultSenderMsgs

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

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

func (*WasmTestChain) SmartQuery

func (chain *WasmTestChain) SmartQuery(contractAddr string, queryMsg, response any) 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 (*WasmTestChain) StoreCode

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

func (*WasmTestChain) StoreCodeFile

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

func (*WasmTestChain) UnwrapExecTXResult

func (chain *WasmTestChain) 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