Skip to content

Commit 979f598

Browse files
author
MarcoFalke
committed
Merge #12947: Wallet hd functional test speedup and clarification
6cba60a speed up wallet_hd.py and clarify/augment checks (Gregory Sanders) Pull request description: With `keypool=0` I see no reason to do 300 addresses and sends. (with --enable-debug) Before patch: real 1m10.412s user 0m49.772s sys 0m3.988s After: real 0m11.566s user 0m3.344s sys 0m4.648s Also added check, since I failed to understand that on startup the wallet already knows about funds by rescanning blocks newer than oldest key birthdate. Tree-SHA512: cf90f7fe6a437b8b7b1f0707464b9c06085233167826f1a12c3871684664d4d572e13f03e13a718e4537cac39713271c4ac3d9b983e10080b50647caf3cbe82d
2 parents 7c06171 + 6cba60a commit 979f598

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/functional/wallet_hd.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def run_test(self):
4848
# Also send funds to each add
4949
self.nodes[0].generate(101)
5050
hd_add = None
51-
num_hd_adds = 300
52-
for i in range(num_hd_adds):
51+
NUM_HD_ADDS = 10
52+
for i in range(NUM_HD_ADDS):
5353
hd_add = self.nodes[1].getnewaddress()
5454
hd_info = self.nodes[1].getaddressinfo(hd_add)
5555
assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(i)+"'")
@@ -65,7 +65,7 @@ def run_test(self):
6565
assert_equal(change_addrV["hdkeypath"], "m/0'/1'/1'") #second internal child key
6666

6767
self.sync_all()
68-
assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1)
68+
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1)
6969

7070
self.log.info("Restore backup ...")
7171
self.stop_node(1)
@@ -78,10 +78,10 @@ def run_test(self):
7878

7979
# Assert that derivation is deterministic
8080
hd_add_2 = None
81-
for _ in range(num_hd_adds):
81+
for i in range(NUM_HD_ADDS):
8282
hd_add_2 = self.nodes[1].getnewaddress()
8383
hd_info_2 = self.nodes[1].getaddressinfo(hd_add_2)
84-
assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/"+str(_)+"'")
84+
assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/"+str(i)+"'")
8585
assert_equal(hd_info_2["hdmasterkeyid"], masterkeyid)
8686
assert_equal(hd_add, hd_add_2)
8787
connect_nodes_bi(self.nodes, 0, 1)
@@ -90,7 +90,7 @@ def run_test(self):
9090
# Needs rescan
9191
self.stop_node(1)
9292
self.start_node(1, extra_args=self.extra_args[1] + ['-rescan'])
93-
assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1)
93+
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1)
9494

9595
# Try a RPC based rescan
9696
self.stop_node(1)
@@ -100,13 +100,15 @@ def run_test(self):
100100
self.start_node(1, extra_args=self.extra_args[1])
101101
connect_nodes_bi(self.nodes, 0, 1)
102102
self.sync_all()
103+
# Wallet automatically scans blocks older than key on startup
104+
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1)
103105
out = self.nodes[1].rescanblockchain(0, 1)
104106
assert_equal(out['start_height'], 0)
105107
assert_equal(out['stop_height'], 1)
106108
out = self.nodes[1].rescanblockchain()
107109
assert_equal(out['start_height'], 0)
108110
assert_equal(out['stop_height'], self.nodes[1].getblockcount())
109-
assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1)
111+
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1)
110112

111113
# send a tx and make sure its using the internal chain for the changeoutput
112114
txid = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1)

0 commit comments

Comments
 (0)