mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-24 22:45:41 +01:00
test: refactor: Move g_insecure_rand_ctx.Reseed out of the helper that calls MakeRandDeterministicDANGEROUS
The global g_insecure_rand_ctx will be removed in the future, so removing it from this helper is useful. Also, tying the two concepts of the global internal RNGState and the global test-only rng context is a bit confusing, because tests can simply use the m_rng, if it exists. Also, tests may seed more than one random context, or none at all, or a random context of a different type. Fix all issues by moving the Reseed call to the two places where it is used.
This commit is contained in:
@@ -15,7 +15,7 @@ FastRandomContext g_insecure_rand_ctx;
|
||||
|
||||
extern void MakeRandDeterministicDANGEROUS(const uint256& seed) noexcept;
|
||||
|
||||
void SeedRandomForTest(SeedRand seedtype)
|
||||
void SeedRandomStateForTest(SeedRand seedtype)
|
||||
{
|
||||
static const std::string RANDOM_CTX_SEED{"RANDOM_CTX_SEED"};
|
||||
|
||||
@@ -34,5 +34,4 @@ void SeedRandomForTest(SeedRand seedtype)
|
||||
const uint256& seed{seedtype == SeedRand::SEED ? ctx_seed : uint256::ZERO};
|
||||
LogPrintf("%s: Setting random seed for current tests to %s=%s\n", __func__, RANDOM_CTX_SEED, seed.GetHex());
|
||||
MakeRandDeterministicDANGEROUS(seed);
|
||||
g_insecure_rand_ctx.Reseed(GetRandHash());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user