aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/util.py
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-07-12 10:29:02 -0400
committerJohn Newbery <john@johnnewbery.com>2017-10-05 09:48:46 -0400
commit5864e9c1611e6034a8d49b78231abe6bfade686d (patch)
treee8cec4a64d53873002d7ab327e2cd026802bc49e /test/functional/test_framework/util.py
parente93fff1463ae906fc986bf98c3b118c82f171546 (diff)
downloadbitcoin-5864e9c1611e6034a8d49b78231abe6bfade686d.tar.xz
[tests] remove direct testing on JSONRPCException from individual test cases
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r--test/functional/test_framework/util.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 64966adb97..44d7e04a89 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -99,6 +99,13 @@ def assert_raises_jsonrpc(code, message, fun, *args, **kwds):
args*: positional arguments for the function.
kwds**: named arguments for the function.
"""
+ assert try_rpc(code, message, fun, *args, **kwds), "No exception raised"
+
+def try_rpc(code, message, fun, *args, **kwds):
+ """Tries to run an rpc command.
+
+ Test against error code and message if the rpc fails.
+ Returns whether a JSONRPCException was raised."""
try:
fun(*args, **kwds)
except JSONRPCException as e:
@@ -107,10 +114,11 @@ def assert_raises_jsonrpc(code, message, fun, *args, **kwds):
raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"])
if (message is not None) and (message not in e.error['message']):
raise AssertionError("Expected substring not found:" + e.error['message'])
+ return True
except Exception as e:
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
else:
- raise AssertionError("No exception raised")
+ return False
def assert_is_hex_string(string):
try: