test: Rename SeedRand::SEED to FIXED_SEED for clarity
This commit is contained in:
4 files changed
+13
-5
No files matched your search
@@ -36,7 +36,7 @@ void SeedRandomStateForTest(SeedRand seedtype)
|
|||||||
return GetRandHash();
|
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());
|
LogInfo("Setting random seed for current tests to %s=%s\n", RANDOM_CTX_SEED, seed.GetHex());
|
||||||
MakeRandDeterministicDANGEROUS(seed);
|
MakeRandDeterministicDANGEROUS(seed);
|
||||||
}
|
}
|
||||||
+10
-2
@@ -12,8 +12,16 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
enum class SeedRand {
|
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(). */
|
/** Seed the global RNG state for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, TestOpts opts)
|
|||||||
|
|
||||||
// Use randomly chosen seed for deterministic PRNG, so that (by default) test
|
// 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.
|
// 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")) {
|
if (!m_node.args->IsArgSet("-testdatadir")) {
|
||||||
// By default, the data directory has a random name
|
// By default, the data directory has a random name
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ struct BasicTestingSetup {
|
|||||||
|
|
||||||
FastRandomContext m_rng;
|
FastRandomContext m_rng;
|
||||||
/** Seed the global RNG state and m_rng for testing and log the seed value. This affects all randomness, except GetStrongRandBytes(). */
|
/** 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);
|
SeedRandomStateForTest(seed);
|
||||||
m_rng.Reseed(GetRandHash());
|
m_rng.Reseed(GetRandHash());
|
||||||
|
|||||||
Reference in new issue
Block a user