23
23
* using BOOST_CHECK_CLOSE to fail.
24
24
*
25
25
*/
26
- FastRandomContext insecure_rand (true );
26
+ FastRandomContext local_rand_ctx (true );
27
27
28
28
BOOST_AUTO_TEST_SUITE (cuckoocache_tests);
29
29
30
30
31
- /* * insecure_GetRandHash fills in a uint256 from insecure_rand
31
+ /* * insecure_GetRandHash fills in a uint256 from local_rand_ctx
32
32
*/
33
33
void insecure_GetRandHash (uint256& t)
34
34
{
35
35
uint32_t * ptr = (uint32_t *)t.begin ();
36
36
for (uint8_t j = 0 ; j < 8 ; ++j)
37
- *(ptr++) = insecure_rand .rand32 ();
37
+ *(ptr++) = local_rand_ctx .rand32 ();
38
38
}
39
39
40
40
@@ -45,7 +45,7 @@ void insecure_GetRandHash(uint256& t)
45
45
*/
46
46
BOOST_AUTO_TEST_CASE (test_cuckoocache_no_fakes)
47
47
{
48
- insecure_rand = FastRandomContext (true );
48
+ local_rand_ctx = FastRandomContext (true );
49
49
CuckooCache::cache<uint256, SignatureCacheHasher> cc{};
50
50
size_t megabytes = 4 ;
51
51
cc.setup_bytes (megabytes << 20 );
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(test_cuckoocache_no_fakes)
66
66
template <typename Cache>
67
67
double test_cache (size_t megabytes, double load)
68
68
{
69
- insecure_rand = FastRandomContext (true );
69
+ local_rand_ctx = FastRandomContext (true );
70
70
std::vector<uint256> hashes;
71
71
Cache set{};
72
72
size_t bytes = megabytes * (1 << 20 );
@@ -76,7 +76,7 @@ double test_cache(size_t megabytes, double load)
76
76
for (uint32_t i = 0 ; i < n_insert; ++i) {
77
77
uint32_t * ptr = (uint32_t *)hashes[i].begin ();
78
78
for (uint8_t j = 0 ; j < 8 ; ++j)
79
- *(ptr++) = insecure_rand .rand32 ();
79
+ *(ptr++) = local_rand_ctx .rand32 ();
80
80
}
81
81
/* * We make a copy of the hashes because future optimizations of the
82
82
* cuckoocache may overwrite the inserted element, so the test is
@@ -137,7 +137,7 @@ template <typename Cache>
137
137
void test_cache_erase (size_t megabytes)
138
138
{
139
139
double load = 1 ;
140
- insecure_rand = FastRandomContext (true );
140
+ local_rand_ctx = FastRandomContext (true );
141
141
std::vector<uint256> hashes;
142
142
Cache set{};
143
143
size_t bytes = megabytes * (1 << 20 );
@@ -147,7 +147,7 @@ void test_cache_erase(size_t megabytes)
147
147
for (uint32_t i = 0 ; i < n_insert; ++i) {
148
148
uint32_t * ptr = (uint32_t *)hashes[i].begin ();
149
149
for (uint8_t j = 0 ; j < 8 ; ++j)
150
- *(ptr++) = insecure_rand .rand32 ();
150
+ *(ptr++) = local_rand_ctx .rand32 ();
151
151
}
152
152
/* * We make a copy of the hashes because future optimizations of the
153
153
* cuckoocache may overwrite the inserted element, so the test is
@@ -200,7 +200,7 @@ template <typename Cache>
200
200
void test_cache_erase_parallel (size_t megabytes)
201
201
{
202
202
double load = 1 ;
203
- insecure_rand = FastRandomContext (true );
203
+ local_rand_ctx = FastRandomContext (true );
204
204
std::vector<uint256> hashes;
205
205
Cache set{};
206
206
size_t bytes = megabytes * (1 << 20 );
@@ -210,7 +210,7 @@ void test_cache_erase_parallel(size_t megabytes)
210
210
for (uint32_t i = 0 ; i < n_insert; ++i) {
211
211
uint32_t * ptr = (uint32_t *)hashes[i].begin ();
212
212
for (uint8_t j = 0 ; j < 8 ; ++j)
213
- *(ptr++) = insecure_rand .rand32 ();
213
+ *(ptr++) = local_rand_ctx .rand32 ();
214
214
}
215
215
/* * We make a copy of the hashes because future optimizations of the
216
216
* cuckoocache may overwrite the inserted element, so the test is
@@ -302,7 +302,7 @@ void test_cache_generations()
302
302
// iterations with non-deterministic values, so it isn't "overfit" to the
303
303
// specific entropy in FastRandomContext(true) and implementation of the
304
304
// cache.
305
- insecure_rand = FastRandomContext (true );
305
+ local_rand_ctx = FastRandomContext (true );
306
306
307
307
// block_activity models a chunk of network activity. n_insert elements are
308
308
// adde to the cache. The first and last n/4 are stored for removal later
@@ -319,7 +319,7 @@ void test_cache_generations()
319
319
for (uint32_t i = 0 ; i < n_insert; ++i) {
320
320
uint32_t * ptr = (uint32_t *)inserts[i].begin ();
321
321
for (uint8_t j = 0 ; j < 8 ; ++j)
322
- *(ptr++) = insecure_rand .rand32 ();
322
+ *(ptr++) = local_rand_ctx .rand32 ();
323
323
}
324
324
for (uint32_t i = 0 ; i < n_insert / 4 ; ++i)
325
325
reads.push_back (inserts[i]);
0 commit comments