Make [seed_]insecure_rand available to the gtests
This commit is contained in:
parent
fbd6564152
commit
e861389adc
|
@ -2,6 +2,7 @@
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "pubkey.h"
|
#include "pubkey.h"
|
||||||
|
#include "random.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "utiltest.h"
|
#include "utiltest.h"
|
||||||
|
|
||||||
|
@ -13,6 +14,9 @@
|
||||||
|
|
||||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||||
|
|
||||||
|
uint256 insecure_rand_seed = GetRandHash();
|
||||||
|
FastRandomContext insecure_rand_ctx(insecure_rand_seed);
|
||||||
|
|
||||||
struct ECCryptoClosure
|
struct ECCryptoClosure
|
||||||
{
|
{
|
||||||
ECCVerifyHandle handle;
|
ECCVerifyHandle handle;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef BITCOIN_GTEST_UTILS_H
|
#ifndef BITCOIN_GTEST_UTILS_H
|
||||||
#define BITCOIN_GTEST_UTILS_H
|
#define BITCOIN_GTEST_UTILS_H
|
||||||
|
|
||||||
|
#include "random.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "key_io.h"
|
#include "key_io.h"
|
||||||
|
|
||||||
|
@ -10,4 +11,22 @@ void LoadProofParameters();
|
||||||
void LoadGlobalWallet();
|
void LoadGlobalWallet();
|
||||||
void UnloadGlobalWallet();
|
void UnloadGlobalWallet();
|
||||||
|
|
||||||
|
extern uint256 insecure_rand_seed;
|
||||||
|
extern FastRandomContext insecure_rand_ctx;
|
||||||
|
|
||||||
|
static inline void seed_insecure_rand(bool fDeterministic = false)
|
||||||
|
{
|
||||||
|
if (fDeterministic) {
|
||||||
|
insecure_rand_seed = uint256();
|
||||||
|
} else {
|
||||||
|
insecure_rand_seed = GetRandHash();
|
||||||
|
}
|
||||||
|
insecure_rand_ctx = FastRandomContext(insecure_rand_seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t insecure_rand(void)
|
||||||
|
{
|
||||||
|
return insecure_rand_ctx.rand32();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue