can expand this test case to be a little more interesting with a grandparent as well:
0diff --git a/test/functional/p2p_opportunistic_1p1c.py b/test/functional/p2p_opportunistic_1p1c.py
1index 00b94d1a71..8aa5b43a53 100755
2--- a/test/functional/p2p_opportunistic_1p1c.py
3+++ b/test/functional/p2p_opportunistic_1p1c.py
4@@ -62,18 +62,18 @@ class PackageRelayTest(BitcoinTestFramework):
5 "-datacarriersize=100000",
6 "-maxmempool=5",
7 ]]
8 self.supports_cli = False
9
10- def create_tx_below_mempoolminfee(self, wallet):
11+ def create_tx_below_mempoolminfee(self, wallet, utxo_to_spend=None):
12 """Create a 1-input 1sat/vB transaction using a confirmed UTXO. Decrement and use
13 self.sequence so that subsequent calls to this function result in unique transactions."""
14
15 self.sequence -= 1
16 assert_greater_than(self.nodes[0].getmempoolinfo()["mempoolminfee"], FEERATE_1SAT_VB)
17
18- return wallet.create_self_transfer(fee_rate=FEERATE_1SAT_VB, sequence=self.sequence, confirmed_only=True)
19+ 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/)
20 def test_basic_child_then_parent(self):
21 node = self.nodes[0]
22 self.log.info("Check that opportunistic 1p1c logic works when child is received before parent")
23@@ -341,34 +341,42 @@ class PackageRelayTest(BitcoinTestFramework): [@cleanup](/bitcoin-bitcoin/contributor/cleanup/)
24 def test_other_parent_in_mempool(self):
25 self.log.info("Check opportunistic 1p1c works even if child already has another parent in mempool")
26 node = self.nodes[0]
27
28+ # Grandparent will enter mempool by itself
29+ grandparent_high = self.wallet.create_self_transfer(fee_rate=FEERATE_1SAT_VB*10, confirmed_only=True)
30+
31 # This parent needs CPFP
32- parent_low = self.create_tx_below_mempoolminfee(self.wallet)
33+ parent_low = self.create_tx_below_mempoolminfee(self.wallet, utxo_to_spend=grandparent_high["new_utxo"])
34 # This parent does not need CPFP and can be submitted alone ahead of time
35 parent_high = self.wallet.create_self_transfer(fee_rate=FEERATE_1SAT_VB*10, confirmed_only=True)
36 child = self.wallet.create_self_transfer_multi(
37 utxos_to_spend=[parent_high["new_utxo"], parent_low["new_utxo"]],
38 fee_per_output=999*parent_low["tx"].get_vsize(),
39 )
40
41 peer_sender = node.add_outbound_p2p_connection(P2PInterface(), p2p_idx=1, connection_type="outbound-full-relay")
42
43- # 1. Send first parent which will be accepted.
44+ # 1. Send grandparent which will be accepted
45+ peer_sender.send_and_ping(msg_tx(grandparent_high["tx"]))
46+ assert grandparent_high["txid"] in node.getrawmempool()
47+
48+ # 2. Send first parent which will be accepted.
49 peer_sender.send_and_ping(msg_tx(parent_high["tx"]))
50 assert parent_high["txid"] in node.getrawmempool()
51
52- # 2. Send child.
53+ # 3. Send child.
54 peer_sender.send_and_ping(msg_tx(child["tx"]))
55
56- # 3. Node requests parent_low.
57+ # 4. Node requests parent_low.
58 parent_low_txid_int = int(parent_low["txid"], 16)
59 peer_sender.wait_for_getdata([parent_low_txid_int])
60 peer_sender.send_and_ping(msg_tx(parent_low["tx"]))
61
62 node_mempool = node.getrawmempool()
63+ assert grandparent_high["txid"] in node_mempool
64 assert parent_high["txid"] in node_mempool
65 assert parent_low["txid"] in node_mempool
66 assert child["txid"] in node_mempool
67
68 def run_test(self):