test: switch order of error code and message check
What changed, and why it matters
This commit only changes the order of two checks inside a Bitcoin Core test helper. It makes no functional change to the Bitcoin software itself, does not affect live code, and has no security relevance. The change is intended to make debugging test failures easier by showing the error message before the error code in failure logs.
No action needed. This is a benign test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In test/functional/test_framework/util.py, the try_rpc helper was modified to check the JSON-RPC error message before checking the error code. Previously the code was checked first. This is purely a test-framework quality-of-life change; both checks still run, and the behavior of Bitcoin Core nodes is unaffected.
Changed components
test/functional/test_framework/util.pyInspect captured patch +3 / −3
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 0c190ee9..03ece6f0 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -165,13 +165,13 @@ def try_rpc(code, message, fun, *args, **kwds):
try:
fun(*args, **kwds)
except JSONRPCException as e:
- # JSONRPCException was thrown as expected. Check the code and message values are correct.
- if (code is not None) and (code != e.error["code"]):
- raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"])
+ # JSONRPCException was thrown as expected. Check the message and code values are correct.
if (message is not None) and (message not in e.error['message']):
raise AssertionError(
"Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format(
message, e.error['message']))
+ if (code is not None) and (code != e.error["code"]):
+ raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"])
return True
except Exception as e:
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
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.