5 #ifndef BITCOIN_TEST_UTIL_SETUP_COMMON_H 6 #define BITCOIN_TEST_UTIL_SETUP_COMMON_H 22 #include <type_traits> 30 extern const std::function<void(const std::string&)>
G_TEST_LOG_FUN;
38 std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream,
const T& e)
40 return stream << static_cast<typename std::underlying_type<T>::type>(e);
81 const std::vector<const char*>& extra_args = {},
82 const bool coins_db_in_memory =
true,
83 const bool block_tree_db_in_memory =
true);
102 const std::vector<const char*>& extra_args = {},
103 const bool coins_db_in_memory =
true,
104 const bool block_tree_db_in_memory =
true);
120 const std::vector<CMutableTransaction>& txns,
140 std::pair<CMutableTransaction, CAmount>
CreateValidTransaction(
const std::vector<CTransactionRef>& input_transactions,
141 const std::vector<COutPoint>& inputs,
143 const std::vector<CKey>& input_signing_keys,
144 const std::vector<CTxOut>& outputs,
145 const std::optional<CFeeRate>& feerate,
146 const std::optional<uint32_t>& fee_output);
158 const std::vector<COutPoint>& inputs,
160 const std::vector<CKey>& input_signing_keys,
161 const std::vector<CTxOut>& outputs,
178 CKey input_signing_key,
215 template <
class T = const BasicTestingSetup>
218 const std::vector<const char*> arguments =
Cat(
225 return std::make_unique<T>(chain_type, arguments);
244 return std::string(e.what()).find(
m_reason) != std::string::npos;
251 #endif // BITCOIN_TEST_UTIL_SETUP_COMMON_H std::shared_ptr< const CTransaction > CTransactionRef
Testing setup that performs all steps up until right before ChainstateManager gets initialized...
ChainTestingSetup(const ChainType chainType=ChainType::MAIN, const std::vector< const char *> &extra_args={})
void MockMempoolMinFee(const CFeeRate &target_feerate)
Mock the mempool minimum feerate by adding a transaction and calling TrimToSize(0), simulating the mempool "reaching capacity" and evicting by descendant feerate.
bool m_block_tree_db_in_memory
node::CacheSizes m_cache_sizes
std::vector< CTransactionRef > m_coinbase_txns
std::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, const std::vector< const char *> &extra_args={})
Make a test setup that has disk access to the debug.log file disabled.
BasicTestingSetup(const ChainType chainType=ChainType::MAIN, const std::vector< const char *> &extra_args={})
util::SignalInterrupt m_interrupt
int64_t CAmount
Amount in satoshis (Can be negative)
NodeContext struct containing references to chain state and connection state.
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...
Chainstate stores and provides an API to update our local knowledge of the current best chain...
std::vector< CTransactionRef > PopulateMempool(FastRandomContext &det_rand, size_t num_transactions, bool submit)
Create transactions spending from m_coinbase_txns.
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
void mineBlocks(int num_blocks)
Mine a series of new blocks on the active chain.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
TestChain100Setup(const ChainType chain_type=ChainType::REGTEST, const std::vector< const char *> &extra_args={}, const bool coins_db_in_memory=true, const bool block_tree_db_in_memory=true)
std::pair< CMutableTransaction, CAmount > CreateValidTransaction(const std::vector< CTransactionRef > &input_transactions, const std::vector< COutPoint > &inputs, int input_height, const std::vector< CKey > &input_signing_keys, const std::vector< CTxOut > &outputs, const std::optional< CFeeRate > &feerate, const std::optional< uint32_t > &fee_output)
Create a transaction, optionally setting the fee based on the feerate.
HasReason(const std::string &reason)
Serialized script, used inside transaction inputs and outputs.
CMutableTransaction CreateValidMempoolTransaction(const std::vector< CTransactionRef > &input_transactions, const std::vector< COutPoint > &inputs, int input_height, const std::vector< CKey > &input_signing_keys, const std::vector< CTxOut > &outputs, bool submit=true)
Create a transaction and, optionally, submit to the mempool.
CBlock CreateBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, Chainstate &chainstate)
Create a new block with just given transactions, coinbase paying to scriptPubKey. ...
bool operator()(const std::exception &e) const
std::ostream & operator<<(std::ostream &os, const uint256 &num)
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
const std::function< void(const std::string &)> G_TEST_LOG_FUN
This is connected to the logger.
bool m_coins_db_in_memory
A mutable version of CTransaction.
const std::function< std::vector< const char * >)> G_TEST_COMMAND_LINE_ARGUMENTS
Retrieve the command line arguments.
static constexpr CAmount CENT
An encapsulated private key.
TestingSetup(const ChainType chainType=ChainType::MAIN, const std::vector< const char *> &extra_args={}, const bool coins_db_in_memory=true, const bool block_tree_db_in_memory=true)
Identical to TestingSetup, but chain set to regtest.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
void LoadVerifyActivateChainstate()
#define T(expected, seed, data)
Testing setup that configures a complete environment.
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
static constexpr CAmount COIN
The amount of satoshis in one BTC.
const fs::path m_path_root
const std::string m_reason