btcd/integration/rpctest
Calvin Kim f8ce7a7da8 rpctest: scope shared state to the current process
Two pieces of rpctest's global state silently aliased across concurrent
test processes (which is what `go test ./...` does by default, so any
`make unit` that exercises -tags=rpctest hit this):

- btcdExecutablePath compiled to a fixed path /tmp/btcd/rpctest/btcd.
  Two `go build` invocations would race on the same file, occasionally
  yielding a truncated or stale binary and downstream "tls: certificate
  signed by unknown authority" failures when the harness tried to talk
  to the resulting node.

- lastPort started at the same defaultNodePort in every process. The
  bind-test in NextAvailablePort closes the listener before returning,
  so two processes climbing from the same base would frequently hand
  out the same port and one harness would die with "connection refused"
  when btcd failed to bind.

Suffix the executable with a random uint32 and seed lastPort with a
random offset into a 50k-port window so each process climbs through
its own range.
2026-05-30 17:49:55 +09:00
..
blockgen.go multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00
btcd.go rpctest: scope shared state to the current process 2026-05-30 17:49:55 +09:00
doc.go rpctest: Make subpackage of integration. 2017-05-11 15:17:29 -05:00
memwallet.go multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00
node.go multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00
README.md docs: update shields 2021-03-05 07:45:19 -05:00
rpc_harness.go rpctest: scope shared state to the current process 2026-05-30 17:49:55 +09:00
rpc_harness_test.go multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00
utils.go multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00

rpctest

Build Status ISC License GoDoc

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/integration/rpctest

License

Package rpctest is licensed under the copyfree ISC License.