Skip to content

Commit 022cf47

Browse files
committed
Simplify testing RNG code
1 parent fd3e797 commit 022cf47

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

src/test/prevector_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ class prevector_tester {
189189

190190
prevector_tester() {
191191
SeedInsecureRand();
192-
rand_seed = insecure_rand_seed;
193-
rand_cache = insecure_rand_ctx;
192+
rand_seed = InsecureRand256();
193+
rand_cache = FastRandomContext(rand_seed);
194194
}
195195
};
196196

src/test/test_bitcoin.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ void CConnmanTest::ClearNodes()
3636
g_connman->vNodes.clear();
3737
}
3838

39-
uint256 insecure_rand_seed = GetRandHash();
40-
FastRandomContext insecure_rand_ctx(insecure_rand_seed);
39+
FastRandomContext insecure_rand_ctx;
4140

4241
extern bool fPrintToConsole;
4342
extern void noui_connect();

src/test/test_bitcoin.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,11 @@ std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::os
2626
return stream << static_cast<typename std::underlying_type<T>::type>(e);
2727
}
2828

29-
extern uint256 insecure_rand_seed;
3029
extern FastRandomContext insecure_rand_ctx;
3130

32-
static inline void SeedInsecureRand(bool fDeterministic = false)
31+
static inline void SeedInsecureRand(bool deterministic = false)
3332
{
34-
if (fDeterministic) {
35-
insecure_rand_seed = uint256();
36-
} else {
37-
insecure_rand_seed = GetRandHash();
38-
}
39-
insecure_rand_ctx = FastRandomContext(insecure_rand_seed);
33+
insecure_rand_ctx = FastRandomContext(deterministic);
4034
}
4135

4236
static inline uint32_t InsecureRand32() { return insecure_rand_ctx.rand32(); }

0 commit comments

Comments
 (0)