Merge bitcoin/bitcoin#28928: test: add coverage for bech32m in `wallet_keypool_topup`

a8bfc3dea1 test: add coverage for bech32m in `wallet_keypool_topup` (brunoerg)

Pull request description:

  0dcac51049 added coverage for all keypool addresses types in `wallet_keypool_topup` (4y ago). Now we have bech23m, so this PR adds it.

ACKs for top commit:
  achow101:
    ACK a8bfc3dea1
  marcofleon:
    ACK a8bfc3dea1. Definitely a more straightfoward addition to the test. Reviewed the code, built the PR branch and ran all functional tests without issues.
  furszy:
    utACK a8bfc3dea

Tree-SHA512: aa830b723a7a54b23744f9fb3cf5214452c4ffc8e3bbe0e8bd980bdf902e61c3dd2fd57361b82c5c0c5224aa0774158daf34b6b2188edda0a971f82111976051
pull/29728/head
Ava Chow 1 month ago
commit b44f9e4645
No known key found for this signature in database
GPG Key ID: 17565732E08E5E41

@ -25,8 +25,10 @@ class KeypoolRestoreTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 4
self.extra_args = [[], ['-keypool=100'], ['-keypool=100'], ['-keypool=100']]
self.num_nodes = 5
self.extra_args = [[]]
for _ in range(self.num_nodes - 1):
self.extra_args.append(['-keypool=100'])
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
@ -40,12 +42,13 @@ class KeypoolRestoreTest(BitcoinTestFramework):
self.stop_node(1)
shutil.copyfile(wallet_path, wallet_backup_path)
self.start_node(1, self.extra_args[1])
self.connect_nodes(0, 1)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
for i, output_type in enumerate(["legacy", "p2sh-segwit", "bech32"]):
for i in [1, 2, 3, 4]:
self.connect_nodes(0, i)
output_types = ["legacy", "p2sh-segwit", "bech32"]
if self.options.descriptors:
output_types.append("bech32m")
for i, output_type in enumerate(output_types):
self.log.info("Generate keys for wallet with address type: {}".format(output_type))
idx = i+1
for _ in range(90):
@ -59,9 +62,10 @@ class KeypoolRestoreTest(BitcoinTestFramework):
assert not address_details["isscript"] and not address_details["iswitness"]
elif i == 1:
assert address_details["isscript"] and not address_details["iswitness"]
else:
elif i == 2:
assert not address_details["isscript"] and address_details["iswitness"]
elif i == 3:
assert address_details["isscript"] and address_details["iswitness"]
self.log.info("Send funds to wallet")
self.nodes[0].sendtoaddress(addr_oldpool, 10)
@ -87,6 +91,8 @@ class KeypoolRestoreTest(BitcoinTestFramework):
assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/49h/1h/0h/0/110")
elif output_type == 'bech32':
assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/84h/1h/0h/0/110")
elif output_type == 'bech32m':
assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/86h/1h/0h/0/110")
else:
assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/0'/0'/110'")

Loading…
Cancel
Save