@@ -48,8 +48,8 @@ def run_test(self):
48
48
# Also send funds to each add
49
49
self .nodes [0 ].generate (101 )
50
50
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 ):
53
53
hd_add = self .nodes [1 ].getnewaddress ()
54
54
hd_info = self .nodes [1 ].getaddressinfo (hd_add )
55
55
assert_equal (hd_info ["hdkeypath" ], "m/0'/0'/" + str (i )+ "'" )
@@ -65,7 +65,7 @@ def run_test(self):
65
65
assert_equal (change_addrV ["hdkeypath" ], "m/0'/1'/1'" ) #second internal child key
66
66
67
67
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 )
69
69
70
70
self .log .info ("Restore backup ..." )
71
71
self .stop_node (1 )
@@ -78,10 +78,10 @@ def run_test(self):
78
78
79
79
# Assert that derivation is deterministic
80
80
hd_add_2 = None
81
- for _ in range (num_hd_adds ):
81
+ for i in range (NUM_HD_ADDS ):
82
82
hd_add_2 = self .nodes [1 ].getnewaddress ()
83
83
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 )+ "'" )
85
85
assert_equal (hd_info_2 ["hdmasterkeyid" ], masterkeyid )
86
86
assert_equal (hd_add , hd_add_2 )
87
87
connect_nodes_bi (self .nodes , 0 , 1 )
@@ -90,7 +90,7 @@ def run_test(self):
90
90
# Needs rescan
91
91
self .stop_node (1 )
92
92
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 )
94
94
95
95
# Try a RPC based rescan
96
96
self .stop_node (1 )
@@ -100,13 +100,15 @@ def run_test(self):
100
100
self .start_node (1 , extra_args = self .extra_args [1 ])
101
101
connect_nodes_bi (self .nodes , 0 , 1 )
102
102
self .sync_all ()
103
+ # Wallet automatically scans blocks older than key on startup
104
+ assert_equal (self .nodes [1 ].getbalance (), NUM_HD_ADDS + 1 )
103
105
out = self .nodes [1 ].rescanblockchain (0 , 1 )
104
106
assert_equal (out ['start_height' ], 0 )
105
107
assert_equal (out ['stop_height' ], 1 )
106
108
out = self .nodes [1 ].rescanblockchain ()
107
109
assert_equal (out ['start_height' ], 0 )
108
110
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 )
110
112
111
113
# send a tx and make sure its using the internal chain for the changeoutput
112
114
txid = self .nodes [1 ].sendtoaddress (self .nodes [0 ].getnewaddress (), 1 )
0 commit comments