@@ -1271,6 +1271,15 @@ void FuncProUpServInvalidNType(TestChainSetup& setup)
12711271 }
12721272}
12731273
1274+ // Adds entry to pool as AcceptToMemoryPool does, recording a provider transaction against the
1275+ // masternode list at pindex.
1276+ static void AddToMempool (CTxMemPool& pool, const CTxMemPoolEntry& entry, const CBlockIndex* pindex)
1277+ EXCLUSIVE_LOCKS_REQUIRED(::cs_main, pool.cs)
1278+ {
1279+ auto ancestors{pool.AssumeCalculateMemPoolAncestors (__func__, entry, CTxMemPool::Limits::NoLimits ())};
1280+ pool.addUnchecked (entry, ancestors, pindex);
1281+ }
1282+
12741283void FuncTestMempoolReorg (TestChainSetup& setup)
12751284{
12761285 auto & chainman = *Assert (setup.m_node .chainman .get ());
@@ -1315,7 +1324,7 @@ void FuncTestMempoolReorg(TestChainSetup& setup)
13151324
13161325 // Create ProUpServ and test block reorg which double-spend ProRegTx
13171326 auto tx_up_serv = CreateProUpServTx (chainman, utxos, tx_reg.GetHash (), operatorKey, 2 , CScript (), setup.coinbaseKey );
1318- testPool. addUnchecked ( entry.FromTx (tx_up_serv));
1327+ AddToMempool (testPool, entry.FromTx (tx_up_serv), chainman. ActiveChain (). Tip ( ));
13191328 // A disconnected block would insert ProRegTx back into mempool
13201329 testPool.addUnchecked (entry.FromTx (tx_reg));
13211330 BOOST_CHECK_EQUAL (testPool.size (), 2U );
@@ -1329,7 +1338,7 @@ void FuncTestMempoolReorg(TestChainSetup& setup)
13291338 // Check mempool as if a new block with tx_reg_ds was connected instead of the old one with tx_reg
13301339 std::vector<CTransactionRef> block_reorg;
13311340 block_reorg.emplace_back (std::make_shared<CTransaction>(tx_reg_ds));
1332- testPool.removeForBlock (block_reorg, nHeight + 2 );
1341+ testPool.removeForBlock (block_reorg, nHeight + 2 , chainman. ActiveChain (). Tip () );
13331342 BOOST_CHECK_EQUAL (testPool.size (), 0U );
13341343}
13351344
@@ -1397,13 +1406,13 @@ void FuncTestMempoolProTxKeyChangedConflictChain(TestChainSetup& setup)
13971406 TestMemPoolEntryHelper entry;
13981407 LOCK2 (cs_main, testPool.cs );
13991408
1400- testPool. addUnchecked ( entry.FromTx (tx_parent));
1401- testPool. addUnchecked ( entry.FromTx (tx_child));
1409+ AddToMempool (testPool, entry.FromTx (tx_parent), chainman. ActiveChain (). Tip ( ));
1410+ AddToMempool (testPool, entry.FromTx (tx_child), chainman. ActiveChain (). Tip ( ));
14021411 BOOST_CHECK_EQUAL (testPool.size (), 2U );
14031412
14041413 // Pre-fix this aborted the process instead of returning.
14051414 std::vector<CTransactionRef> block_txs{std::make_shared<CTransaction>(tx_revoke)};
1406- testPool.removeForBlock (block_txs, chainman.ActiveChain ().Height () + 1 );
1415+ testPool.removeForBlock (block_txs, chainman.ActiveChain ().Height () + 1 , chainman. ActiveChain (). Tip () );
14071416 BOOST_CHECK_EQUAL (testPool.size (), 0U );
14081417}
14091418
@@ -1440,7 +1449,7 @@ void FuncTestMempoolDualProregtx(TestChainSetup& setup)
14401449
14411450 testPool.addUnchecked (entry.FromTx (tx_reg1));
14421451 BOOST_CHECK_EQUAL (testPool.size (), 1U );
1443- BOOST_CHECK (testPool.existsProviderTxConflict (CTransaction (tx_reg2)));
1452+ BOOST_CHECK (testPool.existsProviderTxConflict (CTransaction (tx_reg2), chainman. ActiveChain (). Tip () ));
14441453}
14451454
14461455// A ProRegTx that reuses a confirmed external collateral replaces the live MN at block
@@ -1531,21 +1540,21 @@ void FuncTestMempoolProRegReplacementUpdateConflict(TestChainSetup& setup)
15311540 // Replacement already in mempool => update for the MN it replaces is a conflict.
15321541 testPool.addUnchecked (entry.FromTx (tx_reg_replace));
15331542 BOOST_CHECK_EQUAL (testPool.size (), 1U );
1534- BOOST_CHECK (testPool.existsProviderTxConflict (CTransaction (tx_up_serv)));
1543+ BOOST_CHECK (testPool.existsProviderTxConflict (CTransaction (tx_up_serv), tip_index () ));
15351544 testPool.removeRecursive (CTransaction (tx_reg_replace), MemPoolRemovalReason::MANUAL );
15361545 BOOST_CHECK_EQUAL (testPool.size (), 0U );
15371546
15381547 // Update already in mempool => replacement ProRegTx reusing that MN's collateral conflicts.
1539- testPool. addUnchecked ( entry.FromTx (tx_up_serv));
1548+ AddToMempool (testPool, entry.FromTx (tx_up_serv), tip_index ( ));
15401549 BOOST_CHECK_EQUAL (testPool.size (), 1U );
1541- BOOST_CHECK (testPool.existsProviderTxConflict (CTransaction (tx_reg_replace)));
1550+ BOOST_CHECK (testPool.existsProviderTxConflict (CTransaction (tx_reg_replace), tip_index () ));
15421551
15431552 // existsProviderTxConflict only gates our own acceptance; it cannot stop a miner from
15441553 // confirming the replacement. Once that block arrives, removeForBlock must evict the
15451554 // now-unmineable update, otherwise it lingers and stalls our own block assembly.
15461555 std::vector<CTransactionRef> connected{MakeTransactionRef (CMutableTransaction ()),
15471556 MakeTransactionRef (tx_reg_replace)};
1548- testPool.removeForBlock (connected, tip_height () + 1 );
1557+ testPool.removeForBlock (connected, tip_height () + 1 , tip_index () );
15491558 BOOST_CHECK_EQUAL (testPool.size (), 0U );
15501559 }
15511560
@@ -1569,20 +1578,21 @@ void FuncTestMempoolProRegReplacementUpdateConflict(TestChainSetup& setup)
15691578 LOCK2 (cs_main, testPool.cs );
15701579 // ProUpServ and ProUpRev are signed by the operator key, so they stay valid across a
15711580 // confirmed ProUpReg that keeps it, and across a spend of anything but the collateral.
1572- testPool.addUnchecked (entry.FromTx (tx_up_serv));
1573- testPool.addUnchecked (entry.FromTx (tx_up_rev));
1574- testPool.removeForBlock ({MakeTransactionRef (tx_up_reg), MakeTransactionRef (tx_spend_other)}, tip_height () + 1 );
1581+ AddToMempool (testPool, entry.FromTx (tx_up_serv), tip_index ());
1582+ AddToMempool (testPool, entry.FromTx (tx_up_rev), tip_index ());
1583+ testPool.removeForBlock ({MakeTransactionRef (tx_up_reg), MakeTransactionRef (tx_spend_other)}, tip_height () + 1 ,
1584+ tip_index ());
15751585 BOOST_CHECK_EQUAL (testPool.size (), 2U );
15761586
1577- testPool.removeForBlock ({MakeTransactionRef (tx_up_reg_new_key)}, tip_height () + 1 );
1587+ testPool.removeForBlock ({MakeTransactionRef (tx_up_reg_new_key)}, tip_height () + 1 , tip_index () );
15781588 BOOST_CHECK_EQUAL (testPool.size (), 0U );
15791589
15801590 // Spending the collateral removes the MN, and no update of any kind can be mined after that.
1581- testPool. addUnchecked ( entry.FromTx (tx_up_serv));
1582- testPool. addUnchecked ( entry.FromTx (tx_up_reg));
1583- testPool. addUnchecked ( entry.FromTx (tx_up_rev));
1591+ AddToMempool (testPool, entry.FromTx (tx_up_serv), tip_index ( ));
1592+ AddToMempool (testPool, entry.FromTx (tx_up_reg), tip_index ( ));
1593+ AddToMempool (testPool, entry.FromTx (tx_up_rev), tip_index ( ));
15841594 BOOST_CHECK_EQUAL (testPool.size (), 3U );
1585- testPool.removeForBlock ({MakeTransactionRef (tx_spend_collateral)}, tip_height () + 1 );
1595+ testPool.removeForBlock ({MakeTransactionRef (tx_spend_collateral)}, tip_height () + 1 , tip_index () );
15861596 BOOST_CHECK_EQUAL (testPool.size (), 0U );
15871597 }
15881598}
@@ -1599,7 +1609,7 @@ static std::map<uint256, size_t> TemplatePositions(TestChainSetup& setup,
15991609 {
16001610 LOCK2 (cs_main, mempool.cs );
16011611 for (const auto & [tx, fee] : txs) {
1602- mempool. addUnchecked ( entry.Fee (fee).FromTx (tx));
1612+ AddToMempool (mempool, entry.Fee (fee).FromTx (tx), chainman. ActiveChain (). Tip ( ));
16031613 }
16041614 }
16051615 node::BlockAssembler::Options options;
@@ -2993,7 +3003,7 @@ void FuncEvoNodeRegistrarRaiseNotMined(TestChainV24SignalBeforeV19Setup& setup)
29933003 TestMemPoolEntryHelper entry;
29943004 {
29953005 LOCK2 (cs_main, mempool.cs );
2996- mempool. addUnchecked ( entry.Fee (50000 ).Time (Now<NodeSeconds>()).FromTx (tx));
3006+ AddToMempool (mempool, entry.Fee (50000 ).Time (Now<NodeSeconds>()).FromTx (tx), chainman. ActiveChain (). Tip ( ));
29973007 BOOST_REQUIRE (mempool.exists (tx.GetHash ()));
29983008 }
29993009 const auto block_template = node::BlockAssembler{chainman.ActiveChainstate (), setup.m_node , &mempool}.CreateNewBlock (
0 commit comments