Skip to content

Commit 90620d6

Browse files
committed
scripted-diff: Rename cuckoo tests' local rand context
-BEGIN VERIFY SCRIPT- sed -i 's/insecure_rand/local_rand_ctx/g' src/test/cuckoocache_tests.cpp -END VERIFY SCRIPT-
1 parent 37e864e commit 90620d6

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/test/cuckoocache_tests.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
* using BOOST_CHECK_CLOSE to fail.
2424
*
2525
*/
26-
FastRandomContext insecure_rand(true);
26+
FastRandomContext local_rand_ctx(true);
2727

2828
BOOST_AUTO_TEST_SUITE(cuckoocache_tests);
2929

3030

31-
/** insecure_GetRandHash fills in a uint256 from insecure_rand
31+
/** insecure_GetRandHash fills in a uint256 from local_rand_ctx
3232
*/
3333
void insecure_GetRandHash(uint256& t)
3434
{
3535
uint32_t* ptr = (uint32_t*)t.begin();
3636
for (uint8_t j = 0; j < 8; ++j)
37-
*(ptr++) = insecure_rand.rand32();
37+
*(ptr++) = local_rand_ctx.rand32();
3838
}
3939

4040

@@ -45,7 +45,7 @@ void insecure_GetRandHash(uint256& t)
4545
*/
4646
BOOST_AUTO_TEST_CASE(test_cuckoocache_no_fakes)
4747
{
48-
insecure_rand = FastRandomContext(true);
48+
local_rand_ctx = FastRandomContext(true);
4949
CuckooCache::cache<uint256, SignatureCacheHasher> cc{};
5050
size_t megabytes = 4;
5151
cc.setup_bytes(megabytes << 20);
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(test_cuckoocache_no_fakes)
6666
template <typename Cache>
6767
double test_cache(size_t megabytes, double load)
6868
{
69-
insecure_rand = FastRandomContext(true);
69+
local_rand_ctx = FastRandomContext(true);
7070
std::vector<uint256> hashes;
7171
Cache set{};
7272
size_t bytes = megabytes * (1 << 20);
@@ -76,7 +76,7 @@ double test_cache(size_t megabytes, double load)
7676
for (uint32_t i = 0; i < n_insert; ++i) {
7777
uint32_t* ptr = (uint32_t*)hashes[i].begin();
7878
for (uint8_t j = 0; j < 8; ++j)
79-
*(ptr++) = insecure_rand.rand32();
79+
*(ptr++) = local_rand_ctx.rand32();
8080
}
8181
/** We make a copy of the hashes because future optimizations of the
8282
* cuckoocache may overwrite the inserted element, so the test is
@@ -137,7 +137,7 @@ template <typename Cache>
137137
void test_cache_erase(size_t megabytes)
138138
{
139139
double load = 1;
140-
insecure_rand = FastRandomContext(true);
140+
local_rand_ctx = FastRandomContext(true);
141141
std::vector<uint256> hashes;
142142
Cache set{};
143143
size_t bytes = megabytes * (1 << 20);
@@ -147,7 +147,7 @@ void test_cache_erase(size_t megabytes)
147147
for (uint32_t i = 0; i < n_insert; ++i) {
148148
uint32_t* ptr = (uint32_t*)hashes[i].begin();
149149
for (uint8_t j = 0; j < 8; ++j)
150-
*(ptr++) = insecure_rand.rand32();
150+
*(ptr++) = local_rand_ctx.rand32();
151151
}
152152
/** We make a copy of the hashes because future optimizations of the
153153
* cuckoocache may overwrite the inserted element, so the test is
@@ -200,7 +200,7 @@ template <typename Cache>
200200
void test_cache_erase_parallel(size_t megabytes)
201201
{
202202
double load = 1;
203-
insecure_rand = FastRandomContext(true);
203+
local_rand_ctx = FastRandomContext(true);
204204
std::vector<uint256> hashes;
205205
Cache set{};
206206
size_t bytes = megabytes * (1 << 20);
@@ -210,7 +210,7 @@ void test_cache_erase_parallel(size_t megabytes)
210210
for (uint32_t i = 0; i < n_insert; ++i) {
211211
uint32_t* ptr = (uint32_t*)hashes[i].begin();
212212
for (uint8_t j = 0; j < 8; ++j)
213-
*(ptr++) = insecure_rand.rand32();
213+
*(ptr++) = local_rand_ctx.rand32();
214214
}
215215
/** We make a copy of the hashes because future optimizations of the
216216
* cuckoocache may overwrite the inserted element, so the test is
@@ -302,7 +302,7 @@ void test_cache_generations()
302302
// iterations with non-deterministic values, so it isn't "overfit" to the
303303
// specific entropy in FastRandomContext(true) and implementation of the
304304
// cache.
305-
insecure_rand = FastRandomContext(true);
305+
local_rand_ctx = FastRandomContext(true);
306306

307307
// block_activity models a chunk of network activity. n_insert elements are
308308
// adde to the cache. The first and last n/4 are stored for removal later
@@ -319,7 +319,7 @@ void test_cache_generations()
319319
for (uint32_t i = 0; i < n_insert; ++i) {
320320
uint32_t* ptr = (uint32_t*)inserts[i].begin();
321321
for (uint8_t j = 0; j < 8; ++j)
322-
*(ptr++) = insecure_rand.rand32();
322+
*(ptr++) = local_rand_ctx.rand32();
323323
}
324324
for (uint32_t i = 0; i < n_insert / 4; ++i)
325325
reads.push_back(inserts[i]);

0 commit comments

Comments
 (0)