aboutsummaryrefslogtreecommitdiff
path: root/src/test/pool_tests.cpp
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-08-02 11:35:15 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-08-26 11:19:52 +0200
commitfa0fe08eca48064b2a42789571fea017e455d820 (patch)
tree5bde0488dfc6cad7103bfca07a084f3453340f1a /src/test/pool_tests.cpp
parentfa54cab4734f02422f28fdffc0f11e6d3d51b8f0 (diff)
scripted-diff: [test] Use g_rng/m_rng directly
-BEGIN VERIFY SCRIPT- # Use m_rng in unit test files ren() { sed -i "s:\<$1\>:$2:g" $( git grep -l "$1" src/test/*.cpp src/wallet/test/*.cpp src/test/util/setup_common.cpp ) ; } ren InsecureRand32 m_rng.rand32 ren InsecureRand256 m_rng.rand256 ren InsecureRandBits m_rng.randbits ren InsecureRandRange m_rng.randrange ren InsecureRandBool m_rng.randbool ren g_insecure_rand_ctx m_rng ren g_insecure_rand_ctx_temp_path g_rng_temp_path -END VERIFY SCRIPT-
Diffstat (limited to 'src/test/pool_tests.cpp')
-rw-r--r--src/test/pool_tests.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/pool_tests.cpp b/src/test/pool_tests.cpp
index 5ad4afa3a1..9d15660126 100644
--- a/src/test/pool_tests.cpp
+++ b/src/test/pool_tests.cpp
@@ -129,17 +129,17 @@ BOOST_AUTO_TEST_CASE(random_allocations)
std::vector<PtrSizeAlignment> ptr_size_alignment{};
for (size_t i = 0; i < 1000; ++i) {
// make it a bit more likely to allocate than deallocate
- if (ptr_size_alignment.empty() || 0 != InsecureRandRange(4)) {
+ if (ptr_size_alignment.empty() || 0 != m_rng.randrange(4)) {
// allocate a random item
- std::size_t alignment = std::size_t{1} << InsecureRandRange(8); // 1, 2, ..., 128
- std::size_t size = (InsecureRandRange(200) / alignment + 1) * alignment; // multiple of alignment
+ std::size_t alignment = std::size_t{1} << m_rng.randrange(8); // 1, 2, ..., 128
+ std::size_t size = (m_rng.randrange(200) / alignment + 1) * alignment; // multiple of alignment
void* ptr = resource.Allocate(size, alignment);
BOOST_TEST(ptr != nullptr);
BOOST_TEST((reinterpret_cast<uintptr_t>(ptr) & (alignment - 1)) == 0);
ptr_size_alignment.push_back({ptr, size, alignment});
} else {
// deallocate a random item
- auto& x = ptr_size_alignment[InsecureRandRange(ptr_size_alignment.size())];
+ auto& x = ptr_size_alignment[m_rng.randrange(ptr_size_alignment.size())];
resource.Deallocate(x.ptr, x.bytes, x.alignment);
x = ptr_size_alignment.back();
ptr_size_alignment.pop_back();