Simplify testing RNG code

This commit is contained in:
Pieter Wuille committed 2018-12-12 14:28:15 -08:00
1 parent fd3e7973ff
commit 022cf47dd7
3 files changed
+5 -12

No files matched your search

+2 -2
View File
@@ -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);
} }
}; };
+1 -2
View File
@@ -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();
+2 -8
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); 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(); }