aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-08-29 09:48:34 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-08-29 09:38:05 +0200
commit2222f7a87404078984c7189768a3422deb114302 (patch)
tree80469d3ac40cb8f15833fad35c2c4f17f4d2430d /src
parent4ee1940e849efe8fb1510b11d78399231df4b578 (diff)
test: Rename SeedRand::SEED to FIXED_SEED for clarity
Diffstat (limited to 'src')
-rw-r--r--src/test/util/random.cpp2
-rw-r--r--src/test/util/random.h12
-rw-r--r--src/test/util/setup_common.cpp2
-rw-r--r--src/test/util/setup_common.h2
4 files changed, 13 insertions, 5 deletions
diff --git a/src/test/util/random.cpp b/src/test/util/random.cpp
index b568f275a5..32d785e45d 100644
--- a/src/test/util/random.cpp
+++ b/src/test/util/random.cpp
@@ -36,7 +36,7 @@ void SeedRandomStateForTest(SeedRand seedtype)
return GetRandHash();
}();
- const uint256& seed{seedtype == SeedRand::SEED ? ctx_seed : uint256::ZERO};
+ const uint256& seed{seedtype == SeedRand::FIXED_SEED ? ctx_seed : uint256::ZERO};
LogInfo("Setting random seed for current tests to %s=%s\n", RANDOM_CTX_SEED, seed.GetHex());
MakeRandDeterministicDANGEROUS(seed);
}
diff --git a/src/test/util/random.h b/src/test/util/random.h
index c458534d48..441150e666 100644
--- a/src/test/util/random.h
+++ b/src/test/util/random.h
@@ -12,8 +12,16 @@
#include <cstdint>
enum class SeedRand {
- ZEROS, //!< Seed with a compile time constant of zeros
- SEED, //!< Use (and report) random seed from environment, or a (truly) random one.
+ /**
+ * Seed with a compile time constant of zeros.
+ */
+ ZEROS,
+ /**
+ * Seed with a fixed value that never changes over the lifetime of this
+ * process. The seed is read from the RANDOM_CTX_SEED environment variable
+ * if set, otherwise generated randomly once, saved, and reused.
+ */
+ FIXED_SEED,
};
/** Seed the global RNG state for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index dcf72cf627..cffc1273f0 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -154,7 +154,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, TestOpts opts)
// Use randomly chosen seed for deterministic PRNG, so that (by default) test
// data directories use a random name that doesn't overlap with other tests.
- SeedRandomForTest(SeedRand::SEED);
+ SeedRandomForTest(SeedRand::FIXED_SEED);
if (!m_node.args->IsArgSet("-testdatadir")) {
// By default, the data directory has a random name
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
index d995549ca6..a9a890b1a5 100644
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -68,7 +68,7 @@ struct BasicTestingSetup {
FastRandomContext m_rng;
/** Seed the global RNG state and m_rng for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */
- void SeedRandomForTest(SeedRand seed = SeedRand::SEED)
+ void SeedRandomForTest(SeedRand seed)
{
SeedRandomStateForTest(seed);
m_rng.Reseed(GetRandHash());