5 #ifndef BITCOIN_TEST_UTIL_SETUP_COMMON_H
6 #define BITCOIN_TEST_UTIL_SETUP_COMMON_H
23 #include <type_traits>
29 extern const std::function<void(
const std::string&)>
G_TEST_LOG_FUN;
37 std::ostream&
operator<<(
typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream,
const T& e)
39 return stream << static_cast<typename std::underlying_type<T>::type>(e);
110 const std::vector<const char*>& extra_args = {},
111 const bool coins_db_in_memory =
true,
112 const bool block_tree_db_in_memory =
true);
131 const std::vector<const char*>& extra_args = {},
132 const bool coins_db_in_memory =
true,
133 const bool block_tree_db_in_memory =
true);
149 const std::vector<CMutableTransaction>& txns,
170 CKey input_signing_key,
196 template <
class T = const BasicTestingSetup>
199 const std::vector<const char*> arguments =
Cat(
206 return std::make_unique<T>(chain_name, arguments);
225 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.
An encapsulated private key.
Serialized script, used inside transaction inputs and outputs.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
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 block calls to the fs::path(std::string) implicit constructor and the fs::path:...
std::ostream & operator<<(typename std::enable_if< std::is_enum< T >::value, std::ostream >::type &stream, const T &e)
std::shared_ptr< const CTransaction > CTransactionRef
std::ostream & operator<<(std::ostream &os, const uint256 &num)
@ 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::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 constexpr CAmount CENT
const std::function< void(const std::string &)> G_TEST_LOG_FUN
This is connected to the logger.
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.
const std::function< std::vector< const char * >)> G_TEST_COMMAND_LINE_ARGUMENTS
Retrieve the command line arguments.
FastRandomContext g_insecure_rand_ctx
This global and the helpers that use it are not thread-safe.
BasicTestingSetup(const std::string &chainName=CBaseChainParams::MAIN, const std::vector< const char * > &extra_args={})
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={})
node::CacheSizes m_cache_sizes
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.
TestChain100Setup(const std::string &chain_name=CBaseChainParams::REGTEST, const std::vector< const char * > &extra_args={}, const bool coins_db_in_memory=true, const bool block_tree_db_in_memory=true)
std::vector< CTransactionRef > PopulateMempool(FastRandomContext &det_rand, size_t num_transactions, bool submit)
Create transactions spending from m_coinbase_txns.
CBlock CreateAndProcessBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, Chainstate *chainstate=nullptr)
Create a new block with just given transactions, coinbase paying to scriptPubKey, and try to add it t...
CBlock CreateBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, Chainstate &chainstate)
Create a new block with just given transactions, coinbase paying to scriptPubKey.
Testing setup that configures a complete environment.
bool m_block_tree_db_in_memory
bool m_coins_db_in_memory
void LoadVerifyActivateChainstate()
TestingSetup(const std::string &chainName=CBaseChainParams::MAIN, const std::vector< const char * > &extra_args={}, const bool coins_db_in_memory=true, const bool block_tree_db_in_memory=true)
NodeContext struct containing references to chain state and connection state.
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.