diff options
| author | John Newbery <[email protected]> | 2017-03-07 14:08:59 -0500 |
|---|---|---|
| committer | John Newbery <[email protected]> | 2017-03-15 11:56:25 -0400 |
| commit | c9bd0f64212cd600daf30c9c59035bfe9f07b81b (patch) | |
| tree | 9f587fadcbbd92fb983a770af4a1cf5084bc8b01 /qa/rpc-tests/keypool.py | |
| parent | Merge #9481: [Qt] Show more significant warning if we fall back to the defaul... (diff) | |
| download | discoin-c9bd0f64212cd600daf30c9c59035bfe9f07b81b.tar.xz discoin-c9bd0f64212cd600daf30c9c59035bfe9f07b81b.zip | |
Fix RPC failure testing (2 of 2)
Commit 9db8eecac1c713c760c0217b6acb7455c657fa8b 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().
Diffstat (limited to 'qa/rpc-tests/keypool.py')
| -rwxr-xr-x | qa/rpc-tests/keypool.py | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/qa/rpc-tests/keypool.py b/qa/rpc-tests/keypool.py index 4b9936a1f..cee58563f 100755 --- a/qa/rpc-tests/keypool.py +++ b/qa/rpc-tests/keypool.py @@ -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__() |