From 24c345f89ecad54223e42f8cf084ef3c5ed5f0c0 Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Wed, 29 Nov 2023 09:50:37 -0500 Subject: [PATCH] Add regression test to check for non-broadcast of accepted submitpackage txns --- test/functional/rpc_packages.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/functional/rpc_packages.py b/test/functional/rpc_packages.py index 6507f6267b96d7..6995008312386d 100755 --- a/test/functional/rpc_packages.py +++ b/test/functional/rpc_packages.py @@ -340,6 +340,21 @@ def test_submitpackage(self): assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, chain_hex) assert_equal(legacy_pool, node.getrawmempool()) + # Create a transaction chain such as only the parent gets accepted (by making the child's + # version non-standard). Make sure the parent does get broadcast. + self.log.info("If a package is partially submitted, transactions included in mempool get broadcast") + peer = node.add_p2p_connection(P2PTxInvStore()) + txs = self.wallet.create_self_transfer_chain(chain_length=2) + bad_child = tx_from_hex(txs[1]["hex"]) + bad_child.nVersion = -1 + hex_partial_acceptance = [txs[0]["hex"], bad_child.serialize().hex()] + res = node.submitpackage(hex_partial_acceptance) + assert_equal(res["package_msg"], "transaction failed") + first_wtxid = txs[0]["tx"].getwtxid() + assert "error" not in res["tx-results"][first_wtxid] + sec_wtxid = next(wtxid for wtxid in res["tx-results"] if wtxid != first_wtxid) + assert_equal(res["tx-results"][sec_wtxid]["error"], "version") + peer.wait_for_broadcast([first_wtxid]) if __name__ == "__main__": RPCPackagesTest().main()