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 committed 2026-01-21 17:23:30 +05:30
1 parent 8c07800b19
commit 0aba464ce7
1 file changed
+3 -3
+3 -3
View File
@@ -165,13 +165,13 @@ def try_rpc(code, message, fun, *args, **kwds):
try: try:
fun(*args, **kwds) fun(*args, **kwds)
except JSONRPCException as e: except JSONRPCException as e:
# JSONRPCException was thrown as expected. Check the code and message values are correct. # JSONRPCException was thrown as expected. Check the message and code values are correct.
if (code is not None) and (code != e.error["code"]):
raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"])
if (message is not None) and (message not in e.error['message']): if (message is not None) and (message not in e.error['message']):
raise AssertionError( raise AssertionError(
"Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format( "Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format(
message, e.error['message'])) 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 return True
except Exception as e: except Exception as e:
raise AssertionError("Unexpected exception raised: " + type(e).__name__) raise AssertionError("Unexpected exception raised: " + type(e).__name__)