rpctest

package
v0.0.0-...-82e7055 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: ISC Imports: 24 Imported by: 0

README

rpctest

ISC License [GoDoc] (http://godoc.org/github.com/james-ray/hcd/rpctest)

Package rpctest provides a hcd-specific RPC testing harness crafting and executing integration tests by driving a hcd instance via the RPC interface. Each instance of an active harness comes equipped with a simple in-memory HD wallet capable of properly syncing to the generated chain, creating new addresses, and crafting fully signed transactions paying to an arbitrary set of outputs.

This package was designed specifically to act as an RPC testing harness for hcd. However, the constructs presented are general enough to be adapted to any project wishing to programmatically drive a hcd instance of its systems/integration tests.

Installation and Updating

$ go get -u github.com/james-ray/hcd/rpctest

License

Package rpctest is licensed under the copyfree ISC License.

Documentation

Overview

Package rpctest provides a hcd-specific RPC testing harness crafting and executing integration tests by driving a `hcd` instance via the `RPC` interface. Each instance of an active harness comes equipped with a simple in-memory HD wallet capable of properly syncing to the generated chain, creating new addresses, and crafting fully signed transactions paying to an arbitrary set of outputs.

This package was designed specifically to act as an RPC testing harness for `hcd`. However, the constructs presented are general enough to be adapted to any project wishing to programmatically drive a `hcd` instance of its systems/integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectNode

func ConnectNode(from *Harness, to *Harness) error

ConnectNode establishes a new peer-to-peer connection between the "from" harness and the "to" harness. The connection made is flagged as persistent, therefore in the case of disconnects, "from" will attempt to reestablish a connection to the "to" harness.

func JoinNodes

func JoinNodes(nodes []*Harness, joinType JoinType) error

JoinNodes is a synchronization tool used to block until all passed nodes are fully synced with respect to an attribute. This function will block for a period of time, finally returning once all nodes are synced according to the passed JoinType. This function be used to to ensure all active test harnesses are at a consistent state before proceeding to an assertion or check within rpc tests.

func NodesConnected

func NodesConnected(from, to *Harness, allowReverse bool) (bool, error)

NodesConnected verifies whether there is a connection via the p2p interface between the specified nodes. If allowReverse is true, connectivity is also checked in the reverse direction (to->from).

func RemoveNode

func RemoveNode(from *Harness, to *Harness) error

RemoveNode removes the peer-to-peer connection between the "from" harness and the "to" harness. The connection is only removed in this direction, therefore if the reverse connection exists, the nodes may still be connected.

This function returns an error if the nodes were not previously connected.

func TearDownAll

func TearDownAll() error

TearDownAll tears down all active test harnesses.

Types

type JoinType

type JoinType uint8

JoinType is an enum representing a particular type of "node join". A node join is a synchronization tool used to wait until a subset of nodes have a consistent state with respect to an attribute.

const (
	// Blocks is a JoinType which waits until all nodes share the same
	// block height.
	Blocks JoinType = iota

	// Mempools is a JoinType which blocks until all nodes have identical
	// mempool.
	Mempools
)

Jump to

Keyboard shortcuts

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