mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-15 16:38:23 +01:00
test: add chained 1p1c propagation test
This commit is contained in:
@@ -82,6 +82,7 @@ class RPCPackagesTest(BitcoinTestFramework):
|
||||
self.independent_txns_testres_blank = [{
|
||||
"txid": res["txid"], "wtxid": res["wtxid"]} for res in self.independent_txns_testres]
|
||||
|
||||
self.test_submitpackage_with_ancestors()
|
||||
self.test_independent(coin)
|
||||
self.test_chain()
|
||||
self.test_multiple_children()
|
||||
@@ -501,5 +502,40 @@ class RPCPackagesTest(BitcoinTestFramework):
|
||||
assert_equal(pkg_result["tx-results"][tx.wtxid_hex]["error"], "scriptpubkey")
|
||||
assert_equal(node.getrawmempool(), [chained_txns_burn[0]["txid"]])
|
||||
|
||||
def test_submitpackage_with_ancestors(self):
|
||||
self.log.info("Test that submitpackage can send a package that has in-mempool ancestors")
|
||||
node = self.nodes[0]
|
||||
peer = node.add_p2p_connection(P2PTxInvStore())
|
||||
|
||||
parent_tx = self.wallet.create_self_transfer()
|
||||
child_tx = self.wallet.create_self_transfer(utxo_to_spend=parent_tx["new_utxo"])
|
||||
grandchild_tx = self.wallet.create_self_transfer(utxo_to_spend=child_tx["new_utxo"])
|
||||
ggrandchild_tx = self.wallet.create_self_transfer(utxo_to_spend=grandchild_tx["new_utxo"])
|
||||
|
||||
# Submitting them all together doesn't work, as the topology is not child-with-parents
|
||||
assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, [parent_tx["hex"], child_tx["hex"], grandchild_tx["hex"], ggrandchild_tx["hex"]])
|
||||
|
||||
# Submit older package and check acceptance
|
||||
result_submit_older = node.submitpackage(package=[parent_tx["hex"], child_tx["hex"]])
|
||||
assert_equal(result_submit_older["package_msg"], "success")
|
||||
mempool = node.getrawmempool()
|
||||
assert parent_tx["txid"] in mempool
|
||||
assert child_tx["txid"] in mempool
|
||||
|
||||
# Submit younger package and check acceptance
|
||||
result_submit_younger = node.submitpackage(package=[grandchild_tx["hex"], ggrandchild_tx["hex"]])
|
||||
assert_equal(result_submit_younger["package_msg"], "success")
|
||||
mempool = node.getrawmempool()
|
||||
|
||||
assert parent_tx["txid"] in mempool
|
||||
assert child_tx["txid"] in mempool
|
||||
assert grandchild_tx["txid"] in mempool
|
||||
assert ggrandchild_tx["txid"] in mempool
|
||||
|
||||
# The node should announce each transaction.
|
||||
peer.wait_for_broadcast([tx["tx"].wtxid_hex for tx in [parent_tx, child_tx, grandchild_tx, ggrandchild_tx]])
|
||||
self.generate(node, 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
RPCPackagesTest(__file__).main()
|
||||
|
||||
Reference in New Issue
Block a user