aboutsummaryrefslogtreecommitdiff
path: root/src/test/skiplist_tests.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-06-07 11:34:55 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2017-06-07 11:34:55 -0700
commit3ecabae36364e905e7821fba3e60aa7f8418de6c (patch)
tree04b22d1cf440fcedacdea019f6421c629d766b44 /src/test/skiplist_tests.cpp
parentefee1db21a652019e0ab18fffc233d91bb7f1816 (diff)
Replace more rand() % NUM by randranges
Diffstat (limited to 'src/test/skiplist_tests.cpp')
-rw-r--r--src/test/skiplist_tests.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/skiplist_tests.cpp b/src/test/skiplist_tests.cpp
index 00ad5c1aa8..36f29a486b 100644
--- a/src/test/skiplist_tests.cpp
+++ b/src/test/skiplist_tests.cpp
@@ -34,8 +34,8 @@ BOOST_AUTO_TEST_CASE(skiplist_test)
}
for (int i=0; i < 1000; i++) {
- int from = insecure_rand() % (SKIPLIST_LENGTH - 1);
- int to = insecure_rand() % (from + 1);
+ int from = insecure_randrange(SKIPLIST_LENGTH - 1);
+ int to = insecure_randrange(from + 1);
BOOST_CHECK(vIndex[SKIPLIST_LENGTH - 1].GetAncestor(from) == &vIndex[from]);
BOOST_CHECK(vIndex[from].GetAncestor(to) == &vIndex[to]);
@@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(findearliestatleast_test)
} else {
// randomly choose something in the range [MTP, MTP*2]
int64_t medianTimePast = vBlocksMain[i].GetMedianTimePast();
- int r = insecure_rand() % medianTimePast;
+ int r = insecure_randrange(medianTimePast);
vBlocksMain[i].nTime = r + medianTimePast;
vBlocksMain[i].nTimeMax = std::max(vBlocksMain[i].nTime, vBlocksMain[i-1].nTimeMax);
}
@@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(findearliestatleast_test)
// Verify that FindEarliestAtLeast is correct.
for (unsigned int i=0; i<10000; ++i) {
// Pick a random element in vBlocksMain.
- int r = insecure_rand() % vBlocksMain.size();
+ int r = insecure_randrange(vBlocksMain.size());
int64_t test_time = vBlocksMain[r].nTime;
CBlockIndex *ret = chain.FindEarliestAtLeast(test_time);
BOOST_CHECK(ret->nTimeMax >= test_time);