From 0aba464ce76522f1be3bb9e471b45438738de492 Mon Sep 17 00:00:00 2001 From: rkrux Date: Wed, 21 Jan 2026 17:03:45 +0530 Subject: [PATCH] test: switch order of error code and message check I feel it'd be easier to debug intermittent test failures if the error message is present in the logs instead of error code. So, switching order of error code and message in the `try_rpc` function to aid error debugging. --- test/functional/test_framework/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 0c190ee936b..03ece6f064a 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__)