This PR adds coverage for this line https://github.com/bitcoin/bitcoin/blob/master/src/rpc/mempool.cpp#L996
If you run the following you will get no results for submitpackage
grep -nri "TX decode failed" ./test/functional
This PR adds coverage for this line https://github.com/bitcoin/bitcoin/blob/master/src/rpc/mempool.cpp#L996
If you run the following you will get no results for submitpackage
grep -nri "TX decode failed" ./test/functional
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31139.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | instagibbs, tdb3, rkrux, achow101 |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
376@@ -377,6 +377,10 @@ def test_submitpackage(self):
377 self.log.info("Submitpackage only allows packages of 1 child with its parents")
378 # Chain of 3 transactions has too many generations
379 legacy_pool = node.getrawmempool()
380+
381+ chain_hex_decode_failure = [t["hex"][:-1] + 'X' for t in self.wallet.create_self_transfer_chain(chain_length=2)]
376@@ -377,6 +377,9 @@ def test_submitpackage(self):
377 self.log.info("Submitpackage only allows packages of 1 child with its parents")
378 # Chain of 3 transactions has too many generations
379 legacy_pool = node.getrawmempool()
380+
381+ assert_raises_rpc_error(-22, "TX decode failed:", node.submitpackage, ["", ""])
382+
tACK 4bdb78cfe76414227b749674ed660f4972fb6eda
Make, functional tests successful. Left a small suggestion.
376@@ -377,6 +377,9 @@ def test_submitpackage(self):
377 self.log.info("Submitpackage only allows packages of 1 child with its parents")
378 # Chain of 3 transactions has too many generations
379 legacy_pool = node.getrawmempool()
380+
381+ assert_raises_rpc_error(-22, "TX decode failed:", node.submitpackage, ["", ""])
I don’t think just passing two empty strings is the right way of testing it because:
Ya that makes sense!
What I did in 34c6643
Is I used a proper hex value and then had the second value malformed so that we can cover more bases
let me know if that looks good to you I can modify it other ways aswell!
it only plays with non-hex values and do not exercise the hex parsing.
an empty string is valid hex, it’s just an invalid tx, no? If you want to test invalid hex that’s another thing.
if the first tx is invalid, the second one has no effect.
You need two transactions currently for it to get far enough to try and deserialize. I don’t really care which one(s) are valid except for ease of reading.
let me know if that looks good to you I can modify it other ways aswell!
imo having valid hex is a more realistic scenario, but coverage is coverage
ok I added an assert to check for txid
in getrawmempool
in 1fab1d6
let me know if that looks good to you!
380
381+
382 self.log.info("Submitpackage only allows packages of 1 child with its parents")
383 # Chain of 3 transactions has too many generations
384 legacy_pool = node.getrawmempool()
385+
LGTM, will ACK again once @instagibbs’s suggestion is also added.
🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/32095511448
Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
ACK 1fab1d601e40edc7296cf3d60a7e917b0e6493b3
Thanks for incorporating the changes.
368@@ -369,6 +369,13 @@ def test_submit_child_with_parents(self, num_parents, partial_submit):
369 def test_submitpackage(self):
370 node = self.nodes[0]
371
372+ self.log.info("Submitpackage only allows valid hex inputs")
373+ valid_tx_list = self.wallet.create_self_transfer_chain(chain_length=2)
374+ hex_list = [valid_tx_list[0]["hex"][:-1] + 'X', valid_tx_list[1]["hex"]]
375+ txid_list = [valid_tx_list[0]["txid"], valid_tx_list[1]["txid"]]
376+ assert_raises_rpc_error(-22, "TX decode failed:", node.submitpackage, hex_list)
377+ assert txid_list[0] not in node.getrawmempool()
0 assert txid_list[0] not in node.getrawmempool()
1 assert txid_list[1] not in node.getrawmempool()
Thanks!
Updated in d7fd766feb2f579bdba0e778bacdeb13103e8282
ACK 1fab1d601e40edc7296cf3d60a7e917b0e6493b3
with minor suggestion
368@@ -369,6 +369,14 @@ def test_submit_child_with_parents(self, num_parents, partial_submit):
369 def test_submitpackage(self):
370 node = self.nodes[0]
371
372+ self.log.info("Submitpackage only allows valid hex inputs")
373+ valid_tx_list = self.wallet.create_self_transfer_chain(chain_length=2)
374+ hex_list = [valid_tx_list[0]["hex"][:-1] + 'X', valid_tx_list[1]["hex"]]
375+ txid_list = [valid_tx_list[0]["txid"], valid_tx_list[1]["txid"]]
376+ assert_raises_rpc_error(-22, "TX decode failed:", node.submitpackage, hex_list)
Induced failure with:
0- hex_list = [valid_tx_list[0]["hex"][:-1] + 'X', valid_tx_list[1]["hex"]]
1+ hex_list = [valid_tx_list[0]["hex"], valid_tx_list[1]["hex"]]
Also verified that the not in node.getrawmempool()
asserts also fail, e.g.
0 self.log.info("Submitpackage only allows valid hex inputs")
1 valid_tx_list = self.wallet.create_self_transfer_chain(chain_length=2)
2- hex_list = [valid_tx_list[0]["hex"][:-1] + 'X', valid_tx_list[1]["hex"]]
3+ hex_list = [valid_tx_list[0]["hex"], valid_tx_list[1]["hex"]]
4 txid_list = [valid_tx_list[0]["txid"], valid_tx_list[1]["txid"]]
5- assert_raises_rpc_error(-22, "TX decode failed:", node.submitpackage, hex_list)
6- assert txid_list[0] not in node.getrawmempool()
7+ node.submitpackage(hex_list)
8+ #assert_raises_rpc_error(-22, "TX decode failed:", node.submitpackage, hex_list)
9+ #assert txid_list[0] not in node.getrawmempool()
10 assert txid_list[1] not in node.getrawmempool()
ACK d7fd766feb2f579bdba0e778bacdeb13103e8282
Looks good, thanks. corecheck.dev shows the added coverage for mempool.cpp. Ran a few quick sanity checks.