LCOV - code coverage report
Current view: top level - src/test/util - random.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 12 12 100.0 %
Date: 2026-06-25 07:23:43 Functions: 6 6 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2023 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 <test/util/setup_common.h>
      11             : #include <uint256.h>
      12             : 
      13             : #include <cstdint>
      14             : 
      15    16554078 : static inline uint32_t InsecureRand32()
      16             : {
      17    16554078 :     return g_insecure_rand_ctx.rand32();
      18             : }
      19             : 
      20      389880 : static inline uint256 InsecureRand256()
      21             : {
      22      389880 :     return g_insecure_rand_ctx.rand256();
      23             : }
      24             : 
      25     3343630 : static inline uint64_t InsecureRandBits(int bits)
      26             : {
      27     3343630 :     return g_insecure_rand_ctx.randbits(bits);
      28             : }
      29             : 
      30     5869801 : static inline uint64_t InsecureRandRange(uint64_t range)
      31             : {
      32     5869801 :     return g_insecure_rand_ctx.randrange(range);
      33             : }
      34             : 
      35      646839 : static inline bool InsecureRandBool()
      36             : {
      37      646839 :     return g_insecure_rand_ctx.randbool();
      38             : }
      39             : 
      40      174017 : static inline CAmount InsecureRandMoneyAmount()
      41             : {
      42      174017 :     return static_cast<CAmount>(InsecureRandRange(MAX_MONEY + 1));
      43             : }
      44             : 
      45             : #endif // BITCOIN_TEST_UTIL_RANDOM_H

Generated by: LCOV version 1.16