mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
test: add rpc getaddressinfo labels test coverage
This commit is contained in:
@@ -29,6 +29,7 @@ from test_framework.util import (
|
||||
from test_framework.wallet_util import (
|
||||
get_key,
|
||||
get_multisig,
|
||||
labels_value,
|
||||
test_address,
|
||||
)
|
||||
|
||||
@@ -121,7 +122,7 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||
self.test_importmulti({"scriptPubKey": key.p2pkh_script,
|
||||
"timestamp": "now",
|
||||
"internal": True,
|
||||
"label": "Example label"},
|
||||
"label": "Unsuccessful labelling for internal addresses"},
|
||||
success=False,
|
||||
error_code=-8,
|
||||
error_message='Internal addresses should not have a label')
|
||||
@@ -550,7 +551,7 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||
self.log.info("Should not import a p2sh-p2wpkh address from descriptor without checksum and private key")
|
||||
self.test_importmulti({"desc": "sh(wpkh(" + key.pubkey + "))",
|
||||
"timestamp": "now",
|
||||
"label": "Descriptor import test",
|
||||
"label": "Unsuccessful P2SH-P2WPKH descriptor import",
|
||||
"keys": [key.privkey]},
|
||||
success=False,
|
||||
error_code=-5,
|
||||
@@ -558,17 +559,19 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||
|
||||
# Test importing of a P2SH-P2WPKH address via descriptor + private key
|
||||
key = get_key(self.nodes[0])
|
||||
p2sh_p2wpkh_label = "Successful P2SH-P2WPKH descriptor import"
|
||||
self.log.info("Should import a p2sh-p2wpkh address from descriptor and private key")
|
||||
self.test_importmulti({"desc": descsum_create("sh(wpkh(" + key.pubkey + "))"),
|
||||
"timestamp": "now",
|
||||
"label": "Descriptor import test",
|
||||
"label": p2sh_p2wpkh_label,
|
||||
"keys": [key.privkey]},
|
||||
success=True)
|
||||
test_address(self.nodes[1],
|
||||
key.p2sh_p2wpkh_addr,
|
||||
solvable=True,
|
||||
ismine=True,
|
||||
label="Descriptor import test")
|
||||
label=p2sh_p2wpkh_label,
|
||||
labels=labels_value(name=p2sh_p2wpkh_label))
|
||||
|
||||
# Test ranged descriptor fails if range is not specified
|
||||
xpriv = "tprv8ZgxMBicQKsPeuVhWwi6wuMQGfPKi9Li5GtX35jVNknACgqe3CY4g5xgkfDDJcmtF7o1QnxWDRYw4H5P26PXq7sbcUkEqeR4fg3Kxp2tigg"
|
||||
@@ -628,17 +631,19 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||
|
||||
# Test importing of a P2PKH address via descriptor
|
||||
key = get_key(self.nodes[0])
|
||||
p2pkh_label = "P2PKH descriptor import"
|
||||
self.log.info("Should import a p2pkh address from descriptor")
|
||||
self.test_importmulti({"desc": descsum_create("pkh(" + key.pubkey + ")"),
|
||||
"timestamp": "now",
|
||||
"label": "Descriptor import test"},
|
||||
"label": p2pkh_label},
|
||||
True,
|
||||
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
|
||||
test_address(self.nodes[1],
|
||||
key.p2pkh_addr,
|
||||
solvable=True,
|
||||
ismine=False,
|
||||
label="Descriptor import test")
|
||||
label=p2pkh_label,
|
||||
labels=labels_value(name=p2pkh_label))
|
||||
|
||||
# Test import fails if both desc and scriptPubKey are provided
|
||||
key = get_key(self.nodes[0])
|
||||
|
||||
Reference in New Issue
Block a user