-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC: Improve error messages on RPC endpoints that use GetTransaction #13144
Changes from all commits
0f5c476
6d787d4
ac35351
8f3efeb
12c4386
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ class RawTransactionsTest(BitcoinTestFramework): | |
def set_test_params(self): | ||
self.setup_clean_chain = True | ||
self.num_nodes = 3 | ||
self.extra_args = [["-addresstype=legacy"], ["-addresstype=legacy"], ["-addresstype=legacy"]] | ||
self.extra_args = [["-addresstype=legacy"], ["-addresstype=legacy"], ["-addresstype=legacy", "-txindex"]] | ||
|
||
def setup_network(self, split=False): | ||
super().setup_network() | ||
|
@@ -231,6 +231,28 @@ def run_test(self): | |
self.nodes[0].reconsiderblock(block1) | ||
assert_equal(self.nodes[0].getbestblockhash(), block2) | ||
|
||
# Create new transaction and don't broadcast. | ||
to_address = self.nodes[0].getnewaddress() | ||
prevout_index = [i for i, out in enumerate(gottx['vout']) if out['value'] == 1][0] | ||
inputs = [{"txid": tx, "vout": prevout_index}] | ||
outputs = {to_address: 0.9999} | ||
spending_rawtx = self.nodes[1].createrawtransaction(inputs, outputs) | ||
spending_tx = self.nodes[1].signrawtransactionwithwallet(spending_rawtx)['hex'] | ||
spending_txid = bytes_to_hex_str(hash256(hex_str_to_bytes(spending_tx))) | ||
|
||
# Searching unknown transaction without -txindex. | ||
assert_raises_rpc_error(-33, "No such mempool transaction. Use -txindex to enable blockchain transaction queries.", self.nodes[1].getrawtransaction, spending_txid) | ||
|
||
# Searching unknown transaction with txindex. | ||
assert_raises_rpc_error(-5, "No such mempool or blockchain transaction.", self.nodes[2].getrawtransaction, spending_txid) | ||
|
||
# Broadcast transaction to mempool. | ||
self.nodes[0].sendrawtransaction(spending_tx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this could be removed (lines 193 to 200), does't test error messages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of the assertion on line 199 is to test that the error received on 192 goes away after transaction is in the mempool. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, a comment there would be nice then, like: # No error should be raised now that the transaction is known. |
||
self.sync_all() | ||
|
||
gottx = self.nodes[2].getrawtransaction(spending_txid, True) | ||
assert_equal(gottx['txid'], spending_txid) | ||
|
||
######################### | ||
# RAW TX MULTISIG TESTS # | ||
######################### | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F841 local variable 'prevout_index' is assigned to but never used