mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
test: Rename SeedRand::SEED to FIXED_SEED for clarity
This commit is contained in:
parent
4ee1940e84
commit
2222f7a874
4 changed files with 13 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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(). */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Add table
Reference in a new issue