@@ -158,8 +158,7 @@ typedef CCheckQueue<FrozenCleanupCheck> FrozenCleanup_Queue;
158158 */
159159static void Correct_Queue_range (std::vector<size_t > range)
160160{
161- auto small_queue = std::make_unique<Correct_Queue>(QUEUE_BATCH_SIZE);
162- small_queue->StartWorkerThreads (SCRIPT_CHECK_THREADS);
161+ auto small_queue = std::make_unique<Correct_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
163162 // Make vChecks here to save on malloc (this test can be slow...)
164163 std::vector<FakeCheckCheckCompletion> vChecks;
165164 vChecks.reserve (9 );
@@ -176,7 +175,6 @@ static void Correct_Queue_range(std::vector<size_t> range)
176175 BOOST_REQUIRE (control.Wait ());
177176 BOOST_REQUIRE_EQUAL (FakeCheckCheckCompletion::n_calls, i);
178177 }
179- small_queue->StopWorkerThreads ();
180178}
181179
182180/* * Test that 0 checks is correct
@@ -218,9 +216,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_Random)
218216/* * Test that failing checks are caught */
219217BOOST_AUTO_TEST_CASE (test_CheckQueue_Catches_Failure)
220218{
221- auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE);
222- fail_queue->StartWorkerThreads (SCRIPT_CHECK_THREADS);
223-
219+ auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
224220 for (size_t i = 0 ; i < 1001 ; ++i) {
225221 CCheckQueueControl<FailingCheck> control (fail_queue.get ());
226222 size_t remaining = i;
@@ -240,15 +236,12 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure)
240236 BOOST_REQUIRE (success);
241237 }
242238 }
243- fail_queue->StopWorkerThreads ();
244239}
245240// Test that a block validation which fails does not interfere with
246241// future blocks, ie, the bad state is cleared.
247242BOOST_AUTO_TEST_CASE (test_CheckQueue_Recovers_From_Failure)
248243{
249- auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE);
250- fail_queue->StartWorkerThreads (SCRIPT_CHECK_THREADS);
251-
244+ auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
252245 for (auto times = 0 ; times < 10 ; ++times) {
253246 for (const bool end_fails : {true , false }) {
254247 CCheckQueueControl<FailingCheck> control (fail_queue.get ());
@@ -262,17 +255,14 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
262255 BOOST_REQUIRE (r != end_fails);
263256 }
264257 }
265- fail_queue->StopWorkerThreads ();
266258}
267259
268260// Test that unique checks are actually all called individually, rather than
269261// just one check being called repeatedly. Test that checks are not called
270262// more than once as well
271263BOOST_AUTO_TEST_CASE (test_CheckQueue_UniqueCheck)
272264{
273- auto queue = std::make_unique<Unique_Queue>(QUEUE_BATCH_SIZE);
274- queue->StartWorkerThreads (SCRIPT_CHECK_THREADS);
275-
265+ auto queue = std::make_unique<Unique_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
276266 size_t COUNT = 100000 ;
277267 size_t total = COUNT;
278268 {
@@ -294,7 +284,6 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
294284 }
295285 BOOST_REQUIRE (r);
296286 }
297- queue->StopWorkerThreads ();
298287}
299288
300289
@@ -305,8 +294,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
305294// time could leave the data hanging across a sequence of blocks.
306295BOOST_AUTO_TEST_CASE (test_CheckQueue_Memory)
307296{
308- auto queue = std::make_unique<Memory_Queue>(QUEUE_BATCH_SIZE);
309- queue->StartWorkerThreads (SCRIPT_CHECK_THREADS);
297+ auto queue = std::make_unique<Memory_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
310298 for (size_t i = 0 ; i < 1000 ; ++i) {
311299 size_t total = i;
312300 {
@@ -325,16 +313,14 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory)
325313 }
326314 BOOST_REQUIRE_EQUAL (MemoryCheck::fake_allocated_memory, 0U );
327315 }
328- queue->StopWorkerThreads ();
329316}
330317
331318// Test that a new verification cannot occur until all checks
332319// have been destructed
333320BOOST_AUTO_TEST_CASE (test_CheckQueue_FrozenCleanup)
334321{
335- auto queue = std::make_unique<FrozenCleanup_Queue>(QUEUE_BATCH_SIZE);
322+ auto queue = std::make_unique<FrozenCleanup_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS );
336323 bool fails = false ;
337- queue->StartWorkerThreads (SCRIPT_CHECK_THREADS);
338324 std::thread t0 ([&]() {
339325 CCheckQueueControl<FrozenCleanupCheck> control (queue.get ());
340326 std::vector<FrozenCleanupCheck> vChecks (1 );
@@ -361,14 +347,13 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
361347 // Wait for control to finish
362348 t0.join ();
363349 BOOST_REQUIRE (!fails);
364- queue->StopWorkerThreads ();
365350}
366351
367352
368353/* * Test that CCheckQueueControl is threadsafe */
369354BOOST_AUTO_TEST_CASE (test_CheckQueueControl_Locks)
370355{
371- auto queue = std::make_unique<Standard_Queue>(QUEUE_BATCH_SIZE);
356+ auto queue = std::make_unique<Standard_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS );
372357 {
373358 std::vector<std::thread> tg;
374359 std::atomic<int > nThreads {0 };
0 commit comments