lbcd/rpctest/README.md
Olaoluwa Osuntokun b86df0ba91
rpctest: create new rpctest package
This commit adds a new package (rpctest) which provides functionality
for writing automated black box tests to exercise the RPC interface.

An instance of a rpctest consists of an active btcd process running in
(typically) --simnet mode, a btcrpcclient instance connected to said
node, and finally an embedded in-memory wallet instance (the memWallet)
which manages any created coinbase outputs created by the mining btcd
node.

As part of the SetUp process for an RPC test, a test author can
optionally opt to have a test blockchain created. The second argument
to SetUp dictates the number of mature coinbase outputs desired. The
btcd process will then be directed to generate a test chain of length:
100 + numMatureOutputs.

The embedded memWallet instance acts as a minimal, simple wallet for
each Harness instance. The memWallet itself is a BIP 32 HD wallet
capable of creating new addresses, creating fully signed transactions,
creating+broadcasting a transaction paying to an arbitrary set of
outputs, and querying the currently confirmed balance.

In order to test various scenarios of blocks containing arbitrary
transactions, one can use the Generate rpc call via the exposed
btcrpcclient connected to the active btcd node. Additionally, the
Harness also exposes a secondary block generation API allowing callers
to create blocks with a set of hand-selected transactions, and an
arbitrary BlockVersion or Timestamp.

After execution of test logic TearDown should be called, allowing the
test instance to clean up created temporary directories, and shut down
the running processes.

Running multiple concurrent rpctest.Harness instances is supported in
order to allow for test authors to exercise complex scenarios. As a
result, the primary interface to create, and initialize an
rpctest.Harness instance is concurrent safe, with shared package level
private global variables protected by a sync.Mutex.

Fixes #116.
2016-08-19 17:37:08 -05:00

1.2 KiB

rpctest

[Build Status] (https://travis-ci.org/btcsuite/btcd) ![ISC License] (http://img.shields.io/badge/license-ISC-blue.svg) [GoDoc] (http://godoc.org/github.com/btcsuite/btcd/rpctest)

Package rpctest provides a btcd-specific RPC testing harness crafting and executing integration tests by driving a btcd 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 btcd. However, the constructs presented are general enough to be adapted to any project wishing to programmatically drive a btcd instance of its systems/integration tests.

Installation and Updating

$ go get -u github.com/btcsuite/btcd/rpctest

License

Package rpctest is licensed under the copyfree ISC License.