rpctest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2016 License: ISC Imports: 18 Imported by: 0

Documentation

Overview

Package rpctest ....

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

type Harness struct {
	ActiveNet *chaincfg.Params

	Node      *rpc.Client
	WalletRPC *rpc.Client
	// contains filtered or unexported fields
}

Harness fully encapsulates an active dcrd process, along with an embdedded dcrwallet in order to provide a unified platform for creating rpc driven integration tests involving dcrd. The active dcrd node will typically be run in simnet mode in order to allow for easy generation of test blockchains. Additionally, a special method is provided which allows on to easily generate coinbase spends. The active dcrd process if fully managed by Harness, which handles the necessary initialization, and teardown of the process along with any temporary directories created as a result. Multiple Harness instances may be run concurrently, in order to allow for testing complex scenarios involving multuple nodes.

func NewHarness

func NewHarness(activeNet *chaincfg.Params, handlers *rpc.NotificationHandlers,
	extraArgs []string) (*Harness, error)

NewHarness creates and initializes new instance of the rpc test harness. Optionally, websocket handlers and a specified configuration may be passed. In the case that a nil config is passed, a default configuration will be used.

NOTE: This function is safe for concurrent access.

func (*Harness) GenerateBlock

func (h *Harness) GenerateBlock(startHeight uint32) ([]*chainhash.Hash, error)

GenerateBlock is a helper function to ensure that the chain has actually incremented due to FORK blocks after stake voting height that may occur.

func (*Harness) RPCConfig

func (h *Harness) RPCConfig() rpc.ConnConfig

RPCConfig returns the harnesses current rpc configuration. This allows other potential RPC clients created within tests to connect to a given test harness instance.

func (*Harness) SetUp

func (h *Harness) SetUp(createTestChain bool, numMatureOutputs uint32) error

SetUp initializes the rpc test state. Initialization includes: starting up a simnet node, creating a websocket client and connecting to the started node, and finally: optionally generating and submitting a testchain with a configurable number of mature coinbase outputs coinbase outputs.

func (*Harness) TearDown

func (h *Harness) TearDown() error

TearDown stops the running rpc test instance. All created p. killed, and temporary directories removed.

Jump to

Keyboard shortcuts

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