Skip to content

Commit 2222f7a

Browse files
author
MarcoFalke
committed
test: Rename SeedRand::SEED to FIXED_SEED for clarity
1 parent 4ee1940 commit 2222f7a

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/test/util/random.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void SeedRandomStateForTest(SeedRand seedtype)
3636
return GetRandHash();
3737
}();
3838

39-
const uint256& seed{seedtype == SeedRand::SEED ? ctx_seed : uint256::ZERO};
39+
const uint256& seed{seedtype == SeedRand::FIXED_SEED ? ctx_seed : uint256::ZERO};
4040
LogInfo("Setting random seed for current tests to %s=%s\n", RANDOM_CTX_SEED, seed.GetHex());
4141
MakeRandDeterministicDANGEROUS(seed);
4242
}

src/test/util/random.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@
1212
#include <cstdint>
1313

1414
enum class SeedRand {
15-
ZEROS, //!< Seed with a compile time constant of zeros
16-
SEED, //!< Use (and report) random seed from environment, or a (truly) random one.
15+
/**
16+
* Seed with a compile time constant of zeros.
17+
*/
18+
ZEROS,
19+
/**
20+
* Seed with a fixed value that never changes over the lifetime of this
21+
* process. The seed is read from the RANDOM_CTX_SEED environment variable
22+
* if set, otherwise generated randomly once, saved, and reused.
23+
*/
24+
FIXED_SEED,
1725
};
1826

1927
/** Seed the global RNG state for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */

src/test/util/setup_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, TestOpts opts)
154154

155155
// Use randomly chosen seed for deterministic PRNG, so that (by default) test
156156
// data directories use a random name that doesn't overlap with other tests.
157-
SeedRandomForTest(SeedRand::SEED);
157+
SeedRandomForTest(SeedRand::FIXED_SEED);
158158

159159
if (!m_node.args->IsArgSet("-testdatadir")) {
160160
// By default, the data directory has a random name

src/test/util/setup_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct BasicTestingSetup {
6868

6969
FastRandomContext m_rng;
7070
/** Seed the global RNG state and m_rng for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */
71-
void SeedRandomForTest(SeedRand seed = SeedRand::SEED)
71+
void SeedRandomForTest(SeedRand seed)
7272
{
7373
SeedRandomStateForTest(seed);
7474
m_rng.Reseed(GetRandHash());

0 commit comments

Comments
 (0)