![]() |
Bitcoin Core 30.99.0
P2P Digital Currency
|
Testing fixture that pre-creates a 100-block REGTEST-mode block chain. More...
#include <setup_common.h>
Public Member Functions | |
| TestChain100Setup (ChainType chain_type=ChainType::REGTEST, TestOpts={}) | |
| 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 to the current chain. More... | |
| CBlock | CreateBlock (const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, Chainstate &chainstate) |
| Create a new block with just given transactions, coinbase paying to scriptPubKey. More... | |
| void | mineBlocks (int num_blocks) |
| Mine a series of new blocks on the active chain. More... | |
| 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. More... | |
| 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. More... | |
| CMutableTransaction | CreateValidMempoolTransaction (CTransactionRef input_transaction, uint32_t input_vout, int input_height, CKey input_signing_key, CScript output_destination, CAmount output_amount=CAmount(1 *COIN), bool submit=true) |
| Create a 1-in-1-out transaction and, optionally, submit to the mempool. More... | |
| std::vector< CTransactionRef > | PopulateMempool (FastRandomContext &det_rand, size_t num_transactions, bool submit) |
| Create transactions spending from m_coinbase_txns. More... | |
Public Member Functions inherited from TestingSetup | |
| TestingSetup (ChainType chainType=ChainType::MAIN, TestOpts={}) | |
Public Member Functions inherited from ChainTestingSetup | |
| ChainTestingSetup (ChainType chainType=ChainType::MAIN, TestOpts={}) | |
| ~ChainTestingSetup () | |
| void | LoadVerifyActivateChainstate () |
Public Member Functions inherited from BasicTestingSetup | |
| void | SeedRandomForTest (SeedRand seed) |
| Seed the global RNG state and m_rng for testing and log the seed value. More... | |
| BasicTestingSetup (ChainType chainType=ChainType::MAIN, TestOpts={}) | |
| ~BasicTestingSetup () | |
Public Attributes | |
| std::vector< CTransactionRef > | m_coinbase_txns |
| CKey | coinbaseKey |
Public Attributes inherited from ChainTestingSetup | |
| kernel::CacheSizes | m_kernel_cache_sizes {node::CalculateCacheSizes(m_args).kernel} |
| bool | m_coins_db_in_memory {true} |
| bool | m_block_tree_db_in_memory {true} |
| std::function< void()> | m_make_chainman {} |
Public Attributes inherited from BasicTestingSetup | |
| util::SignalInterrupt | m_interrupt |
| node::NodeContext | m_node |
| FastRandomContext | m_rng |
| fs::path | m_path_root |
| fs::path | m_path_lock |
| bool | m_has_custom_datadir {false} |
| ArgsManager | m_args |
| Test-specific arguments and settings. More... | |
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
Definition at line 146 of file setup_common.h.
| TestChain100Setup::TestChain100Setup | ( | ChainType | chain_type = ChainType::REGTEST, |
| TestOpts | opts = {} |
||
| ) |
| CBlock TestChain100Setup::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 to the current chain.
If no chainstate is specified, default to the active.
Definition at line 429 of file setup_common.cpp.
| CBlock TestChain100Setup::CreateBlock | ( | const std::vector< CMutableTransaction > & | txns, |
| const CScript & | scriptPubKey, | ||
| Chainstate & | chainstate | ||
| ) |
Create a new block with just given transactions, coinbase paying to scriptPubKey.
Definition at line 409 of file setup_common.cpp.
| CMutableTransaction TestChain100Setup::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.
| input_transactions | The transactions to spend |
| inputs | Outpoints with which to construct transaction vin. |
| input_height | The height of the block that included the input transaction(s). |
| input_signing_keys | The keys to spend inputs. |
| outputs | Transaction vout. |
| submit | Whether or not to submit to mempool |
Definition at line 509 of file setup_common.cpp.
| CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction | ( | CTransactionRef | input_transaction, |
| uint32_t | input_vout, | ||
| int | input_height, | ||
| CKey | input_signing_key, | ||
| CScript | output_destination, | ||
| CAmount | output_amount = CAmount(1 * COIN), |
||
| bool | submit = true |
||
| ) |
Create a 1-in-1-out transaction and, optionally, submit to the mempool.
| input_transaction | The transaction to spend |
| input_vout | The vout to spend from the input_transaction |
| input_height | The height of the block that included the input_transaction |
| input_signing_key | The key to spend the input_transaction |
| output_destination | Where to send the output |
| output_amount | How much to send |
| submit | Whether or not to submit to mempool |
Definition at line 526 of file setup_common.cpp.
| std::pair< CMutableTransaction, CAmount > TestChain100Setup::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.
Note: The feerate may not be met exactly depending on whether the signatures can have different sizes.
| input_transactions | The transactions to spend |
| inputs | Outpoints with which to construct transaction vin. |
| input_height | The height of the block that included the input transactions. |
| input_signing_keys | The keys to spend the input transactions. |
| outputs | Transaction vout. |
| feerate | The feerate the transaction should pay. |
| fee_output | The index of the output to take the fee from. |
Definition at line 445 of file setup_common.cpp.
| void TestChain100Setup::mineBlocks | ( | int | num_blocks | ) |
Mine a series of new blocks on the active chain.
Definition at line 398 of file setup_common.cpp.
| std::vector< CTransactionRef > TestChain100Setup::PopulateMempool | ( | FastRandomContext & | det_rand, |
| size_t | num_transactions, | ||
| bool | submit | ||
| ) |
Create transactions spending from m_coinbase_txns.
These transactions will only spend coins that exist in the current chain, but may be premature coinbase spends, have missing signatures, or violate some other consensus rules. They should only be used for testing mempool consistency. All transactions will have some random number of inputs and outputs (between 1 and 24). Transactions may or may not be dependent upon each other; if dependencies exit, every parent will always be somewhere in the list before the child so each transaction can be submitted in the same order they appear in the list.
| [in] | submit | When true, submit transactions to the mempool. When false, return them but don't submit them. |
Definition at line 544 of file setup_common.cpp.
| CKey TestChain100Setup::coinbaseKey |
Definition at line 242 of file setup_common.h.
| std::vector<CTransactionRef> TestChain100Setup::m_coinbase_txns |
Definition at line 241 of file setup_common.h.