Skip to content

Commit

Permalink
Add regression test to check for non-broadcast of accepted submitpack…
Browse files Browse the repository at this point in the history
…age txns
  • Loading branch information
instagibbs committed Nov 29, 2023
1 parent 4fb3340 commit 24c345f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/functional/rpc_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 24c345f

Please sign in to comment.