integration/rpctest: improve test harness - #7
Open
allocz wants to merge 15 commits into
Open
Conversation
allocz
force-pushed
the
improve_rpctest_harness
branch
from
July 3, 2026 20:42
287ca98 to
f8932e0
Compare
allocz
force-pushed
the
improve_rpctest_harness
branch
9 times, most recently
from
July 12, 2026 03:06
fb75252 to
e7fe6fd
Compare
The usage of option structs allows cleaner calls when the default behavior is needed and also allows future extensions without breaking the API.
allocz
force-pushed
the
improve_rpctest_harness
branch
2 times, most recently
from
August 11, 2026 20:00
4814d98 to
0694cb1
Compare
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
force-pushed
the
improve_rpctest_harness
branch
from
August 11, 2026 20:15
0694cb1 to
56762b2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed in btcsuite#2560.
Changes