Skip to content

Commit f9603ee

Browse files
committed
Add test for flushing keypool with newkeypool
1 parent 6f6f7bb commit f9603ee

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/functional/wallet_keypool.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ def run_test(self):
138138
assert_equal(wi['keypoolsize_hd_internal'], 100)
139139
assert_equal(wi['keypoolsize'], 100)
140140

141+
if not self.options.descriptors:
142+
# Check that newkeypool entirely flushes the keypool
143+
start_keypath = nodes[0].getaddressinfo(nodes[0].getnewaddress())['hdkeypath']
144+
nodes[0].newkeypool()
145+
end_keypath = nodes[0].getaddressinfo(nodes[0].getnewaddress())['hdkeypath']
146+
# The new keypath index should be 100 more than the old one
147+
keypath_prefix = start_keypath.rsplit('/', 1)[0]
148+
new_index = int(start_keypath.rsplit('/', 1)[1][:-1]) + 100
149+
assert_equal(end_keypath, keypath_prefix + '/' + str(new_index) + '\'')
150+
141151
# create a blank wallet
142152
nodes[0].createwallet(wallet_name='w2', blank=True, disable_private_keys=True)
143153
w2 = nodes[0].get_wallet_rpc('w2')

0 commit comments

Comments
 (0)