qa: Account for errno not always being set for ConnectionResetError
What changed, and why it matters
This is a small fix to Bitcoin Core's internal Python test framework. When a test talks to a running node and the connection is reset unexpectedly, Python's error object sometimes doesn't include a standard error number. The patch makes the test code treat that as a connection reset, so it can log and retry correctly instead of crashing the test run. It does not change the Bitcoin node itself, user wallets, consensus rules, or network behavior.
No security action required. Treat as a normal test-framework reliability improvement. Reviewers may optionally verify that the new ConnectionResetError branch is covered by existing functional tests that simulate node crashes or disconnects.
Security signals we found
No security signal: change is in test framework only
No remote attack surface introduced
No change to consensus, networking, wallet, or RPC server code
Evidence from the diff
The commit modifies test/functional/test_framework/test_node.py to handle OSError instances with errno=None. It extends the existing TimeoutError workaround (CPython issue 109601) to also cover ConnectionResetError, setting error_num to errno.ECONNRESET when the errno attribute is missing. This prevents the downstream if error_num not in [...] check from failing on a None value when http.client.RemoteDisconnected (a subclass of ConnectionResetError) is raised without an errno. The change is purely in QA/test infrastructure.
Changed components
test/functional/test_framework/test_node.pyInspect captured patch +9 / −4
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 4186cec5..06575a57 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -363,10 +363,15 @@ class TestNode():
latest_error = suppress_error(f"JSONRPCException {e.error['code']}", e)
except OSError as e:
error_num = e.errno
- # Work around issue where socket timeouts don't have errno set.
- # https://github.com/python/cpython/issues/109601
- if error_num is None and isinstance(e, TimeoutError):
- error_num = errno.ETIMEDOUT
+ if error_num is None:
+ # Work around issue where socket timeouts don't have errno set.
+ # https://github.com/python/cpython/issues/109601
+ if isinstance(e, TimeoutError):
+ error_num = errno.ETIMEDOUT
+ # http.client.RemoteDisconnected inherits from this type and
+ # doesn't specify errno.
+ elif isinstance(e, ConnectionResetError):
+ error_num = errno.ECONNRESET
# Suppress similarly to the above JSONRPCException errors.
if error_num not in [
Why this scored 19/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.