mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +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:
@@ -30,19 +30,10 @@ class DisableWalletTest (BitcoinTestFramework):
|
||||
x = self.nodes[0].validateaddress('mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
|
||||
assert(x['isvalid'] == True)
|
||||
|
||||
# Checking mining to an address without a wallet
|
||||
try:
|
||||
self.nodes[0].generatetoaddress(1, 'mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
|
||||
except JSONRPCException as e:
|
||||
assert("Invalid address" not in e.error['message'])
|
||||
assert("ProcessNewBlock, block not accepted" not in e.error['message'])
|
||||
assert("Couldn't create new block" not in e.error['message'])
|
||||
|
||||
try:
|
||||
self.nodes[0].generatetoaddress(1, '3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
|
||||
raise AssertionError("Must not mine to invalid address!")
|
||||
except JSONRPCException as e:
|
||||
assert("Invalid address" in e.error['message'])
|
||||
# Checking mining to an address without a wallet. Generating to a valid address should succeed
|
||||
# but generating to an invalid address will fail.
|
||||
self.nodes[0].generatetoaddress(1, 'mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
|
||||
assert_raises_jsonrpc(-5, "Invalid address", self.nodes[0].generatetoaddress, 1, '3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
|
||||
|
||||
if __name__ == '__main__':
|
||||
DisableWalletTest ().main ()
|
||||
|
||||
Reference in New Issue
Block a user