5#ifndef BITCOIN_TEST_UTIL_SETUP_COMMON_H
6#define BITCOIN_TEST_UTIL_SETUP_COMMON_H
156 const std::vector<CMutableTransaction>& txns,
175 std::pair<CMutableTransaction, CAmount>
CreateValidTransaction(
const std::vector<CTransactionRef>& input_transactions,
176 const std::vector<COutPoint>& inputs,
178 const std::vector<CKey>& input_signing_keys,
179 const std::vector<CTxOut>& outputs,
180 const std::optional<CFeeRate>& feerate,
181 const std::optional<uint32_t>& fee_output);
193 const std::vector<COutPoint>& inputs,
195 const std::vector<CKey>& input_signing_keys,
196 const std::vector<CTxOut>& outputs,
213 CKey input_signing_key,
240template <
class T = const BasicTestingSetup>
243 opts.extra_args =
Cat(
250 return std::make_unique<T>(chain_type, opts);
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
An encapsulated private key.
Serialized script, used inside transaction inputs and outputs.
A basic thread-safe queue, used for queuing sockets to be returned by Accept().
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
void Reseed(const uint256 &seed) noexcept
Reseed with explicit seed (only for testing).
decltype(CreateSock) m_create_sock_orig
Save the original value of CreateSock here and restore it when the test ends.
std::shared_ptr< DynSock::Pipes > ConnectClient(std::span< const std::byte > data)
Connect to the socket with a mock client (a DynSock) and send pre-loaded data.
DynSock::Queue m_accepted_sockets
Queue of connected sockets returned by listening socket (represents network interface)
Helper class that manages an interrupt flag, and allows a thread or signal to interrupt another threa...
CacheSizes CalculateCacheSizes(const ArgsManager &args, size_t n_indexes)
std::function< std::unique_ptr< Sock >(int, int, int)> CreateSock
Socket factory.
std::shared_ptr< const CTransaction > CTransactionRef
uint256 GetRandHash() noexcept
Generate a random uint256.
static constexpr CAmount CENT
void SetupCommonTestArgs(ArgsManager &argsman)
Register common test args.
const std::function< std::vector< const char * >()> G_TEST_COMMAND_LINE_ARGUMENTS
Retrieve the command line arguments.
std::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, TestOpts opts={})
Make a test setup that has disk access to the debug.log file disabled.
const std::function< std::string()> G_TEST_GET_FULL_NAME
Retrieve the unit test name.
ArgsManager m_args
Test-specific arguments and settings.
bool m_has_custom_datadir
BasicTestingSetup(ChainType chainType=ChainType::MAIN, TestOpts={})
void SeedRandomForTest(SeedRand seed)
Seed the global RNG state and m_rng for testing and log the seed value.
util::SignalInterrupt m_interrupt
A mutable version of CTransaction.
Testing setup that performs all steps up until right before ChainstateManager gets initialized.
ChainTestingSetup(ChainType chainType=ChainType::MAIN, TestOpts={})
kernel::CacheSizes m_kernel_cache_sizes
bool m_block_tree_db_in_memory
std::function< void()> m_make_chainman
void LoadVerifyActivateChainstate()
bool m_coins_db_in_memory
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(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.
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.
CBlock CreateAndProcessBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey)
Create a new block with just given transactions, coinbase paying to scriptPubKey, and try to add it t...
TestChain100Setup(ChainType chain_type=ChainType::REGTEST, TestOpts={})
std::vector< CTransactionRef > PopulateMempool(FastRandomContext &det_rand, size_t num_transactions, bool submit)
Create transactions spending from m_coinbase_txns.
CBlock CreateBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey)
Create a new block with just given transactions, coinbase paying to scriptPubKey.
bool min_validation_cache
bool block_tree_db_in_memory
std::vector< const char * > extra_args
bool setup_validation_interface
Testing setup that configures a complete environment.
TestingSetup(ChainType chainType=ChainType::MAIN, TestOpts={})
Identical to TestingSetup, but chain set to testnet4.
kernel::CacheSizes kernel
NodeContext struct containing references to chain state and connection state.
SeedRandomStateForTest(SeedRand::ZEROS)
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.