Skip to content

Commit 86e732d

Browse files
committed
scripted-diff: test: Use CTxMemPool in TestingSetup
After this commit, there should be no explicit instantiation of CTxMemPool in src/test other than those in fuzz/ and setup_common -BEGIN VERIFY SCRIPT- find_regex="CTxMemPool\s+([^;({]+)(|\(\)|\{\});" \ && git grep -l -E "$find_regex" -- src/test \ | grep -v -e "^src/test/util/setup_common.cpp$" \ -e "^src/test/fuzz/" \ | xargs sed -i -E "s@$find_regex@CTxMemPool\& \1 = *Assert(m_node.mempool);@g" -END VERIFY SCRIPT-
1 parent 213457e commit 86e732d

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/test/blockencodings_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ constexpr long SHARED_TX_OFFSET{3};
5454

5555
BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
5656
{
57-
CTxMemPool pool;
57+
CTxMemPool& pool = *Assert(m_node.mempool);
5858
TestMemPoolEntryHelper entry;
5959
CBlock block(BuildBlockTestCase());
6060

@@ -137,7 +137,7 @@ class TestHeaderAndShortIDs {
137137

138138
BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
139139
{
140-
CTxMemPool pool;
140+
CTxMemPool& pool = *Assert(m_node.mempool);
141141
TestMemPoolEntryHelper entry;
142142
CBlock block(BuildBlockTestCase());
143143

@@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
207207

208208
BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
209209
{
210-
CTxMemPool pool;
210+
CTxMemPool& pool = *Assert(m_node.mempool);
211211
TestMemPoolEntryHelper entry;
212212
CBlock block(BuildBlockTestCase());
213213

@@ -258,7 +258,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
258258

259259
BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest)
260260
{
261-
CTxMemPool pool;
261+
CTxMemPool& pool = *Assert(m_node.mempool);
262262
CMutableTransaction coinbase;
263263
coinbase.vin.resize(1);
264264
coinbase.vin[0].scriptSig.resize(10);

src/test/mempool_tests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
5656
}
5757

5858

59-
CTxMemPool testPool;
59+
CTxMemPool& testPool = *Assert(m_node.mempool);
6060
LOCK2(cs_main, testPool.cs);
6161

6262
// Nothing in pool, remove should do nothing:
@@ -121,7 +121,7 @@ static void CheckSort(CTxMemPool& pool, std::vector<std::string>& sortedOrder) E
121121

122122
BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
123123
{
124-
CTxMemPool pool;
124+
CTxMemPool& pool = *Assert(m_node.mempool);
125125
LOCK2(cs_main, pool.cs);
126126
TestMemPoolEntryHelper entry;
127127

@@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
294294

295295
BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
296296
{
297-
CTxMemPool pool;
297+
CTxMemPool& pool = *Assert(m_node.mempool);
298298
LOCK2(cs_main, pool.cs);
299299
TestMemPoolEntryHelper entry;
300300

@@ -423,7 +423,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
423423

424424
BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
425425
{
426-
CTxMemPool pool;
426+
CTxMemPool& pool = *Assert(m_node.mempool);
427427
LOCK2(cs_main, pool.cs);
428428
TestMemPoolEntryHelper entry;
429429

@@ -594,7 +594,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
594594
{
595595
size_t ancestors, descendants;
596596

597-
CTxMemPool pool;
597+
CTxMemPool& pool = *Assert(m_node.mempool);
598598
LOCK2(cs_main, pool.cs);
599599
TestMemPoolEntryHelper entry;
600600

@@ -753,7 +753,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTestsDiamond)
753753
{
754754
size_t ancestors, descendants;
755755

756-
CTxMemPool pool;
756+
CTxMemPool& pool = *Assert(m_node.mempool);
757757
LOCK2(::cs_main, pool.cs);
758758
TestMemPoolEntryHelper entry;
759759

src/test/validation_chainstate_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
3030
ChainstateManager manager{chainman_opts};
3131

3232
WITH_LOCK(::cs_main, manager.m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(1 << 20, true));
33-
CTxMemPool mempool;
33+
CTxMemPool& mempool = *Assert(m_node.mempool);
3434

3535
//! Create and add a Coin with DynamicMemoryUsage of 80 bytes to the given view.
3636
auto add_coin = [](CCoinsViewCache& coins_view) -> COutPoint {

src/test/validation_flush_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, ChainTestingSetup)
2020
//!
2121
BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
2222
{
23-
CTxMemPool mempool;
23+
CTxMemPool& mempool = *Assert(m_node.mempool);
2424
BlockManager blockman{};
2525
CChainState chainstate{&mempool, blockman, *Assert(m_node.chainman)};
2626
chainstate.InitCoinsDB(/*cache_size_bytes=*/1 << 10, /*in_memory=*/true, /*should_wipe=*/false);

0 commit comments

Comments
 (0)