Simplify testing RNG code

This commit is contained in:
Pieter Wuille 2018-10-31 15:51:57 -07:00
parent fd3e7973ff
commit 022cf47dd7
3 changed files with 5 additions and 12 deletions

View file

@ -189,8 +189,8 @@ public:
prevector_tester() {
SeedInsecureRand();
rand_seed = insecure_rand_seed;
rand_cache = insecure_rand_ctx;
rand_seed = InsecureRand256();
rand_cache = FastRandomContext(rand_seed);
}
};

View file

@ -36,8 +36,7 @@ void CConnmanTest::ClearNodes()
g_connman->vNodes.clear();
}
uint256 insecure_rand_seed = GetRandHash();
FastRandomContext insecure_rand_ctx(insecure_rand_seed);
FastRandomContext insecure_rand_ctx;
extern bool fPrintToConsole;
extern void noui_connect();

View file

@ -26,17 +26,11 @@ std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::os
return stream << static_cast<typename std::underlying_type<T>::type>(e);
}
extern uint256 insecure_rand_seed;
extern FastRandomContext insecure_rand_ctx;
static inline void SeedInsecureRand(bool fDeterministic = false)
static inline void SeedInsecureRand(bool deterministic = false)
{
if (fDeterministic) {
insecure_rand_seed = uint256();
} else {
insecure_rand_seed = GetRandHash();
}
insecure_rand_ctx = FastRandomContext(insecure_rand_seed);
insecure_rand_ctx = FastRandomContext(deterministic);
}
static inline uint32_t InsecureRand32() { return insecure_rand_ctx.rand32(); }