@ -19,9 +19,8 @@ importing nodes pick up the new transactions regardless of whether rescans
@@ -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")
@@ -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 ,
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 ,
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 " : {
@ -179,13 +183,5 @@ class ImportRescanTest(BitcoinTestFramework):
@@ -179,13 +183,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 ( )