Skip to content

Commit fafe941

Browse files
author
MarcoFalke
committed
test: Add missing validation locks
1 parent fac4558 commit fafe941

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/bench/mempool_eviction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <list>
1010
#include <vector>
1111

12-
static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
12+
static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
1313
{
1414
int64_t nTime = 0;
1515
unsigned int nHeight = 1;
@@ -108,7 +108,7 @@ static void MempoolEviction(benchmark::State& state)
108108
tx7.vout[1].nValue = 10 * COIN;
109109

110110
CTxMemPool pool;
111-
LOCK(pool.cs);
111+
LOCK2(cs_main, pool.cs);
112112
// Create transaction references outside the "hot loop"
113113
const CTransactionRef tx1_r{MakeTransactionRef(tx1)};
114114
const CTransactionRef tx2_r{MakeTransactionRef(tx2)};

src/test/blockencodings_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
6262
TestMemPoolEntryHelper entry;
6363
CBlock block(BuildBlockTestCase());
6464

65-
LOCK(pool.cs);
65+
LOCK2(cs_main, pool.cs);
6666
pool.addUnchecked(entry.FromTx(block.vtx[2]));
6767
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
6868

@@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
162162
TestMemPoolEntryHelper entry;
163163
CBlock block(BuildBlockTestCase());
164164

165-
LOCK(pool.cs);
165+
LOCK2(cs_main, pool.cs);
166166
pool.addUnchecked(entry.FromTx(block.vtx[2]));
167167
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
168168

@@ -232,7 +232,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
232232
TestMemPoolEntryHelper entry;
233233
CBlock block(BuildBlockTestCase());
234234

235-
LOCK(pool.cs);
235+
LOCK2(cs_main, pool.cs);
236236
pool.addUnchecked(entry.FromTx(block.vtx[1]));
237237
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
238238

src/test/mempool_tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
5555

5656

5757
CTxMemPool testPool;
58-
LOCK(testPool.cs);
58+
LOCK2(cs_main, testPool.cs);
5959

6060
// Nothing in pool, remove should do nothing:
6161
unsigned int poolSize = testPool.size();
@@ -120,7 +120,7 @@ static void CheckSort(CTxMemPool &pool, std::vector<std::string> &sortedOrder) E
120120
BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
121121
{
122122
CTxMemPool pool;
123-
LOCK(pool.cs);
123+
LOCK2(cs_main, pool.cs);
124124
TestMemPoolEntryHelper entry;
125125

126126
/* 3rd highest fee */
@@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
293293
BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
294294
{
295295
CTxMemPool pool;
296-
LOCK(pool.cs);
296+
LOCK2(cs_main, pool.cs);
297297
TestMemPoolEntryHelper entry;
298298

299299
/* 3rd highest fee */
@@ -422,7 +422,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
422422
BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
423423
{
424424
CTxMemPool pool;
425-
LOCK(pool.cs);
425+
LOCK2(cs_main, pool.cs);
426426
TestMemPoolEntryHelper entry;
427427

428428
CMutableTransaction tx1 = CMutableTransaction();
@@ -595,7 +595,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
595595
size_t ancestors, descendants;
596596

597597
CTxMemPool pool;
598-
LOCK(pool.cs);
598+
LOCK2(cs_main, pool.cs);
599599
TestMemPoolEntryHelper entry;
600600

601601
/* Base transaction */

src/test/miner_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static bool TestSequenceLocks(const CTransaction &tx, int flags) EXCLUSIVE_LOCKS
9999
// Test suite for ancestor feerate transaction selection.
100100
// Implemented as an additional function, rather than a separate test case,
101101
// to allow reusing the blockchain created in CreateNewBlock_validity.
102-
static void TestPackageSelection(const CChainParams& chainparams, const CScript& scriptPubKey, const std::vector<CTransactionRef>& txFirst) EXCLUSIVE_LOCKS_REQUIRED(::mempool.cs)
102+
static void TestPackageSelection(const CChainParams& chainparams, const CScript& scriptPubKey, const std::vector<CTransactionRef>& txFirst) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs)
103103
{
104104
// Test the ancestor feerate transaction selection.
105105
TestMemPoolEntryHelper entry;

src/test/policyestimator_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
1818
{
1919
CBlockPolicyEstimator feeEst;
2020
CTxMemPool mpool(&feeEst);
21-
LOCK(mpool.cs);
21+
LOCK2(cs_main, mpool.cs);
2222
TestMemPoolEntryHelper entry;
2323
CAmount basefee(2000);
2424
CAmount deltaFee(100);

0 commit comments

Comments
 (0)