 |
Bitcoin Core
23.99.0
P2P Digital Currency
|
Go to the documentation of this file.
5 #ifndef BITCOIN_TEST_UTIL_SETUP_COMMON_H
6 #define BITCOIN_TEST_UTIL_SETUP_COMMON_H
23 #include <type_traits>
27 extern const std::function<void(
const std::string&)>
G_TEST_LOG_FUN;
35 std::ostream&
operator<<(
typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream,
const T& e)
37 return stream << static_cast<typename std::underlying_type<T>::type>(e);
125 const std::vector<const char*>& extra_args = {});
141 const std::vector<CMutableTransaction>& txns,
162 CKey input_signing_key,
188 template <
class T = const BasicTestingSetup>
191 const std::vector<const char*> arguments =
Cat(
198 return std::make_unique<T>(chain_name, arguments);
244 return std::string(e.what()).find(
m_reason) != std::string::npos;
251 #endif // BITCOIN_TEST_UTIL_SETUP_COMMON_H
CBlock CreateBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, CChainState &chainstate)
Create a new block with just given transactions, coinbase paying to scriptPubKey.
std::ostream & operator<<(std::ostream &os, const uint256 &num)
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
Identical to TestingSetup, but chain set to regtest.
const std::function< void(const std::string &)> G_TEST_LOG_FUN
This is connected to the logger.
uint256 rand256() noexcept
generate a random uint256.
static bool InsecureRandBool()
static void SeedInsecureRand(SeedRand seed=SeedRand::SEED)
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.
TestingSetup(const std::string &chainName=CBaseChainParams::MAIN, const std::vector< const char * > &extra_args={})
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
bool randbool() noexcept
Generate a random boolean.
ChainTestingSetup(const std::string &chainName=CBaseChainParams::MAIN, const std::vector< const char * > &extra_args={})
BasicTestingSetup(const std::string &chainName=CBaseChainParams::MAIN, const std::vector< const char * > &extra_args={})
static uint256 InsecureRand256()
NodeContext struct containing references to chain state and connection state.
static uint64_t InsecureRandRange(uint64_t range)
const std::function< std::vector< const char * >)> G_TEST_COMMAND_LINE_ARGUMENTS
Retrieve the command line arguments.
TestMemPoolEntryHelper & SigOpsCost(unsigned int _sigopsCost)
static uint32_t InsecureRand32()
std::shared_ptr< const CTransaction > CTransactionRef
@ SEED
Call the Seed() helper.
uint64_t randbits(int bits) noexcept
Generate a random (bits)-bit integer.
node::CacheSizes m_cache_sizes
@ ZEROS
Seed with a compile time constant of zeros.
FastRandomContext g_insecure_rand_ctx
This global and the helpers that use it are not thread-safe.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
uint32_t rand32() noexcept
Generate a random 32-bit integer.
static const std::string REGTEST
static constexpr CAmount CENT
int64_t CAmount
Amount in satoshis (Can be negative)
std::ostream & operator<<(typename std::enable_if< std::is_enum< T >::value, std::ostream >::type &stream, const T &e)
TestMemPoolEntryHelper & SpendsCoinbase(bool _flag)
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
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.
TestChain100Setup(const std::string &chain_name=CBaseChainParams::REGTEST, const std::vector< const char * > &extra_args={})
CChainState stores and provides an API to update our local knowledge of the current best chain.
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...
Serialized script, used inside transaction inputs and outputs.
static const std::string MAIN
Chain name strings.
std::vector< CTransactionRef > PopulateMempool(FastRandomContext &det_rand, size_t num_transactions, bool submit)
Create transactions spending from m_coinbase_txns.
TestMemPoolEntryHelper & Fee(CAmount _fee)
An encapsulated private key.
std::vector< CTransactionRef > m_coinbase_txns
uint64_t randrange(uint64_t range) noexcept
Generate a random integer in the range [0..range).
const fs::path m_path_root
Testing setup that configures a complete environment.
static uint64_t InsecureRandBits(int bits)
const std::string m_reason
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
HasReason(const std::string &reason)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
A mutable version of CTransaction.
bool operator()(const std::exception &e) const
void mineBlocks(int num_blocks)
Mine a series of new blocks on the active chain.
bool g_mock_deterministic_tests
Flag to make GetRand in random.h return the same number.
TestMemPoolEntryHelper & Height(unsigned int _height)
Testing setup that performs all steps up until right before ChainstateManager gets initialized.
static secp256k1_context * ctx
TestMemPoolEntryHelper & Time(int64_t _time)
void Seed(FastRandomContext &ctx)
Seed the given random ctx or use the seed passed in via an environment var.