Skip to content

integration/rpctest: improve test harness - #7

Open
allocz wants to merge 15 commits into
masterfrom
improve_rpctest_harness
Open

integration/rpctest: improve test harness#7
allocz wants to merge 15 commits into
masterfrom
improve_rpctest_harness

Conversation

@allocz

@allocz allocz commented Jun 30, 2026

Copy link
Copy Markdown
Owner

As discussed in btcsuite#2560.

Changes

  • 1. Debug event stream: connect to btcd and receive debug events.
  • 2. Harness teardown: stops btcd returning the exit code, but allow stopping without cleaning up node data, enabling the test of scenarios where btcd exits with error or scenarios where the node should be restarted.
  • 3. Harness start: allow the harness to be started again after teardown is called.
  • 4. Change New() signature: pass opts as a struct instead of having to pass multiple zero values to get default initialization.

@allocz
allocz force-pushed the improve_rpctest_harness branch from 287ca98 to f8932e0 Compare July 3, 2026 20:42
@allocz allocz changed the title integration/rpctest: add log assertion to Harness integration/rpctest: improve test harness Jul 3, 2026
@allocz
allocz force-pushed the improve_rpctest_harness branch 9 times, most recently from fb75252 to e7fe6fd Compare July 12, 2026 03:06
The usage of option structs allows cleaner calls when the default
behavior is needed and also allows future extensions without breaking
the API.
@allocz
allocz force-pushed the improve_rpctest_harness branch 2 times, most recently from 4814d98 to 0694cb1 Compare August 11, 2026 20:00
allocz added 14 commits August 11, 2026 20:14
rpctest.New was removed and rpctest.New2 renamed to rpctest.New, fixed
broken tests due to the API change.
With the signal option, we make it possible to skip sending the shutdown
signal to the node, allowing the test of cases where we expect the node
shutting down by itself.
Node restart support was implemented by creating the node instance on
harness SetUp instead of New, this way we can also run the same node
several times with a different set of arguments, allowing more test
cases to happen.

An option `NoRPCClientAndWallet` was added to simplify test cases where
for some reason the RPC Client won't connect to the instance.

Options `SkipCleanup` and `NoSignal` added to tear down procedure,
enabling the node to be restarted while the state is kept and also
allowing the test of cases where the node should shutdown by itself
instead of being shutdown upon receiving a signal.

Tests covering node restart and exit error code implemented and added
to the harness test table.
There are cases where the RPC will work, but the wallet would not be
able to finish sync up to best height, or we don't have reasons to wait
for the sync to finish.

Setting `NoWalletWait` to true allow us to skip waiting the wallet and
speed up tests, or even avoid blocking forever.
Previously, each time harness setup was executed, a new goroutine was
launched to handle the wallet updates, but the channel keeping the
goroutine alive was never closed, causing goroutine leakage.

The memwallet implementation was changed and now the memwallet goroutine
is stopped when harness teardown is called.

A test was added to assert that there's no goroutine leaks between
harness setup and teardown.
The debug stream allows the register of debug events which are
broadcasted to debug clients. The `debug` tag switches between the real
and the nop implementation, so that there's no cost of sending debug
events in production.
Now, when btcd is compiled with the `debug` tag and the flag
--debugstream=<host:port> is passed to btcd, the debug stream server
will be started, allowing btcd to broadcast debug events.

When the harness option `DebugHandler` callback is set, the harness will
connect with the debug stream, and the debug events can be handled by
the callback.
The change allow us to see the name and status of the tests running,
while also allowing to filter the tests by regexp instead of having to
comment when we want to test a single test case in isolation.

TestHarness previouly contained lines not wrapped to 80 columns.
Since the blocks are generated only when both CreateTestChain and
NumMatureOutputs are set, there's no obvious reason to keep both. The
code was simplified by ignoring the CreateTestChain option.
The previous commit made CreateTestChain option useless, so this commit
cleans up the codebase by effectively removing the option and all the
references to it.
@allocz
allocz force-pushed the improve_rpctest_harness branch from 0694cb1 to 56762b2 Compare August 11, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant