diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-07-28 11:09:58 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-07-29 08:04:06 -0400 |
commit | fa5ed4f8d2c4cb3507bcc2460725d483f2e5789c (patch) | |
tree | 0dabe170ab89702055257cf214ab1de431aa4a9b /src/test/mempool_tests.cpp | |
parent | ad51e1372bc645fc8710da2bc9e0a9fc6c0f27bb (diff) | |
download | bitcoin-fa5ed4f8d2c4cb3507bcc2460725d483f2e5789c.tar.xz |
refactor: Avoid locking tx pool cs thrice
Diffstat (limited to 'src/test/mempool_tests.cpp')
-rw-r--r-- | src/test/mempool_tests.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index e2d76dc293..fb80599af7 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -55,6 +55,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest) CTxMemPool testPool; + LOCK(testPool.cs); // Nothing in pool, remove should do nothing: unsigned int poolSize = testPool.size(); @@ -119,6 +120,7 @@ static void CheckSort(CTxMemPool &pool, std::vector<std::string> &sortedOrder) E BOOST_AUTO_TEST_CASE(MempoolIndexingTest) { CTxMemPool pool; + LOCK(pool.cs); TestMemPoolEntryHelper entry; /* 3rd highest fee */ @@ -165,7 +167,6 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest) sortedOrder[2] = tx1.GetHash().ToString(); // 10000 sortedOrder[3] = tx4.GetHash().ToString(); // 15000 sortedOrder[4] = tx2.GetHash().ToString(); // 20000 - LOCK(pool.cs); CheckSort<descendant_score>(pool, sortedOrder); /* low fee but with high fee child */ @@ -292,6 +293,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest) BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest) { CTxMemPool pool; + LOCK(pool.cs); TestMemPoolEntryHelper entry; /* 3rd highest fee */ @@ -347,7 +349,6 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest) } sortedOrder[4] = tx3.GetHash().ToString(); // 0 - LOCK(pool.cs); CheckSort<ancestor_score>(pool, sortedOrder); /* low fee parent with high fee child */ @@ -421,6 +422,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest) BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest) { CTxMemPool pool; + LOCK(pool.cs); TestMemPoolEntryHelper entry; CMutableTransaction tx1 = CMutableTransaction(); @@ -593,6 +595,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests) size_t ancestors, descendants; CTxMemPool pool; + LOCK(pool.cs); TestMemPoolEntryHelper entry; /* Base transaction */ |