Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
util
random.h
Go to the documentation of this file.
1
// Copyright (c) 2023-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_TEST_UTIL_RANDOM_H
6
#define BITCOIN_TEST_UTIL_RANDOM_H
7
8
#include <
consensus/amount.h
>
9
#include <
random.h
>
10
#include <
uint256.h
>
11
12
#include <atomic>
13
#include <cstdint>
14
15
enum class
SeedRand
{
19
ZEROS
,
25
FIXED_SEED
,
26
};
27
29
void
SeedRandomStateForTest
(
SeedRand
seed);
30
31
extern
std::atomic<bool>
g_seeded_g_prng_zero
;
32
extern
std::atomic<bool>
g_used_g_prng
;
33
34
template
<RandomNumberGenerator Rng>
35
inline
CAmount
RandMoney
(Rng&& rng)
36
{
37
return
CAmount
{rng.randrange(
MAX_MONEY
+ 1)};
38
}
39
40
#endif
// BITCOIN_TEST_UTIL_RANDOM_H
amount.h
MAX_MONEY
static constexpr CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
Definition
amount.h:26
CAmount
int64_t CAmount
Amount in satoshis (Can be negative).
Definition
amount.h:12
g_used_g_prng
std::atomic< bool > g_used_g_prng
Definition
random.cpp:599
g_seeded_g_prng_zero
std::atomic< bool > g_seeded_g_prng_zero
Definition
random.cpp:15
random.h
SeedRand
SeedRand
Definition
random.h:15
SeedRand::ZEROS
@ ZEROS
Seed with a compile time constant of zeros.
Definition
random.h:19
SeedRand::FIXED_SEED
@ FIXED_SEED
Seed with a fixed value that never changes over the lifetime of this process.
Definition
random.h:25
RandMoney
CAmount RandMoney(Rng &&rng)
Definition
random.h:35
SeedRandomStateForTest
void SeedRandomStateForTest(SeedRand seed)
Seed the global RNG state for testing and log the seed value.
Definition
random.cpp:19
uint256.h
Generated on
for Bitcoin Core by
1.17.0