Skip to content

Commit e073f1d

Browse files
committed
test: make sure keypool sizes do not change on getrawchangeaddress/getnewaddress failures
1 parent 367bb7a commit e073f1d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/functional/wallet_keypool.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,34 @@ def run_test(self):
103103
nodes[0].getrawchangeaddress()
104104
nodes[0].getrawchangeaddress()
105105
nodes[0].getrawchangeaddress()
106-
addr = set()
106+
# remember keypool sizes
107+
wi = nodes[0].getwalletinfo()
108+
kp_size_before = [wi['keypoolsize_hd_internal'], wi['keypoolsize']]
107109
# the next one should fail
108110
assert_raises_rpc_error(-12, "Keypool ran out", nodes[0].getrawchangeaddress)
111+
# check that keypool sizes did not change
112+
wi = nodes[0].getwalletinfo()
113+
kp_size_after = [wi['keypoolsize_hd_internal'], wi['keypoolsize']]
114+
assert_equal(kp_size_before, kp_size_after)
109115

110116
# drain the external keys
117+
addr = set()
111118
addr.add(nodes[0].getnewaddress(address_type="bech32"))
112119
addr.add(nodes[0].getnewaddress(address_type="bech32"))
113120
addr.add(nodes[0].getnewaddress(address_type="bech32"))
114121
addr.add(nodes[0].getnewaddress(address_type="bech32"))
115122
addr.add(nodes[0].getnewaddress(address_type="bech32"))
116123
addr.add(nodes[0].getnewaddress(address_type="bech32"))
117124
assert len(addr) == 6
125+
# remember keypool sizes
126+
wi = nodes[0].getwalletinfo()
127+
kp_size_before = [wi['keypoolsize_hd_internal'], wi['keypoolsize']]
118128
# the next one should fail
119129
assert_raises_rpc_error(-12, "Error: Keypool ran out, please call keypoolrefill first", nodes[0].getnewaddress)
130+
# check that keypool sizes did not change
131+
wi = nodes[0].getwalletinfo()
132+
kp_size_after = [wi['keypoolsize_hd_internal'], wi['keypoolsize']]
133+
assert_equal(kp_size_before, kp_size_after)
120134

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

0 commit comments

Comments
 (0)