Merge bitcoin/bitcoin#36446: test: remove some avoidable test waits
What changed, and why it matters
This commit only changes Bitcoin Core's test and benchmark code to remove unnecessary waiting periods and honor existing test settings. It does not alter the production Bitcoin node software that users run, so it cannot directly affect live network security, wallets, or consensus behavior. The changes make CI tests run faster and avoid some redundant setup work.
No security action required. Treat as a normal test-quality/CI-performance improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit pulls in four test-only/bench-only changes: (1) capping benchmark epochs in WalletLoadingDescriptors to respect sanity mode’s single epoch, (2) switching two wallet unit tests from TestChain100Setup to BasicTestingSetup because they do not use the 100-block chain, (3) capping expected no-event IPC timeouts in interface_ipc_mining.py at 5 seconds, and (4) replacing a fixed 5-second sync attempt in p2p_node_network_limited.py with header/ping barriers and a bounded negative check. All modifications are confined to src/bench/wallet_loading.cpp, src/wallet/test/wallet_tests.cpp, test/functional/interface_ipc_mining.py, and test/functional/p2p_node_network_limited.py. No production consensus, networking, wallet, or RPC code is touched.
Changed components
test/functional/interface_ipc_mining.pytest/functional/p2p_node_network_limited.pysrc/bench/wallet_loading.cppsrc/wallet/test/wallet_tests.cppInspect captured patch +43 / −10
### src/bench/wallet_loading.cpp
@@ -18,6 +18,8 @@
#include <wallet/wallet.h>
#include <wallet/walletutil.h>
+#include <algorithm>
+#include <cstddef>
#include <cstdint>
#include <memory>
#include <optional>
@@ -62,7 +64,7 @@ static void WalletLoadingDescriptors(benchmark::Bench& bench)
options.require_create = false;
options.require_existing = true;
- bench.epochs(5)
+ bench.epochs(std::min(bench.epochs(), size_t{5}))
.setup([&] {
TestUnloadWallet(std::move(wallet));
database = MakeWalletDatabase("", options, status, error);
### src/wallet/test/wallet_tests.cpp
@@ -597,7 +597,7 @@ BOOST_FIXTURE_TEST_CASE(BasicOutputTypesTest, ListCoinsTest)
}
}
-BOOST_FIXTURE_TEST_CASE(wallet_disableprivkeys, TestChain100Setup)
+BOOST_FIXTURE_TEST_CASE(wallet_disableprivkeys, BasicTestingSetup)
{
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateMockableWalletDatabase());
LOCK(wallet->cs_wallet);
@@ -642,7 +642,7 @@ static size_t CalculateNestedKeyhashInputSize(bool use_max_sig)
return (size_t)GetVirtualTransactionInputSize(tx_in);
}
-BOOST_FIXTURE_TEST_CASE(dummy_input_size_test, TestChain100Setup)
+BOOST_FIXTURE_TEST_CASE(dummy_input_size_test, BasicTestingSetup)
{
BOOST_CHECK_EQUAL(CalculateNestedKeyhashInputSize(false), DUMMY_NESTED_P2WPKH_INPUT_SIZE);
BOOST_CHECK_EQUAL(CalculateNestedKeyhashInputSize(true), DUMMY_NESTED_P2WPKH_INPUT_SIZE);
### test/functional/interface_ipc_mining.py
@@ -150,7 +150,7 @@ async def async_routine():
assert_equal(len(newblockref.hash), block_hash_size)
assert_equal(newblockref.height, current_block_height + 1)
self.log.debug("Wait for timeout")
- oldblockref = (await mining.waitTipChanged(ctx, newblockref.hash, self.default_ipc_timeout)).result
+ oldblockref = (await mining.waitTipChanged(ctx, newblockref.hash, self.no_event_timeout_ms)).result
assert_equal(len(newblockref.hash), block_hash_size)
assert_equal(oldblockref.hash, newblockref.hash)
assert_equal(oldblockref.height, newblockref.height)
@@ -279,8 +279,10 @@ async def create_block():
assert_equal(len(block2.vtx), 1)
self.log.debug("Wait for another, but time out")
+ waitoptions.timeout = self.no_event_timeout_ms
template3 = await mining_wait_next_template(template2, stack, ctx, waitoptions)
assert template3 is None
+ waitoptions.timeout = self.default_ipc_timeout
self.log.debug("Wait for another, get one after increase in fees in the mempool")
template4 = await wait_and_do(
@@ -307,8 +309,10 @@ async def create_block():
assert_equal(len(block4.vtx), 3)
self.log.debug("Wait for another, but time out, since the fee threshold is set now")
+ waitoptions.timeout = self.no_event_timeout_ms
template7 = await mining_wait_next_template(template6, stack, ctx, waitoptions)
assert template7 is None
+ waitoptions.timeout = self.default_ipc_timeout
self.log.debug("interruptWait should abort the current wait")
async def wait_for_block():
@@ -800,6 +804,8 @@ def run_test(self):
self.miniwallet = MiniWallet(self.nodes[0])
# Amount of time in milliseconds the test is allowed to wait or be idle before it should fail.
self.default_ipc_timeout = 1000.0 * self.options.timeout_factor
+ # Expected timeout checks allow up to 5 seconds on slow CI runners.
+ self.no_event_timeout_ms = min(self.default_ipc_timeout, 5000.0)
self.default_block_create_options = self.capnp_modules['mining'].BlockCreateOptions()
self.default_block_wait_options = self.capnp_modules['mining'].BlockWaitOptions()
self.default_block_wait_options.timeout = self.default_ipc_timeout
### test/functional/p2p_node_network_limited.py
@@ -21,6 +21,7 @@
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
+ ensure_for,
try_rpc
)
@@ -138,12 +139,36 @@ def run_test(self):
# connect unsynced node 2 with pruned NODE_NETWORK_LIMITED peer
# because node 2 is in IBD and node 0 is a NODE_NETWORK_LIMITED peer, sync must not be possible
self.connect_nodes(0, 2)
- try:
- self.sync_blocks([self.nodes[0], self.nodes[2]], timeout=5)
- except Exception:
- pass
- # node2 must remain at height 0
- assert_equal(self.nodes[2].getblockheader(self.nodes[2].getbestblockhash())['height'], 0)
+ pruned_node = self.nodes[0]
+ full_node = self.nodes[2]
+ # Wait for headers and a ping roundtrip so the block request decision
+ # has had time to run before checking the negative case.
+ limited_tip = pruned_node.getbestblockhash()
+ self.wait_until(lambda: any(
+ tip["hash"] == limited_tip and tip["status"] == "headers-only"
+ for tip in full_node.getchaintips()
+ ))
+ peers = full_node.getpeerinfo()
+ assert_equal(len(peers), 1)
+ received_pongs = peers[0]["bytesrecv_per_msg"].get("pong", 0)
+ full_node.ping()
+ self.wait_until(lambda: full_node.getpeerinfo()[0]["bytesrecv_per_msg"].get("pong", 0) > received_pongs)
+
+ def no_block_request_from_limited_peer():
+ peers = full_node.getpeerinfo()
+ if len(peers) != 1:
+ return False
+ peer = peers[0]
+ return (
+ full_node.getblockcount() == 0
+ and peer["inflight"] == []
+ and peer["bytessent_per_msg"].get("getdata", 0) == 0
+ )
+
+ ensure_for(
+ duration=max(1.0, min(5.0, self.options.timeout_factor)),
+ f=no_block_request_from_limited_peer,
+ )
# now connect also to node 1 (non pruned)
self.connect_nodes(1, 2)Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.