aboutsummaryrefslogtreecommitdiff
path: root/test/functional/import-rescan.py
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-07-12 10:29:02 -0400
committerMarcoFalke <falke.marco@gmail.com>2017-11-01 10:40:09 -0400
commit5b728c8e98a4d3d72b1ca5f6ac287b453b0fb5d6 (patch)
treec4a4cd22c46b1d214a27f532bf4e39adc5d395aa /test/functional/import-rescan.py
parent34833534b656f565df9510a6c649687063db956d (diff)
downloadbitcoin-5b728c8e98a4d3d72b1ca5f6ac287b453b0fb5d6.tar.xz
[tests] remove direct testing on JSONRPCException from individual test cases
Github-Pull: #10853 Rebased-From: 5864e9c1611e6034a8d49b78231abe6bfade686d
Diffstat (limited to 'test/functional/import-rescan.py')
-rwxr-xr-xtest/functional/import-rescan.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/test/functional/import-rescan.py b/test/functional/import-rescan.py
index 02d7428120..c7eb07ab12 100755
--- a/test/functional/import-rescan.py
+++ b/test/functional/import-rescan.py
@@ -19,9 +19,8 @@ importing nodes pick up the new transactions regardless of whether rescans
happened previously.
"""
-from test_framework.authproxy import JSONRPCException
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import (connect_nodes, sync_blocks, assert_equal, set_node_times)
+from test_framework.util import (assert_raises_jsonrpc, connect_nodes, sync_blocks, assert_equal, set_node_times)
import collections
import enum
@@ -35,21 +34,26 @@ Rescan = enum.Enum("Rescan", "no yes late_timestamp")
class Variant(collections.namedtuple("Variant", "call data rescan prune")):
"""Helper for importing one key and verifying scanned transactions."""
+ def try_rpc(self, func, *args, **kwargs):
+ if self.expect_disabled:
+ assert_raises_jsonrpc(-4, "Rescan is disabled in pruned mode", func, *args, **kwargs)
+ else:
+ return func(*args, **kwargs)
+
def do_import(self, timestamp):
"""Call one key import RPC."""
if self.call == Call.single:
if self.data == Data.address:
- response, error = try_rpc(self.node.importaddress, self.address["address"], self.label,
- self.rescan == Rescan.yes)
+ response = self.try_rpc(self.node.importaddress, self.address["address"], self.label,
+ self.rescan == Rescan.yes)
elif self.data == Data.pub:
- response, error = try_rpc(self.node.importpubkey, self.address["pubkey"], self.label,
- self.rescan == Rescan.yes)
+ response = self.try_rpc(self.node.importpubkey, self.address["pubkey"], self.label,
+ self.rescan == Rescan.yes)
elif self.data == Data.priv:
- response, error = try_rpc(self.node.importprivkey, self.key, self.label, self.rescan == Rescan.yes)
+ response = self.try_rpc(self.node.importprivkey, self.key, self.label, self.rescan == Rescan.yes)
assert_equal(response, None)
- assert_equal(error, {'message': 'Rescan is disabled in pruned mode',
- 'code': -4} if self.expect_disabled else None)
+
elif self.call == Call.multi:
response = self.node.importmulti([{
"scriptPubKey": {
@@ -180,13 +184,5 @@ class ImportRescanTest(BitcoinTestFramework):
else:
variant.check()
-
-def try_rpc(func, *args, **kwargs):
- try:
- return func(*args, **kwargs), None
- except JSONRPCException as e:
- return None, e.error
-
-
if __name__ == "__main__":
ImportRescanTest().main()