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.
This commit is contained in:
rkrux 2026-01-21 17:03:45 +05:30
parent 8c07800b19
commit 0aba464ce7
No known key found for this signature in database
GPG Key ID: 8614B8BD2E144C6D

View File

@ -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__)