5#ifndef BITCOIN_TEST_UTIL_SETUP_COMMON_H
6#define BITCOIN_TEST_UTIL_SETUP_COMMON_H
25extern const std::function<void(
const std::string&)>
G_TEST_LOG_FUN;
29std::ostream&
operator<<(
typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream,
const T& e)
31 return stream << static_cast<typename std::underlying_type<T>::type>(e);
133 const std::vector<CMutableTransaction>& txns,
154 CKey input_signing_key,
167template <
class T = const BasicTestingSetup>
170 const std::vector<const char*> arguments =
Cat(
177 return std::make_unique<T>(chain_name, arguments);
223 return std::string(e.what()).find(
m_reason) != std::string::npos;
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) of a given ins...
static const std::string REGTEST
static const std::string MAIN
Chain name strings.
CChainState stores and provides an API to update our local knowledge of the current best chain.
An encapsulated private key.
Serialized script, used inside transaction inputs and outputs.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Users of this module must hold an ECCVerifyHandle.
uint32_t rand32() noexcept
Generate a random 32-bit integer.
uint256 rand256() noexcept
generate a random uint256.
bool randbool() noexcept
Generate a random boolean.
uint64_t randbits(int bits) noexcept
Generate a random (bits)-bit integer.
uint64_t randrange(uint64_t range) noexcept
Generate a random integer in the range [0..range).
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
HasReason(const std::string &reason)
const std::string m_reason
bool operator()(const std::exception &e) const
Path class wrapper to prepare application code for transition from boost::filesystem library to std::...
#define T(expected, seed, data)
std::shared_ptr< const CTransaction > CTransactionRef
@ ZEROS
Seed with a compile time constant of zeros.
@ SEED
Call the Seed() helper.
bool g_mock_deterministic_tests
Flag to make GetRand in random.h return the same number.
std::ostream & operator<<(typename std::enable_if< std::is_enum< T >::value, std::ostream >::type &stream, const T &e)
static uint64_t InsecureRandRange(uint64_t range)
static constexpr CAmount CENT
const std::function< void(const std::string &)> G_TEST_LOG_FUN
This is connected to the logger.
static uint256 InsecureRand256()
static void SeedInsecureRand(SeedRand seed=SeedRand::SEED)
void Seed(FastRandomContext &ctx)
Seed the given random ctx or use the seed passed in via an environment var.
static uint64_t InsecureRandBits(int bits)
std::unique_ptr< T > MakeNoLogFileContext(const std::string &chain_name=CBaseChainParams::REGTEST, const std::vector< const char * > &extra_args={})
Make a test setup that has disk access to the debug.log file disabled.
static uint32_t InsecureRand32()
FastRandomContext g_insecure_rand_ctx
This global and the helpers that use it are not thread-safe.
static bool InsecureRandBool()
BasicTestingSetup(const std::string &chainName=CBaseChainParams::MAIN, const std::vector< const char * > &extra_args={})
ECCVerifyHandle globalVerifyHandle
const fs::path m_path_root
A mutable version of CTransaction.
Testing setup that performs all steps up until right before ChainstateManager gets initialized.
ChainTestingSetup(const std::string &chainName=CBaseChainParams::MAIN, const std::vector< const char * > &extra_args={})
NodeContext struct containing references to chain state and connection state.
Identical to TestingSetup, but chain set to regtest.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
void mineBlocks(int num_blocks)
Mine a series of new blocks on the active chain.
std::vector< CTransactionRef > m_coinbase_txns
CMutableTransaction CreateValidMempoolTransaction(CTransactionRef input_transaction, int input_vout, int input_height, CKey input_signing_key, CScript output_destination, CAmount output_amount=CAmount(1 *COIN), bool submit=true)
Create a transaction and submit to the mempool.
CBlock CreateBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, CChainState &chainstate)
Create a new block with just given transactions, coinbase paying to scriptPubKey.
CBlock CreateAndProcessBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, CChainState *chainstate=nullptr)
Create a new block with just given transactions, coinbase paying to scriptPubKey, and try to add it t...
TestChain100Setup(const std::vector< const char * > &extra_args={})
TestMemPoolEntryHelper & SigOpsCost(unsigned int _sigopsCost)
TestMemPoolEntryHelper & Time(int64_t _time)
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
TestMemPoolEntryHelper & SpendsCoinbase(bool _flag)
TestMemPoolEntryHelper & Height(unsigned int _height)
TestMemPoolEntryHelper & Fee(CAmount _fee)
Testing setup that configures a complete environment.
TestingSetup(const std::string &chainName=CBaseChainParams::MAIN, const std::vector< const char * > &extra_args={})
static secp256k1_context * ctx
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.