test

package
v5.0.0-...-628dd20 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package test includes convenience functions and types to help with testing

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func PollForAck

func PollForAck(ctx context.Context, chain ChainAcker, startHeight, maxHeight uint64, packet ibc.Packet) (ibc.PacketAcknowledgement, error)

PollForAck attempts to find an acknowledgement containing a packet equal to the packet argument. Polling starts at startHeight and continues until maxHeight. It is safe to call this function even if the chain has yet to produce blocks for the target min/max height range. Polling delays until heights exist on the chain. Returns an error if acknowledgement not found or problems getting height or acknowledgements.

func PollForTimeout

func PollForTimeout(ctx context.Context, chain ChainTimeouter, startHeight, maxHeight uint64, packet ibc.Packet) (ibc.PacketTimeout, error)

PollForTimeout attempts to find a timeout containing a packet equal to the packet argument. Otherwise, works identically to PollForAck.

func WaitForBlocks

func WaitForBlocks(ctx context.Context, delta int, chains ...ChainHeighter) error

WaitForBlocks blocks until all chains reach a block height delta equal to or greater than the delta argument. If a ChainHeighter does not monotonically increase the height, this function may block program execution indefinitely.

func WaitForInSync

func WaitForInSync(ctx context.Context, chain ChainHeighter, nodes ...ChainHeighter) error

WaitForInSync blocks until all nodes have heights greater than or equal to the chain height.

Types

type BlockPoller

type BlockPoller struct {
	CurrentHeight func(ctx context.Context) (uint64, error)
	PollFunc      func(ctx context.Context, height uint64) (any, error)
}

func (BlockPoller) DoPoll

func (p BlockPoller) DoPoll(ctx context.Context, startHeight, maxHeight uint64) (any, error)

type ChainAcker

type ChainAcker interface {
	ChainHeighter
	Acknowledgements(ctx context.Context, height uint64) ([]ibc.PacketAcknowledgement, error)
}

ChainAcker is a chain that can get its acknowledgements at a specified height

type ChainHeighter

type ChainHeighter interface {
	Height(ctx context.Context) (uint64, error)
}

ChainHeighter fetches the current chain block height.

type ChainTimeouter

type ChainTimeouter interface {
	ChainHeighter
	Timeouts(ctx context.Context, height uint64) ([]ibc.PacketTimeout, error)
}

ChainTimeouter is a chain that can get its timeouts at a specified height

Jump to

Keyboard shortcuts

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