Skip to content

Commit

Permalink
test: make sure keypool sizes do not change on getrawchangeaddress/…
Browse files Browse the repository at this point in the history
…`getnewaddress` failures
  • Loading branch information
UdjinM6 committed Feb 28, 2024
1 parent 367bb7a commit e073f1d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/functional/wallet_keypool.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,34 @@ def run_test(self):
nodes[0].getrawchangeaddress()
nodes[0].getrawchangeaddress()
nodes[0].getrawchangeaddress()
addr = set()
# remember keypool sizes
wi = nodes[0].getwalletinfo()
kp_size_before = [wi['keypoolsize_hd_internal'], wi['keypoolsize']]
# the next one should fail
assert_raises_rpc_error(-12, "Keypool ran out", nodes[0].getrawchangeaddress)
# check that keypool sizes did not change
wi = nodes[0].getwalletinfo()
kp_size_after = [wi['keypoolsize_hd_internal'], wi['keypoolsize']]
assert_equal(kp_size_before, kp_size_after)

# drain the external keys
addr = set()
addr.add(nodes[0].getnewaddress(address_type="bech32"))
addr.add(nodes[0].getnewaddress(address_type="bech32"))
addr.add(nodes[0].getnewaddress(address_type="bech32"))
addr.add(nodes[0].getnewaddress(address_type="bech32"))
addr.add(nodes[0].getnewaddress(address_type="bech32"))
addr.add(nodes[0].getnewaddress(address_type="bech32"))
assert len(addr) == 6
# remember keypool sizes
wi = nodes[0].getwalletinfo()
kp_size_before = [wi['keypoolsize_hd_internal'], wi['keypoolsize']]
# the next one should fail
assert_raises_rpc_error(-12, "Error: Keypool ran out, please call keypoolrefill first", nodes[0].getnewaddress)
# check that keypool sizes did not change
wi = nodes[0].getwalletinfo()
kp_size_after = [wi['keypoolsize_hd_internal'], wi['keypoolsize']]
assert_equal(kp_size_before, kp_size_after)

# refill keypool with three new addresses
nodes[0].walletpassphrase('test', 1)
Expand Down

0 comments on commit e073f1d

Please sign in to comment.