aboutsummaryrefslogtreecommitdiff
path: root/src/test/util/setup_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/util/setup_common.h')
-rw-r--r--src/test/util/setup_common.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
index 5467cd6cce..1e2e059a56 100644
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -39,9 +39,21 @@ extern FastRandomContext g_insecure_rand_ctx;
*/
extern bool g_mock_deterministic_tests;
-static inline void SeedInsecureRand(bool deterministic = false)
+enum class SeedRand {
+ ZEROS, //!< Seed with a compile time constant of zeros
+ SEED, //!< Call the Seed() helper
+};
+
+/** Seed the given random ctx or use the seed passed in via an environment var */
+void Seed(FastRandomContext& ctx);
+
+static inline void SeedInsecureRand(SeedRand seed = SeedRand::SEED)
{
- g_insecure_rand_ctx = FastRandomContext(deterministic);
+ if (seed == SeedRand::ZEROS) {
+ g_insecure_rand_ctx = FastRandomContext(/* deterministic */ true);
+ } else {
+ Seed(g_insecure_rand_ctx);
+ }
}
static inline uint32_t InsecureRand32() { return g_insecure_rand_ctx.rand32(); }