<commit_before>// Copyright (c) 2015-2016 The Bitcoin Core developers
// Copyright (c) 2015-2019 The Bitcoin Unlimited developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_TEST_TEST_BITCOIN_H
#define BITCOIN_TEST_TEST_BITCOIN_H

#include "chainparamsbase.h"
#include "fs.h"
#include "key.h"
#include "net.h"
#include "pubkey.h"
#include "random.h"
#include "txdb.h"
#include "txmempool.h"

#include <thread>

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(); }
static inline uint32_t InsecureRand32() { return insecure_rand_ctx.rand32(); }
static inline uint256 InsecureRand256(void) { return GetRandHash(); }
/** Basic testing setup.
 * This just configures logging and chain parameters.
 */
struct BasicTestingSetup
{
    ECCVerifyHandle globalVerifyHandle;

    BasicTestingSetup(const std::string &chainName = CBaseChainParams::MAIN);
    ~BasicTestingSetup();
};

/** Testing setup that configures a complete environment.
 * Included are data directory, coins database, script check threads setup.
 */
struct TestingSetup : public BasicTestingSetup
{
    CCoinsViewDB *pcoinsdbview;
    fs::path pathTemp;
    boost::thread_group threadGroup;

    TestingSetup(const std::string &chainName = CBaseChainParams::MAIN);
    ~TestingSetup();
};

class CBlock;
struct CMutableTransaction;
class CScript;

//<commit_msg>Add various insecure_rand wrappers for tests<commit_after>// Copyright (c) 2015-2016 The Bitcoin Core developers
// Copyright (c) 2015-2019 The Bitcoin Unlimited developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_TEST_TEST_BITCOIN_H
#define BITCOIN_TEST_TEST_BITCOIN_H

#include "chainparamsbase.h"
#include "fs.h"
#include "key.h"
#include "net.h"
#include "pubkey.h"
#include "random.h"
#include "txdb.h"
#include "txmempool.h"

#include <thread>

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() { return insecure_rand_ctx.rand32(); }
static inline uint256 insecure_rand256() { return insecure_rand_ctx.rand256(); }
static inline uint64_t insecure_randbits(int bits) { return insecure_rand_ctx.randbits(bits); }
static inline uint64_t insecure_randrange(uint64_t range) { return insecure_rand_ctx.randrange(range); }
static inline bool insecure_randbool() { return insecure_rand_ctx.randbool(); }
static inline std::vector<unsigned char> insecure_randbytes(size_t len) { return insecure_rand_ctx.randbytes(len); }
static inline uint256 InsecureRand256(void) { return GetRandHash(); }
/** Basic testing setup.
 * This just configures logging and chain parameters.
 */
struct BasicTestingSetup
{
    ECCVerifyHandle globalVerifyHandle;

    BasicTestingSetup(const std::string &chainName = CBaseChainParams::MAIN);
    ~BasicTestingSetup();
};

/** Testing setup that configures a complete environment.
 * Included are data directory, coins database, script check threads setup.
 */
struct TestingSetup : public BasicTestingSetup
{
    CCoinsViewDB *pcoinsdbview;
    fs::path pathTemp;
    boost::thread_group threadGroup;

    TestingSetup(const std::string &chainName = CBaseChainParams::MAIN);
    ~TestingSetup();
};

class CBlock;
struct CMutableTransaction;
class CScript;

//
{'fraction_non_alphanumeric': 0.09648043317745508, 'fraction_numerical': 0.02092050209205021, 'mean_word_length': 5.157575757575757, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5595450', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1222, 'n_words': 325}