aboutsummaryrefslogtreecommitdiff
path: root/src/test/util
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2023-01-22 09:57:19 -0800
committerJon Atack <jon@atack.com>2023-02-06 12:26:04 -0800
commit81f5ade2a324167c03c5ce765a26bd42ed652723 (patch)
treef45d1c7ba2012c636866f6fb2d6a7a876b5dda39 /src/test/util
parent52ddbd52f980c0e733682401056d8131f1d513c0 (diff)
Move random test util code from setup_common to random
as many of the unit tests don't use this code
Diffstat (limited to 'src/test/util')
-rw-r--r--src/test/util/random.h39
-rw-r--r--src/test/util/setup_common.h6
2 files changed, 39 insertions, 6 deletions
diff --git a/src/test/util/random.h b/src/test/util/random.h
new file mode 100644
index 0000000000..72c9ec85e2
--- /dev/null
+++ b/src/test/util/random.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2023 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_TEST_UTIL_RANDOM_H
+#define BITCOIN_TEST_UTIL_RANDOM_H
+
+#include <random.h>
+#include <test/util/setup_common.h>
+#include <uint256.h>
+
+#include <cstdint>
+
+static inline uint32_t InsecureRand32()
+{
+ return g_insecure_rand_ctx.rand32();
+}
+
+static inline uint256 InsecureRand256()
+{
+ return g_insecure_rand_ctx.rand256();
+}
+
+static inline uint64_t InsecureRandBits(int bits)
+{
+ return g_insecure_rand_ctx.randbits(bits);
+}
+
+static inline uint64_t InsecureRandRange(uint64_t range)
+{
+ return g_insecure_rand_ctx.randrange(range);
+}
+
+static inline bool InsecureRandBool()
+{
+ return g_insecure_rand_ctx.randbool();
+}
+
+#endif // BITCOIN_TEST_UTIL_RANDOM_H
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
index 5f653d83ae..8874db7e75 100644
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -71,12 +71,6 @@ static inline void SeedInsecureRand(SeedRand seed = SeedRand::SEED)
}
}
-static inline uint32_t InsecureRand32() { return g_insecure_rand_ctx.rand32(); }
-static inline uint256 InsecureRand256() { return g_insecure_rand_ctx.rand256(); }
-static inline uint64_t InsecureRandBits(int bits) { return g_insecure_rand_ctx.randbits(bits); }
-static inline uint64_t InsecureRandRange(uint64_t range) { return g_insecure_rand_ctx.randrange(range); }
-static inline bool InsecureRandBool() { return g_insecure_rand_ctx.randbool(); }
-
static constexpr CAmount CENT{1000000};
/** Basic testing setup.