diff options
author | Jon Atack <jon@atack.com> | 2023-01-20 11:05:09 -0800 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2023-02-09 15:03:36 -0800 |
commit | 9d92c3d7f42c18939a9a6aa1ee185f1c958360a0 (patch) | |
tree | 58ee1fceb4c166575e346faaaff2454e41171875 /src/test/util/random.h | |
parent | 81f5ade2a324167c03c5ce765a26bd42ed652723 (diff) | |
download | bitcoin-9d92c3d7f42c18939a9a6aa1ee185f1c958360a0.tar.xz |
Create InsecureRandMoneyAmount() test util helper
to generate semi-random CAmounts up to MAX_MONEY rather
than only uint32, and use it in the unit tests.
Diffstat (limited to 'src/test/util/random.h')
-rw-r--r-- | src/test/util/random.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/test/util/random.h b/src/test/util/random.h index 72c9ec85e2..7997e8a346 100644 --- a/src/test/util/random.h +++ b/src/test/util/random.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_TEST_UTIL_RANDOM_H #define BITCOIN_TEST_UTIL_RANDOM_H +#include <consensus/amount.h> #include <random.h> #include <test/util/setup_common.h> #include <uint256.h> @@ -36,4 +37,9 @@ static inline bool InsecureRandBool() return g_insecure_rand_ctx.randbool(); } +static inline CAmount InsecureRandMoneyAmount() +{ + return static_cast<CAmount>(InsecureRandRange(MAX_MONEY + 1)); +} + #endif // BITCOIN_TEST_UTIL_RANDOM_H |