Skip to content

Commit

Permalink
test: add coverage for bech32m in wallet_keypool_topup
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoerg committed Nov 21, 2023
1 parent d752349 commit 345667d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/functional/wallet_keypool_topup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def add_options(self, parser):

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 = [[], ['-keypool=100'], ['-keypool=100'], ['-keypool=100'], ['-keypool=100']]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
Expand All @@ -40,12 +40,14 @@ def run_test(self):
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 in range(4):
self.connect_nodes(0, i + 1)

for i, output_type in enumerate(["legacy", "p2sh-segwit", "bech32"]):
addresses = ["legacy", "p2sh-segwit", "bech32"]
if self.options.descriptors:
addresses.append("bech32m")

for i, output_type in enumerate(addresses):
self.log.info("Generate keys for wallet with address type: {}".format(output_type))
idx = i+1
for _ in range(90):
Expand All @@ -59,9 +61,10 @@ def run_test(self):
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"]

else:
assert address_details["isscript"] and address_details["iswitness"]

self.log.info("Send funds to wallet")
self.nodes[0].sendtoaddress(addr_oldpool, 10)
Expand All @@ -87,6 +90,8 @@ def run_test(self):
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'")

Expand Down

0 comments on commit 345667d

Please sign in to comment.