mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Simplify testing RNG code
This commit is contained in:
parent
fd3e7973ff
commit
022cf47dd7
3 changed files with 5 additions and 12 deletions
|
@ -189,8 +189,8 @@ public:
|
||||||
|
|
||||||
prevector_tester() {
|
prevector_tester() {
|
||||||
SeedInsecureRand();
|
SeedInsecureRand();
|
||||||
rand_seed = insecure_rand_seed;
|
rand_seed = InsecureRand256();
|
||||||
rand_cache = insecure_rand_ctx;
|
rand_cache = FastRandomContext(rand_seed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,7 @@ void CConnmanTest::ClearNodes()
|
||||||
g_connman->vNodes.clear();
|
g_connman->vNodes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 insecure_rand_seed = GetRandHash();
|
FastRandomContext insecure_rand_ctx;
|
||||||
FastRandomContext insecure_rand_ctx(insecure_rand_seed);
|
|
||||||
|
|
||||||
extern bool fPrintToConsole;
|
extern bool fPrintToConsole;
|
||||||
extern void noui_connect();
|
extern void noui_connect();
|
||||||
|
|
|
@ -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);
|
return stream << static_cast<typename std::underlying_type<T>::type>(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern uint256 insecure_rand_seed;
|
|
||||||
extern FastRandomContext insecure_rand_ctx;
|
extern FastRandomContext insecure_rand_ctx;
|
||||||
|
|
||||||
static inline void SeedInsecureRand(bool fDeterministic = false)
|
static inline void SeedInsecureRand(bool deterministic = false)
|
||||||
{
|
{
|
||||||
if (fDeterministic) {
|
insecure_rand_ctx = FastRandomContext(deterministic);
|
||||||
insecure_rand_seed = uint256();
|
|
||||||
} else {
|
|
||||||
insecure_rand_seed = GetRandHash();
|
|
||||||
}
|
|
||||||
insecure_rand_ctx = FastRandomContext(insecure_rand_seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t InsecureRand32() { return insecure_rand_ctx.rand32(); }
|
static inline uint32_t InsecureRand32() { return insecure_rand_ctx.rand32(); }
|
||||||
|
|
Loading…
Add table
Reference in a new issue