Skip to content

Commit a9a6d94

Browse files
author
MarcoFalke
committed
Merge #18888: test: Remove RPCOverloadWrapper boilerplate
faa26d3 test: Remove RPCOverloadWrapper boilerplate (MarcoFalke) Pull request description: There are too many wrappers in test_node already, so at least the code that implements the wrappers should be as minimal as possible. ACKs for top commit: laanwj: code review ACK faa26d3 Tree-SHA512: 94e593907de22187524e2445afb3101e40b3b599d4b4015aa8c6ca902d7586ff9daf520828759029d199a3af79e61b96b490a822a5a193ac7bf946beacb11a24
2 parents 51825ae + faa26d3 commit a9a6d94

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

test/functional/test_framework/test_node.py

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ def get_request(self, *args, **kwargs):
562562
def arg_to_cli(arg):
563563
if isinstance(arg, bool):
564564
return str(arg).lower()
565+
elif arg is None:
566+
return 'null'
565567
elif isinstance(arg, dict) or isinstance(arg, list):
566568
return json.dumps(arg, default=EncodeDecimal)
567569
else:
@@ -632,27 +634,13 @@ def __init__(self, rpc, cli=False, descriptors=False):
632634
def __getattr__(self, name):
633635
return getattr(self.rpc, name)
634636

635-
def createwallet(self, wallet_name, disable_private_keys=None, blank=None, passphrase=None, avoid_reuse=None, descriptors=None):
636-
if self.is_cli:
637-
if disable_private_keys is None:
638-
disable_private_keys = 'null'
639-
if blank is None:
640-
blank = 'null'
641-
if passphrase is None:
642-
passphrase = ''
643-
if avoid_reuse is None:
644-
avoid_reuse = 'null'
637+
def createwallet(self, wallet_name, disable_private_keys=None, blank=None, passphrase='', avoid_reuse=None, descriptors=None):
645638
if descriptors is None:
646639
descriptors = self.descriptors
647640
return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors)
648641

649642
def importprivkey(self, privkey, label=None, rescan=None):
650643
wallet_info = self.getwalletinfo()
651-
if self.is_cli:
652-
if label is None:
653-
label = 'null'
654-
if rescan is None:
655-
rescan = 'null'
656644
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
657645
return self.__getattr__('importprivkey')(privkey, label, rescan)
658646
desc = descsum_create('combo(' + privkey + ')')
@@ -667,11 +655,6 @@ def importprivkey(self, privkey, label=None, rescan=None):
667655

668656
def addmultisigaddress(self, nrequired, keys, label=None, address_type=None):
669657
wallet_info = self.getwalletinfo()
670-
if self.is_cli:
671-
if label is None:
672-
label = 'null'
673-
if address_type is None:
674-
address_type = 'null'
675658
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
676659
return self.__getattr__('addmultisigaddress')(nrequired, keys, label, address_type)
677660
cms = self.createmultisig(nrequired, keys, address_type)
@@ -687,11 +670,6 @@ def addmultisigaddress(self, nrequired, keys, label=None, address_type=None):
687670

688671
def importpubkey(self, pubkey, label=None, rescan=None):
689672
wallet_info = self.getwalletinfo()
690-
if self.is_cli:
691-
if label is None:
692-
label = 'null'
693-
if rescan is None:
694-
rescan = 'null'
695673
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
696674
return self.__getattr__('importpubkey')(pubkey, label, rescan)
697675
desc = descsum_create('combo(' + pubkey + ')')
@@ -706,13 +684,6 @@ def importpubkey(self, pubkey, label=None, rescan=None):
706684

707685
def importaddress(self, address, label=None, rescan=None, p2sh=None):
708686
wallet_info = self.getwalletinfo()
709-
if self.is_cli:
710-
if label is None:
711-
label = 'null'
712-
if rescan is None:
713-
rescan = 'null'
714-
if p2sh is None:
715-
p2sh = 'null'
716687
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
717688
return self.__getattr__('importaddress')(address, label, rescan, p2sh)
718689
is_hex = False

0 commit comments

Comments
 (0)