MCPcopy Create free account
hub / github.com/ElementsProject/elements / Correct_Queue_range

Function Correct_Queue_range

src/test/checkqueue_tests.cpp:160–184  ·  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

158 * with each specified size_t Checks pushed.
159 */
160static void Correct_Queue_range(std::vector<size_t> range)
161{
162 auto small_queue = std::make_unique<Correct_Queue>(QUEUE_BATCH_SIZE);
163 small_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
164 // Make vChecks here to save on malloc (this test can be slow...)
165 std::vector<FakeCheckCheckCompletion*> vChecks;
166 for (const size_t i : range) {
167 size_t total = i;
168 FakeCheckCheckCompletion::n_calls = 0;
169 CCheckQueueControl<FakeCheckCheckCompletion> control(small_queue.get());
170 while (total) {
171 vChecks.resize(std::min(total, (size_t) InsecureRandRange(10)));
172 for (size_t i = 0; i < vChecks.size(); ++i) {
173 vChecks[i] = new FakeCheckCheckCompletion();
174 }
175 total -= vChecks.size();
176 control.Add(vChecks);
177 }
178 BOOST_REQUIRE(control.Wait());
179 if (FakeCheckCheckCompletion::n_calls != i) {
180 BOOST_REQUIRE_EQUAL(FakeCheckCheckCompletion::n_calls, i);
181 }
182 }
183 small_queue->StopWorkerThreads();
184}
185
186/** Test that 0 checks is correct
187 */

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 8

InsecureRandRangeFunction · 0.85
StartWorkerThreadsMethod · 0.80
StopWorkerThreadsMethod · 0.80
getMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
AddMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected