test: Avoid empty errmsg in JSONRPCException
What changed, and why it matters
This commit only changes test-framework helper code. It improves error messages shown when a Bitcoin RPC call fails during automated testing, so developers get more useful diagnostics instead of a blank message. It does not touch the live Bitcoin node software, wallet handling, consensus rules, or network code, so it cannot directly affect real users' funds or node security.
No security action needed. Treat as a normal test-framework cleanup commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies JSONRPCException in test/functional/test_framework/authproxy.py to stop formatting a possibly missing ‘message’/’code’ pair and instead stringify the whole rpc_error dict while appending the HTTP status. It also collapses a JSONRPCException-specific catch block in test_framework.py into the generic BaseException handler, relying on logging.exception to include exception details. These are test-only quality-of-life changes.
Changed components
test/functional/test_framework/authproxy.pytest/functional/test_framework/test_framework.pyInspect captured patch +4 / −9
diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py
index 9b2fc0f7..2d2c42b3 100644
--- a/test/functional/test_framework/authproxy.py
+++ b/test/functional/test_framework/authproxy.py
@@ -51,11 +51,7 @@ log = logging.getLogger("BitcoinRPC")
class JSONRPCException(Exception):
def __init__(self, rpc_error, http_status=None):
- try:
- errmsg = '%(message)s (%(code)i)' % rpc_error
- except (KeyError, TypeError):
- errmsg = ''
- super().__init__(errmsg)
+ super().__init__(f"{rpc_error} [http_status={http_status}]")
self.error = rpc_error
self.http_status = http_status
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 3ab351ae..7970da52 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -147,11 +147,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
except subprocess.CalledProcessError as e:
self.log.exception(f"Called Process failed with stdout='{e.stdout}'; stderr='{e.stderr}';")
self.success = TestStatus.FAILED
- except JSONRPCException as e:
- self.log.exception(f"Failure during setup: error={e.error}, http_status={e.http_status}")
- self.success = TestStatus.FAILED
except BaseException:
- self.log.exception("Unexpected exception")
+ # The `exception` log will add the exception info to the message.
+ # https://docs.python.org/3/library/logging.html#logging.exception
+ self.log.exception("Unexpected exception:")
self.success = TestStatus.FAILED
finally:
exit_code = self.shutdown()
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.