mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 04:12:36 -03:00
Merge #18888: test: Remove RPCOverloadWrapper boilerplate
faa26d3744
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 ACKfaa26d3744
Tree-SHA512: 94e593907de22187524e2445afb3101e40b3b599d4b4015aa8c6ca902d7586ff9daf520828759029d199a3af79e61b96b490a822a5a193ac7bf946beacb11a24
This commit is contained in:
commit
a9a6d946e4
1 changed files with 3 additions and 32 deletions
|
@ -562,6 +562,8 @@ class TestNodeCLIAttr:
|
||||||
def arg_to_cli(arg):
|
def arg_to_cli(arg):
|
||||||
if isinstance(arg, bool):
|
if isinstance(arg, bool):
|
||||||
return str(arg).lower()
|
return str(arg).lower()
|
||||||
|
elif arg is None:
|
||||||
|
return 'null'
|
||||||
elif isinstance(arg, dict) or isinstance(arg, list):
|
elif isinstance(arg, dict) or isinstance(arg, list):
|
||||||
return json.dumps(arg, default=EncodeDecimal)
|
return json.dumps(arg, default=EncodeDecimal)
|
||||||
else:
|
else:
|
||||||
|
@ -632,27 +634,13 @@ class RPCOverloadWrapper():
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return getattr(self.rpc, name)
|
return getattr(self.rpc, name)
|
||||||
|
|
||||||
def createwallet(self, wallet_name, disable_private_keys=None, blank=None, passphrase=None, avoid_reuse=None, descriptors=None):
|
def createwallet(self, wallet_name, disable_private_keys=None, blank=None, passphrase='', avoid_reuse=None, descriptors=None):
|
||||||
if self.is_cli:
|
|
||||||
if disable_private_keys is None:
|
|
||||||
disable_private_keys = 'null'
|
|
||||||
if blank is None:
|
|
||||||
blank = 'null'
|
|
||||||
if passphrase is None:
|
|
||||||
passphrase = ''
|
|
||||||
if avoid_reuse is None:
|
|
||||||
avoid_reuse = 'null'
|
|
||||||
if descriptors is None:
|
if descriptors is None:
|
||||||
descriptors = self.descriptors
|
descriptors = self.descriptors
|
||||||
return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors)
|
return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors)
|
||||||
|
|
||||||
def importprivkey(self, privkey, label=None, rescan=None):
|
def importprivkey(self, privkey, label=None, rescan=None):
|
||||||
wallet_info = self.getwalletinfo()
|
wallet_info = self.getwalletinfo()
|
||||||
if self.is_cli:
|
|
||||||
if label is None:
|
|
||||||
label = 'null'
|
|
||||||
if rescan is None:
|
|
||||||
rescan = 'null'
|
|
||||||
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
||||||
return self.__getattr__('importprivkey')(privkey, label, rescan)
|
return self.__getattr__('importprivkey')(privkey, label, rescan)
|
||||||
desc = descsum_create('combo(' + privkey + ')')
|
desc = descsum_create('combo(' + privkey + ')')
|
||||||
|
@ -667,11 +655,6 @@ class RPCOverloadWrapper():
|
||||||
|
|
||||||
def addmultisigaddress(self, nrequired, keys, label=None, address_type=None):
|
def addmultisigaddress(self, nrequired, keys, label=None, address_type=None):
|
||||||
wallet_info = self.getwalletinfo()
|
wallet_info = self.getwalletinfo()
|
||||||
if self.is_cli:
|
|
||||||
if label is None:
|
|
||||||
label = 'null'
|
|
||||||
if address_type is None:
|
|
||||||
address_type = 'null'
|
|
||||||
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
||||||
return self.__getattr__('addmultisigaddress')(nrequired, keys, label, address_type)
|
return self.__getattr__('addmultisigaddress')(nrequired, keys, label, address_type)
|
||||||
cms = self.createmultisig(nrequired, keys, address_type)
|
cms = self.createmultisig(nrequired, keys, address_type)
|
||||||
|
@ -687,11 +670,6 @@ class RPCOverloadWrapper():
|
||||||
|
|
||||||
def importpubkey(self, pubkey, label=None, rescan=None):
|
def importpubkey(self, pubkey, label=None, rescan=None):
|
||||||
wallet_info = self.getwalletinfo()
|
wallet_info = self.getwalletinfo()
|
||||||
if self.is_cli:
|
|
||||||
if label is None:
|
|
||||||
label = 'null'
|
|
||||||
if rescan is None:
|
|
||||||
rescan = 'null'
|
|
||||||
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
||||||
return self.__getattr__('importpubkey')(pubkey, label, rescan)
|
return self.__getattr__('importpubkey')(pubkey, label, rescan)
|
||||||
desc = descsum_create('combo(' + pubkey + ')')
|
desc = descsum_create('combo(' + pubkey + ')')
|
||||||
|
@ -706,13 +684,6 @@ class RPCOverloadWrapper():
|
||||||
|
|
||||||
def importaddress(self, address, label=None, rescan=None, p2sh=None):
|
def importaddress(self, address, label=None, rescan=None, p2sh=None):
|
||||||
wallet_info = self.getwalletinfo()
|
wallet_info = self.getwalletinfo()
|
||||||
if self.is_cli:
|
|
||||||
if label is None:
|
|
||||||
label = 'null'
|
|
||||||
if rescan is None:
|
|
||||||
rescan = 'null'
|
|
||||||
if p2sh is None:
|
|
||||||
p2sh = 'null'
|
|
||||||
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
||||||
return self.__getattr__('importaddress')(address, label, rescan, p2sh)
|
return self.__getattr__('importaddress')(address, label, rescan, p2sh)
|
||||||
is_hex = False
|
is_hex = False
|
||||||
|
|
Loading…
Reference in a new issue