test: Scale NetworkThread close timeout with timeout_factor
What changed, and why it matters
This commit only changes Bitcoin Core's internal test framework. It makes the network cleanup timeout scale with a test-configurable slowdown factor, so slow test environments don't falsely fail. There is no change to production Bitcoin node code, no user-facing behavior, and no security issue.
No security action needed. Treat as ordinary test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes the default timeout=10 argument from NetworkThread.close() in test/functional/test_framework/p2p.py and instead passes timeout=self.options.timeout_factor * 10 from BitcoinTestFramework in test/functional/test_framework/test_framework.py. This is a test-only reliability fix to prevent flaky functional tests under --timeout-factor slowdowns.
Changed components
test/functional/test_framework/p2p.pytest/functional/test_framework/test_framework.pyInspect captured patch +2 / −2
diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
index 986eaf1e..f8e030ad 100755
--- a/test/functional/test_framework/p2p.py
+++ b/test/functional/test_framework/p2p.py
@@ -743,7 +743,7 @@ class NetworkThread(threading.Thread):
"""Start the network thread."""
self.network_event_loop.run_forever()
- def close(self, *, timeout=10):
+ def close(self, *, timeout):
"""Close the connections and network event loop."""
self.network_event_loop.call_soon_threadsafe(self.network_event_loop.stop)
wait_until_helper_internal(lambda: not self.network_event_loop.is_running(), timeout=timeout)
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index ecc9ffa2..1f957564 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -278,7 +278,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
pdb.set_trace()
self.log.debug('Closing down network thread')
- self.network_thread.close()
+ self.network_thread.close(timeout=self.options.timeout_factor * 10)
if self.success == TestStatus.FAILED:
self.log.info("Not stopping nodes as test failed. The dangling processes will be cleaned up later.")
else:
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.