can expand this test case to be a little more interesting with a grandparent as well:
diff --git a/test/functional/p2p_opportunistic_1p1c.py b/test/functional/p2p_opportunistic_1p1c.py
index 00b94d1a71..8aa5b43a53 100755
--- a/test/functional/p2p_opportunistic_1p1c.py
+++ b/test/functional/p2p_opportunistic_1p1c.py
@@ -62,18 +62,18 @@ class PackageRelayTest(BitcoinTestFramework):
"-datacarriersize=100000",
"-maxmempool=5",
]]
self.supports_cli = False
- def create_tx_below_mempoolminfee(self, wallet):
+ def create_tx_below_mempoolminfee(self, wallet, utxo_to_spend=None):
"""Create a 1-input 1sat/vB transaction using a confirmed UTXO. Decrement and use
self.sequence so that subsequent calls to this function result in unique transactions."""
self.sequence -= 1
assert_greater_than(self.nodes[0].getmempoolinfo()["mempoolminfee"], FEERATE_1SAT_VB)
- return wallet.create_self_transfer(fee_rate=FEERATE_1SAT_VB, sequence=self.sequence, confirmed_only=True)
+ return wallet.create_self_transfer(fee_rate=FEERATE_1SAT_VB, sequence=self.sequence, utxo_to_spend=utxo_to_spend, confirmed_only=True) [@cleanup](/bitcoin-bitcoin/contributor/cleanup/)
def test_basic_child_then_parent(self):
node = self.nodes[0]
self.log.info("Check that opportunistic 1p1c logic works when child is received before parent")
@@ -341,34 +341,42 @@ class PackageRelayTest(BitcoinTestFramework): [@cleanup](/bitcoin-bitcoin/contributor/cleanup/)
def test_other_parent_in_mempool(self):
self.log.info("Check opportunistic 1p1c works even if child already has another parent in mempool")
node = self.nodes[0]
+ # Grandparent will enter mempool by itself
+ grandparent_high = self.wallet.create_self_transfer(fee_rate=FEERATE_1SAT_VB*10, confirmed_only=True)
+
# This parent needs CPFP
- parent_low = self.create_tx_below_mempoolminfee(self.wallet)
+ parent_low = self.create_tx_below_mempoolminfee(self.wallet, utxo_to_spend=grandparent_high["new_utxo"])
# This parent does not need CPFP and can be submitted alone ahead of time
parent_high = self.wallet.create_self_transfer(fee_rate=FEERATE_1SAT_VB*10, confirmed_only=True)
child = self.wallet.create_self_transfer_multi(
utxos_to_spend=[parent_high["new_utxo"], parent_low["new_utxo"]],
fee_per_output=999*parent_low["tx"].get_vsize(),
)
peer_sender = node.add_outbound_p2p_connection(P2PInterface(), p2p_idx=1, connection_type="outbound-full-relay")
- # 1. Send first parent which will be accepted.
+ # 1. Send grandparent which will be accepted
+ peer_sender.send_and_ping(msg_tx(grandparent_high["tx"]))
+ assert grandparent_high["txid"] in node.getrawmempool()
+
+ # 2. Send first parent which will be accepted.
peer_sender.send_and_ping(msg_tx(parent_high["tx"]))
assert parent_high["txid"] in node.getrawmempool()
- # 2. Send child.
+ # 3. Send child.
peer_sender.send_and_ping(msg_tx(child["tx"]))
- # 3. Node requests parent_low.
+ # 4. Node requests parent_low.
parent_low_txid_int = int(parent_low["txid"], 16)
peer_sender.wait_for_getdata([parent_low_txid_int])
peer_sender.send_and_ping(msg_tx(parent_low["tx"]))
node_mempool = node.getrawmempool()
+ assert grandparent_high["txid"] in node_mempool
assert parent_high["txid"] in node_mempool
assert parent_low["txid"] in node_mempool
assert child["txid"] in node_mempool
def run_test(self):