mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Fix RPC failure testing (2 of 2)
Commit 9db8eecac1 improved the
assert_raises_jsonrpc() function for better testing of RPC failure
modes. This commit completes the job by removing remaining broken
try-except RPC testing from the individual test cases and replacing it
with calls to assert_raises_jsonrpc().
This commit is contained in:
@@ -28,11 +28,7 @@ class KeyPoolTest(BitcoinTestFramework):
|
||||
assert(addr_before_encrypting_data['hdmasterkeyid'] != wallet_info['hdmasterkeyid'])
|
||||
assert(addr_data['hdmasterkeyid'] == wallet_info['hdmasterkeyid'])
|
||||
|
||||
try:
|
||||
addr = nodes[0].getnewaddress()
|
||||
raise AssertionError('Keypool should be exhausted after one address')
|
||||
except JSONRPCException as e:
|
||||
assert(e.error['code']==-12)
|
||||
assert_raises_jsonrpc(-12, "Error: Keypool ran out, please call keypoolrefill first", nodes[0].getnewaddress)
|
||||
|
||||
# put three new keys in the keypool
|
||||
nodes[0].walletpassphrase('test', 12000)
|
||||
@@ -48,11 +44,7 @@ class KeyPoolTest(BitcoinTestFramework):
|
||||
# assert that four unique addresses were returned
|
||||
assert(len(addr) == 4)
|
||||
# the next one should fail
|
||||
try:
|
||||
addr = nodes[0].getrawchangeaddress()
|
||||
raise AssertionError('Keypool should be exhausted after three addresses')
|
||||
except JSONRPCException as e:
|
||||
assert(e.error['code']==-12)
|
||||
assert_raises_jsonrpc(-12, "Keypool ran out", nodes[0].getrawchangeaddress)
|
||||
|
||||
# refill keypool with three new addresses
|
||||
nodes[0].walletpassphrase('test', 1)
|
||||
@@ -66,11 +58,7 @@ class KeyPoolTest(BitcoinTestFramework):
|
||||
nodes[0].generate(1)
|
||||
nodes[0].generate(1)
|
||||
nodes[0].generate(1)
|
||||
try:
|
||||
nodes[0].generate(1)
|
||||
raise AssertionError('Keypool should be exhausted after three addesses')
|
||||
except JSONRPCException as e:
|
||||
assert(e.error['code']==-12)
|
||||
assert_raises_jsonrpc(-12, "Keypool ran out", nodes[0].generate, 1)
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
Reference in New Issue
Block a user