aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/rawtransactions.py
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-02-09 15:48:39 -0500
committerJohn Newbery <john@johnnewbery.com>2017-03-07 16:45:09 -0500
commitdab804c18a427901684ebe936b2069a97e04a268 (patch)
tree66c7c787b90e18241aa37b92087c2a834afb802e /qa/rpc-tests/rawtransactions.py
parenta012087667edb35a36f25ae06b42b1644d80e649 (diff)
downloadbitcoin-dab804c18a427901684ebe936b2069a97e04a268.tar.xz
Return correct error codes in fundrawtransaction().
The fundrawtransaction() RPC was returning misleading or incorrect error codes (for example RPC_INTERNAL_ERROR when funding the transaction failed). This commit fixes those error codes: - RPC_INTERNAL_ERROR should not be returned for application-level errors, only for genuine internal errors such as corrupted data. That error code has been replaced with RPC_WALLET_ERROR. This commit also updates the test cases to explicitly test the error code.
Diffstat (limited to 'qa/rpc-tests/rawtransactions.py')
-rwxr-xr-xqa/rpc-tests/rawtransactions.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/qa/rpc-tests/rawtransactions.py b/qa/rpc-tests/rawtransactions.py
index 5adef31207..0374d8984a 100755
--- a/qa/rpc-tests/rawtransactions.py
+++ b/qa/rpc-tests/rawtransactions.py
@@ -61,13 +61,8 @@ class RawTransactionsTest(BitcoinTestFramework):
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
rawtx = self.nodes[2].signrawtransaction(rawtx)
- try:
- rawtx = self.nodes[2].sendrawtransaction(rawtx['hex'])
- except JSONRPCException as e:
- assert("Missing inputs" in e.error['message'])
- else:
- assert(False)
-
+ # This will raise an exception since there are missing inputs
+ assert_raises_jsonrpc(-25, "Missing inputs", self.nodes[2].sendrawtransaction, rawtx['hex'])
#########################
# RAW TX MULTISIG TESTS #
@@ -161,13 +156,13 @@ class RawTransactionsTest(BitcoinTestFramework):
assert_equal(self.nodes[0].getrawtransaction(txHash, True)["hex"], rawTxSigned['hex'])
# 6. invalid parameters - supply txid and string "Flase"
- assert_raises(JSONRPCException, self.nodes[0].getrawtransaction, txHash, "Flase")
+ assert_raises_jsonrpc(-3,"Invalid type", self.nodes[0].getrawtransaction, txHash, "Flase")
# 7. invalid parameters - supply txid and empty array
- assert_raises(JSONRPCException, self.nodes[0].getrawtransaction, txHash, [])
+ assert_raises_jsonrpc(-3,"Invalid type", self.nodes[0].getrawtransaction, txHash, [])
# 8. invalid parameters - supply txid and empty dict
- assert_raises(JSONRPCException, self.nodes[0].getrawtransaction, txHash, {})
+ assert_raises_jsonrpc(-3,"Invalid type", self.nodes[0].getrawtransaction, txHash, {})
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 1000}]
outputs = { self.nodes[0].getnewaddress() : 1 }
@@ -175,13 +170,15 @@ class RawTransactionsTest(BitcoinTestFramework):
decrawtx= self.nodes[0].decoderawtransaction(rawtx)
assert_equal(decrawtx['vin'][0]['sequence'], 1000)
+ # 9. invalid parameters - sequence number out of range
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : -1}]
outputs = { self.nodes[0].getnewaddress() : 1 }
- assert_raises(JSONRPCException, self.nodes[0].createrawtransaction, inputs, outputs)
+ assert_raises_jsonrpc(-8, 'Invalid parameter, sequence number is out of range', self.nodes[0].createrawtransaction, inputs, outputs)
+ # 10. invalid parameters - sequence number out of range
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 4294967296}]
outputs = { self.nodes[0].getnewaddress() : 1 }
- assert_raises(JSONRPCException, self.nodes[0].createrawtransaction, inputs, outputs)
+ assert_raises_jsonrpc(-8, 'Invalid parameter, sequence number is out of range', self.nodes[0].createrawtransaction, inputs, outputs)
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 4294967294}]
outputs = { self.nodes[0].getnewaddress() : 1 }