MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / Correct_Queue_range

Function Correct_Queue_range

src/test/checkqueue_tests.cpp:149–175  ·  view source on GitHub ↗

This test case checks that the CCheckQueue works properly * with each specified size_t Checks pushed. */

Source from the content-addressed store, hash-verified

147 * with each specified size_t Checks pushed.
148 */
149static void Correct_Queue_range(std::vector<size_t> range)
150{
151 auto small_queue = std::unique_ptr<Correct_Queue>(new Correct_Queue {QUEUE_BATCH_SIZE});
152 boost::thread_group tg;
153 for (auto x = 0; x < nScriptCheckThreads; ++x) {
154 tg.create_thread([&]{small_queue->Thread();});
155 }
156 // Make vChecks here to save on malloc (this test can be slow...)
157 std::vector<FakeCheckCheckCompletion> vChecks;
158 for (auto i : range) {
159 size_t total = i;
160 FakeCheckCheckCompletion::n_calls = 0;
161 CCheckQueueControl<FakeCheckCheckCompletion> control(small_queue.get());
162 while (total) {
163 vChecks.resize(std::min(total, (size_t) InsecureRandRange(10)));
164 total -= vChecks.size();
165 control.Add(vChecks);
166 }
167 BOOST_REQUIRE(control.Wait());
168 if (FakeCheckCheckCompletion::n_calls != i) {
169 BOOST_REQUIRE_EQUAL(FakeCheckCheckCompletion::n_calls, i);
170 BOOST_TEST_MESSAGE("Failure on trial " << i << " expected, got " << FakeCheckCheckCompletion::n_calls);
171 }
172 }
173 tg.interrupt_all();
174 tg.join_all();
175}
176
177/** Test that 0 checks is correct
178 */

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 7

InsecureRandRangeFunction · 0.85
ThreadMethod · 0.80
getMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
AddMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected