aboutsummaryrefslogtreecommitdiff
path: root/src/test/checkqueue_tests.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-11-07 10:07:01 -0500
committerMarcoFalke <falke.marco@gmail.com>2019-11-07 10:07:11 -0500
commit7d14e35f3fb7a1a651ff51e71c58cdea84643a82 (patch)
treeeaa206de30ca725873285971c81c03be788f84ab /src/test/checkqueue_tests.cpp
parent46e0e276398ea118451f509da1752e16a0b0678a (diff)
parent5506ecfe7a65d5705616bc048f2f1735b89993fb (diff)
downloadbitcoin-7d14e35f3fb7a1a651ff51e71c58cdea84643a82.tar.xz
Merge #17342: refactor: Clean up nScriptCheckThreads
5506ecfe7a65d5705616bc048f2f1735b89993fb [refactor] Replace global int nScriptCheckThreads with bool (John Newbery) d9957623b48a7c3eff0ac750d1245fabfb1843a2 [tests] Don't use TestingSetup in the checkqueue_tests (John Newbery) Pull request description: The meaning of this value is confusing. Refactor it and add comments. ACKs for top commit: sipa: ACK 5506ecfe7a65d5705616bc048f2f1735b89993fb promag: ACK 5506ecfe7a65d5705616bc048f2f1735b89993fb, only change was addressing my nits. laanwj: Code review ACK 5506ecfe7a65d5705616bc048f2f1735b89993fb MarcoFalke: ACK 5506ecfe7a65d5705616bc048f2f1735b89993fb 🥐 Tree-SHA512: 78536727c98d2c23f3c0f3f169131474fef9a4486ae65029011caf06eab30f6f70ff73a65b2fb04a5d969fc1150858d1c6ea4767f04d48c1eea6b829316d0e63
Diffstat (limited to 'src/test/checkqueue_tests.cpp')
-rw-r--r--src/test/checkqueue_tests.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/test/checkqueue_tests.cpp b/src/test/checkqueue_tests.cpp
index 89bb7445f8..6745bb9015 100644
--- a/src/test/checkqueue_tests.cpp
+++ b/src/test/checkqueue_tests.cpp
@@ -5,7 +5,6 @@
#include <util/memory.h>
#include <util/system.h>
#include <util/time.h>
-#include <validation.h>
#include <test/util/setup_common.h>
#include <checkqueue.h>
@@ -19,11 +18,10 @@
#include <unordered_set>
-// BasicTestingSetup not sufficient because nScriptCheckThreads is not set
-// otherwise.
BOOST_FIXTURE_TEST_SUITE(checkqueue_tests, TestingSetup)
static const unsigned int QUEUE_BATCH_SIZE = 128;
+static const int SCRIPT_CHECK_THREADS = 3;
struct FakeCheck {
bool operator()()
@@ -149,7 +147,7 @@ static void Correct_Queue_range(std::vector<size_t> range)
{
auto small_queue = MakeUnique<Correct_Queue>(QUEUE_BATCH_SIZE);
boost::thread_group tg;
- for (auto x = 0; x < nScriptCheckThreads; ++x) {
+ for (auto x = 0; x < SCRIPT_CHECK_THREADS; ++x) {
tg.create_thread([&]{small_queue->Thread();});
}
// Make vChecks here to save on malloc (this test can be slow...)
@@ -214,7 +212,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure)
auto fail_queue = MakeUnique<Failing_Queue>(QUEUE_BATCH_SIZE);
boost::thread_group tg;
- for (auto x = 0; x < nScriptCheckThreads; ++x) {
+ for (auto x = 0; x < SCRIPT_CHECK_THREADS; ++x) {
tg.create_thread([&]{fail_queue->Thread();});
}
@@ -246,7 +244,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
{
auto fail_queue = MakeUnique<Failing_Queue>(QUEUE_BATCH_SIZE);
boost::thread_group tg;
- for (auto x = 0; x < nScriptCheckThreads; ++x) {
+ for (auto x = 0; x < SCRIPT_CHECK_THREADS; ++x) {
tg.create_thread([&]{fail_queue->Thread();});
}
@@ -274,7 +272,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
{
auto queue = MakeUnique<Unique_Queue>(QUEUE_BATCH_SIZE);
boost::thread_group tg;
- for (auto x = 0; x < nScriptCheckThreads; ++x) {
+ for (auto x = 0; x < SCRIPT_CHECK_THREADS; ++x) {
tg.create_thread([&]{queue->Thread();});
}
@@ -310,7 +308,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory)
{
auto queue = MakeUnique<Memory_Queue>(QUEUE_BATCH_SIZE);
boost::thread_group tg;
- for (auto x = 0; x < nScriptCheckThreads; ++x) {
+ for (auto x = 0; x < SCRIPT_CHECK_THREADS; ++x) {
tg.create_thread([&]{queue->Thread();});
}
for (size_t i = 0; i < 1000; ++i) {
@@ -342,7 +340,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
auto queue = MakeUnique<FrozenCleanup_Queue>(QUEUE_BATCH_SIZE);
boost::thread_group tg;
bool fails = false;
- for (auto x = 0; x < nScriptCheckThreads; ++x) {
+ for (auto x = 0; x < SCRIPT_CHECK_THREADS; ++x) {
tg.create_thread([&]{queue->Thread();});
}
std::thread t0([&]() {