test: Add missing validation locks
This commit is contained in:
parent
fac4558462
commit
fafe941bdd
5 changed files with 12 additions and 12 deletions
|
@ -9,7 +9,7 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
|
static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||||
{
|
{
|
||||||
int64_t nTime = 0;
|
int64_t nTime = 0;
|
||||||
unsigned int nHeight = 1;
|
unsigned int nHeight = 1;
|
||||||
|
@ -108,7 +108,7 @@ static void MempoolEviction(benchmark::State& state)
|
||||||
tx7.vout[1].nValue = 10 * COIN;
|
tx7.vout[1].nValue = 10 * COIN;
|
||||||
|
|
||||||
CTxMemPool pool;
|
CTxMemPool pool;
|
||||||
LOCK(pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
// Create transaction references outside the "hot loop"
|
// Create transaction references outside the "hot loop"
|
||||||
const CTransactionRef tx1_r{MakeTransactionRef(tx1)};
|
const CTransactionRef tx1_r{MakeTransactionRef(tx1)};
|
||||||
const CTransactionRef tx2_r{MakeTransactionRef(tx2)};
|
const CTransactionRef tx2_r{MakeTransactionRef(tx2)};
|
||||||
|
|
|
@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
CBlock block(BuildBlockTestCase());
|
CBlock block(BuildBlockTestCase());
|
||||||
|
|
||||||
LOCK(pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
pool.addUnchecked(entry.FromTx(block.vtx[2]));
|
pool.addUnchecked(entry.FromTx(block.vtx[2]));
|
||||||
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
|
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
CBlock block(BuildBlockTestCase());
|
CBlock block(BuildBlockTestCase());
|
||||||
|
|
||||||
LOCK(pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
pool.addUnchecked(entry.FromTx(block.vtx[2]));
|
pool.addUnchecked(entry.FromTx(block.vtx[2]));
|
||||||
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
|
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
CBlock block(BuildBlockTestCase());
|
CBlock block(BuildBlockTestCase());
|
||||||
|
|
||||||
LOCK(pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
pool.addUnchecked(entry.FromTx(block.vtx[1]));
|
pool.addUnchecked(entry.FromTx(block.vtx[1]));
|
||||||
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
|
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
|
||||||
|
|
||||||
|
|
||||||
CTxMemPool testPool;
|
CTxMemPool testPool;
|
||||||
LOCK(testPool.cs);
|
LOCK2(cs_main, testPool.cs);
|
||||||
|
|
||||||
// Nothing in pool, remove should do nothing:
|
// Nothing in pool, remove should do nothing:
|
||||||
unsigned int poolSize = testPool.size();
|
unsigned int poolSize = testPool.size();
|
||||||
|
@ -120,7 +120,7 @@ static void CheckSort(CTxMemPool &pool, std::vector<std::string> &sortedOrder) E
|
||||||
BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
|
BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
|
||||||
{
|
{
|
||||||
CTxMemPool pool;
|
CTxMemPool pool;
|
||||||
LOCK(pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
|
|
||||||
/* 3rd highest fee */
|
/* 3rd highest fee */
|
||||||
|
@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
|
||||||
BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
|
BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
|
||||||
{
|
{
|
||||||
CTxMemPool pool;
|
CTxMemPool pool;
|
||||||
LOCK(pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
|
|
||||||
/* 3rd highest fee */
|
/* 3rd highest fee */
|
||||||
|
@ -422,7 +422,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
|
||||||
BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
|
BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
|
||||||
{
|
{
|
||||||
CTxMemPool pool;
|
CTxMemPool pool;
|
||||||
LOCK(pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
|
|
||||||
CMutableTransaction tx1 = CMutableTransaction();
|
CMutableTransaction tx1 = CMutableTransaction();
|
||||||
|
@ -595,7 +595,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
|
||||||
size_t ancestors, descendants;
|
size_t ancestors, descendants;
|
||||||
|
|
||||||
CTxMemPool pool;
|
CTxMemPool pool;
|
||||||
LOCK(pool.cs);
|
LOCK2(cs_main, pool.cs);
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
|
|
||||||
/* Base transaction */
|
/* Base transaction */
|
||||||
|
|
|
@ -99,7 +99,7 @@ static bool TestSequenceLocks(const CTransaction &tx, int flags) EXCLUSIVE_LOCKS
|
||||||
// Test suite for ancestor feerate transaction selection.
|
// Test suite for ancestor feerate transaction selection.
|
||||||
// Implemented as an additional function, rather than a separate test case,
|
// Implemented as an additional function, rather than a separate test case,
|
||||||
// to allow reusing the blockchain created in CreateNewBlock_validity.
|
// to allow reusing the blockchain created in CreateNewBlock_validity.
|
||||||
static void TestPackageSelection(const CChainParams& chainparams, const CScript& scriptPubKey, const std::vector<CTransactionRef>& txFirst) EXCLUSIVE_LOCKS_REQUIRED(::mempool.cs)
|
static void TestPackageSelection(const CChainParams& chainparams, const CScript& scriptPubKey, const std::vector<CTransactionRef>& txFirst) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs)
|
||||||
{
|
{
|
||||||
// Test the ancestor feerate transaction selection.
|
// Test the ancestor feerate transaction selection.
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
|
|
|
@ -18,7 +18,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||||
{
|
{
|
||||||
CBlockPolicyEstimator feeEst;
|
CBlockPolicyEstimator feeEst;
|
||||||
CTxMemPool mpool(&feeEst);
|
CTxMemPool mpool(&feeEst);
|
||||||
LOCK(mpool.cs);
|
LOCK2(cs_main, mpool.cs);
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
CAmount basefee(2000);
|
CAmount basefee(2000);
|
||||||
CAmount deltaFee(100);
|
CAmount deltaFee(100);
|
||||||
|
|
Loading…
Reference in a new issue