38#include <validation.h>
39#include <versionbits.h>
41#include <boost/test/unit_test.hpp>
83 opts.limits.cluster_size_vbytes = 1'200'000;
99constexpr static struct {
102}
BLOCKINFO[]{{0, 3552706918}, {500, 37506755}, {1000, 948987788}, {400, 524762339}, {800, 258510074}, {300, 102309278},
103 {1300, 54365202}, {600, 1107740426}, {1000, 203094491}, {900, 391178848}, {800, 381177271}, {600, 87188412},
104 {0, 66522866}, {800, 874942736}, {1000, 89200838}, {400, 312638088}, {400, 66263693}, {500, 924648304},
105 {400, 369913599}, {500, 47630099}, {500, 115045364}, {100, 277026602}, {1100, 809621409}, {700, 155345322},
106 {800, 943579953}, {400, 28200730}, {900, 77200495}, {0, 105935488}, {400, 698721821}, {500, 111098863},
107 {1300, 445389594}, {500, 621849894}, {1400, 56010046}, {1100, 370669776}, {1200, 380301940}, {1200, 110654905},
108 {400, 213771024}, {1500, 120014726}, {1200, 835019014}, {1500, 624817237}, {900, 1404297}, {400, 189414558},
109 {400, 293178348}, {1100, 15393789}, {600, 396764180}, {800, 1387046371}, {800, 199368303}, {700, 111496662},
110 {100, 129759616}, {200, 536577982}, {500, 125881300}, {500, 101053391}, {1200, 471590548}, {900, 86957729},
111 {1200, 179604104}, {600, 68658642}, {1000, 203295701}, {500, 139615361}, {900, 233693412}, {300, 153225163},
112 {0, 27616254}, {1200, 9856191}, {100, 220392722}, {200, 66257599}, {1100, 145489641}, {1300, 37859442},
113 {400, 5816075}, {1200, 215752117}, {1400, 32361482}, {1400, 6529223}, {500, 143332977}, {800, 878392},
114 {700, 159290408}, {400, 123197595}, {700, 43988693}, {300, 304224916}, {700, 214771621}, {1100, 274148273},
115 {400, 285632418}, {1100, 923451065}, {600, 12818092}, {1200, 736282054}, {1000, 246683167}, {600, 92950402},
116 {1400, 29223405}, {1000, 841327192}, {700, 174301283}, {1400, 214009854}, {1000, 6989517}, {1200, 278226956},
117 {700, 540219613}, {400, 93663104}, {1100, 152345635}, {1500, 464194499}, {1300, 333850111}, {600, 258311263},
118 {600, 90173162}, {1000, 33590797}, {1500, 332866027}, {100, 204704427}, {1000, 463153545}, {800, 303244785},
119 {600, 88096214}, {0, 137477892}, {1200, 195514506}, {300, 704114595}, {900, 292087369}, {1400, 758684870},
120 {1300, 163493028}, {1200, 53151293}};
124 auto index{std::make_unique<CBlockIndex>()};
126 index->pprev = active_chain_tip;
133void MinerTestingSetup::TestPackageSelection(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst)
138 .coinbase_output_script = scriptPubKey,
145 std::unique_ptr<BlockTemplate> block_template = mining->createNewBlock(options,
false);
146 BOOST_REQUIRE(block_template);
147 CBlock block{block_template->getBlock()};
148 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 1U);
151 auto should_be_nullptr = block_template->waitNext({.timeout =
MillisecondsDouble{0}, .fee_threshold = 1});
152 BOOST_REQUIRE(should_be_nullptr ==
nullptr);
155 block_template = block_template->waitNext({.timeout =
MillisecondsDouble{0}, .fee_threshold = 0});
156 BOOST_REQUIRE(block_template);
166 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
167 tx.
vin[0].prevout.n = 0;
169 tx.
vout[0].nValue = 5000000000LL - 1000;
176 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
177 tx.
vout[0].nValue = 5000000000LL - 10000;
183 tx.
vin[0].prevout.hash = hashParentTx;
184 tx.
vout[0].nValue = 5000000000LL - 1000 - 50000;
190 const std::vector<Txid> tx_id_list{
194 auto raw_txs = mining->getTransactionsByTxID(tx_id_list);
195 BOOST_REQUIRE_EQUAL(raw_txs.size(), tx_id_list.size());
197 BOOST_CHECK(raw_txs[0]->GetHash() == hashParentTx);
201 const std::vector<Wtxid> wtx_id_list{
205 raw_txs = mining->getTransactionsByWitnessID(wtx_id_list);
206 BOOST_REQUIRE_EQUAL(raw_txs.size(), tx_id_list.size());
208 BOOST_CHECK(raw_txs[0]->GetHash() == hashParentTx);
210 block_template = mining->createNewBlock(options,
false);
211 BOOST_REQUIRE(block_template);
212 block = block_template->getBlock();
213 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 4U);
221 m_node.chainman->ActiveChainstate(),
228 const auto combined_txs_fee = parent_tx.GetFee() + high_fee_tx.GetFee();
229 const auto combined_txs_size = parent_tx.GetTxSize() + high_fee_tx.GetTxSize();
230 FeeFrac package_feefrac{combined_txs_fee, combined_txs_size};
232 BOOST_CHECK(block_package_feerates[0] == package_feefrac);
235 FeeFrac medium_tx_feefrac{medium_fee_tx.GetFee(), medium_fee_tx.GetTxSize()};
236 BOOST_CHECK(block_package_feerates[1] == medium_tx_feefrac);
239 tx.
vin[0].prevout.hash = hashHighFeeTx;
240 tx.
vout[0].nValue = 5000000000LL - 1000 - 50000;
249 tx.
vin[0].prevout.hash = hashFreeTx;
250 tx.
vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
255 should_be_nullptr = block_template->waitNext({.timeout =
MillisecondsDouble{0}, .fee_threshold = 1});
256 BOOST_REQUIRE(should_be_nullptr ==
nullptr);
258 block = block_template->getBlock();
260 for (
size_t i=0; i<block.
vtx.size(); ++i) {
269 tx.
vout[0].nValue -= 2;
274 block_template = block_template->waitNext({.fee_threshold = 1});
275 BOOST_REQUIRE(block_template);
276 block = block_template->getBlock();
277 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 6U);
284 tx.
vin[0].prevout.hash = txFirst[2]->GetHash();
286 tx.
vout[0].nValue = 5000000000LL - 100000000;
287 tx.
vout[1].nValue = 100000000;
296 tx.
vin[0].prevout.hash = hashFreeTx2;
299 tx.
vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
302 block_template = mining->createNewBlock(options,
false);
303 BOOST_REQUIRE(block_template);
304 block = block_template->getBlock();
307 for (
size_t i=0; i<block.
vtx.size(); ++i) {
314 tx.
vin[0].prevout.n = 1;
315 tx.
vout[0].nValue = 100000000 - 10000;
317 block_template = mining->createNewBlock(options,
false);
318 BOOST_REQUIRE(block_template);
319 block = block_template->getBlock();
320 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 9U);
330 tx.
vin[0].prevout = input;
332 tx.
vout.resize(num_outputs);
333 for (
auto& out : tx.
vout) {
342 std::vector<CTransactionRef>
ret;
349 tx.
vin[0].prevout.hash = first_tx->GetHash();
350 tx.
vin[0].prevout.n = 0;
352 for (
auto &out : tx.
vout) {
353 out.nValue = first_tx->vout[0].nValue / 50;
359 ret.push_back(parent_tx);
365 for (
unsigned int i = 0; i < 50; ++i) {
371void MinerTestingSetup::TestSigOpsAdjustedWeightChunkLimit(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst)
374 BOOST_REQUIRE(mining);
382 BOOST_REQUIRE(sigop_entry.GetAdjustedWeight() > sigop_entry.GetTxWeight());
389 .coinbase_output_script = scriptPubKey,
391 const CBlock block{mining->createNewBlock(options,
false)->getBlock()};
396void MinerTestingSetup::TestBasicMining(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst,
int baseheight)
412 BOOST_REQUIRE(mining);
415 .coinbase_output_script = scriptPubKey,
423 auto block_template{mining->createNewBlock(options,
false)};
424 BOOST_REQUIRE(block_template);
425 CBlock block{block_template->getBlock()};
429 int64_t legacy_sigops = 0;
430 for (
auto& t : txs) {
438 assert(legacy_sigops == 20001);
447 assert(tx_mempool.mapTx.empty());
450 auto block_template{mining->createNewBlock(options,
false)};
451 BOOST_REQUIRE(block_template);
452 CBlock block{block_template->getBlock()};
456 int64_t legacy_sigops = 0;
457 for (
auto& t : txs) {
463 assert(legacy_sigops == 20001);
465 BOOST_REQUIRE(mining->createNewBlock(options,
false));
475 tx.
vout[0].nValue = BLOCKSUBSIDY;
477 std::vector<unsigned char> vchData(520);
478 for (
unsigned int i = 0; i < 18; ++i) {
484 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
485 tx.
vin[0].prevout.n = 0;
486 tx.
vout[0].nValue = BLOCKSUBSIDY;
487 for (
unsigned int i = 0; i < 63; ++i) {
488 tx.
vout[0].nValue -= LOWFEE;
493 tx.
vin[0].prevout.hash = hash;
495 BOOST_REQUIRE(mining->createNewBlock(options,
false));
514 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
515 tx.
vout[0].nValue = BLOCKSUBSIDY - HIGHFEE;
518 tx.
vin[0].prevout.hash = hash;
521 tx.
vin[1].prevout.hash = txFirst[0]->GetHash();
522 tx.
vin[1].prevout.n = 0;
523 tx.
vout[0].nValue = tx.
vout[0].nValue + BLOCKSUBSIDY - HIGHERFEE;
526 BOOST_REQUIRE(mining->createNewBlock(options,
false));
535 tx.
vin[0].prevout.SetNull();
537 tx.
vout[0].nValue = 0;
550 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
552 tx.
vout[0].nValue = BLOCKSUBSIDY - HIGHFEE;
567 int nHeight = m_node.chainman->ActiveChain().Height();
569 while (m_node.chainman->ActiveChain().Tip()->nHeight < 209999) {
570 CBlockIndex* prev = m_node.chainman->ActiveChain().Tip();
573 m_node.chainman->ActiveChainstate().CoinsTip().SetBestBlock(next->
GetBlockHash());
577 m_node.chainman->ActiveChain().SetTip(*next);
579 BOOST_REQUIRE(mining->createNewBlock(options,
false));
581 while (m_node.chainman->ActiveChain().Tip()->nHeight < 210000) {
582 CBlockIndex* prev = m_node.chainman->ActiveChain().Tip();
585 m_node.chainman->ActiveChainstate().CoinsTip().SetBestBlock(next->
GetBlockHash());
589 m_node.chainman->ActiveChain().SetTip(*next);
591 BOOST_REQUIRE(mining->createNewBlock(options,
false));
594 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
595 tx.
vin[0].prevout.n = 0;
597 tx.
vout[0].nValue = BLOCKSUBSIDY - LOWFEE;
602 tx.
vin[0].prevout.hash = hash;
604 tx.
vout[0].nValue -= LOWFEE;
610 while (m_node.chainman->ActiveChain().Tip()->nHeight >
nHeight) {
611 CBlockIndex* del = m_node.chainman->ActiveChain().Tip();
612 m_node.chainman->ActiveChain().SetTip(*
Assert(del->
pprev));
613 m_node.chainman->ActiveChainstate().CoinsTip().SetBestBlock(del->
pprev->
GetBlockHash());
623 clock.
set(std::chrono::seconds{m_node.chainman->ActiveChain().Tip()->GetMedianTimePast() + 1});
626 std::vector<int> prevheights;
631 prevheights.resize(1);
632 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
633 tx.
vin[0].prevout.n = 0;
635 tx.
vin[0].nSequence = m_node.chainman->ActiveChain().Tip()->nHeight + 1;
636 prevheights[0] = baseheight + 1;
638 tx.
vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
647 CBlockIndex* active_chain_tip = m_node.chainman->ActiveChain().Tip();
652 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
654 prevheights[0] = baseheight + 2;
660 const int SEQUENCE_LOCK_TIME = 512;
662 m_node.chainman->ActiveChain().Tip()->GetAncestor(m_node.chainman->ActiveChain().Tip()->nHeight - i)->nTime += SEQUENCE_LOCK_TIME;
664 CBlockIndex* active_chain_tip = m_node.chainman->ActiveChain().Tip();
669 CBlockIndex* ancestor{
Assert(m_node.chainman->ActiveChain().Tip()->GetAncestor(m_node.chainman->ActiveChain().Tip()->nHeight - i))};
670 ancestor->
nTime -= SEQUENCE_LOCK_TIME;
674 tx.
vin[0].prevout.hash = txFirst[2]->GetHash();
676 prevheights[0] = baseheight + 3;
677 tx.
nLockTime = m_node.chainman->ActiveChain().Tip()->nHeight + 1;
689 tx.
vin[0].prevout.hash = txFirst[3]->GetHash();
690 tx.
nLockTime = m_node.chainman->ActiveChain().Tip()->GetMedianTimePast();
691 prevheights.resize(1);
692 prevheights[0] = baseheight + 4;
700 tx.
vin[0].prevout.hash = hash;
701 prevheights[0] = m_node.chainman->ActiveChain().Tip()->nHeight + 1;
703 tx.
vin[0].nSequence = 0;
706 tx.
vin[0].nSequence = 1;
713 auto block_template = mining->createNewBlock(options,
false);
714 BOOST_REQUIRE(block_template);
720 CBlock block{block_template->getBlock()};
724 CBlockIndex* ancestor{
Assert(m_node.chainman->ActiveChain().Tip()->GetAncestor(m_node.chainman->ActiveChain().Tip()->nHeight - i))};
725 ancestor->
nTime += SEQUENCE_LOCK_TIME;
727 m_node.chainman->ActiveChain().Tip()->nHeight++;
728 clock.
set(std::chrono::seconds{m_node.chainman->ActiveChain().Tip()->GetMedianTimePast() + 1});
730 block_template = mining->createNewBlock(options,
false);
731 BOOST_REQUIRE(block_template);
732 block = block_template->getBlock();
736void MinerTestingSetup::TestPrioritisedMining(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst)
739 BOOST_REQUIRE(mining);
742 .coinbase_output_script = scriptPubKey,
753 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
754 tx.
vin[0].prevout.n = 0;
757 tx.
vout[0].nValue = 5000000000LL;
762 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
763 tx.
vin[0].prevout.n = 0;
764 tx.
vout[0].nValue = 5000000000LL - 1000;
770 tx.
vin[0].prevout.hash = txFirst[2]->GetHash();
771 tx.
vout[0].nValue = 5000000000LL - 10000;
777 tx.
vin[0].prevout.hash = hashParentTx;
778 tx.
vout[0].nValue = 5000000000LL - 1000 - 1000;
789 tx.
vin[0].prevout.hash = txFirst[3]->GetHash();
790 tx.
vout[0].nValue = 5000000000LL;
795 tx.
vin[0].prevout.hash = hashFreeParent;
796 tx.
vout[0].nValue = 5000000000LL;
801 tx.
vin[0].prevout.hash = hashFreeChild;
802 tx.
vout[0].nValue = 5000000000LL;
806 auto block_template = mining->createNewBlock(options,
false);
807 BOOST_REQUIRE(block_template);
808 CBlock block{block_template->getBlock()};
809 BOOST_REQUIRE_EQUAL(block.
vtx.size(), 6U);
815 for (
size_t i=0; i<block.
vtx.size(); ++i) {
826 auto mining{MakeMining()};
827 BOOST_REQUIRE(mining);
830 CScript scriptPubKey =
CScript() <<
"04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f"_hex <<
OP_CHECKSIG;
832 .coinbase_output_script = scriptPubKey,
836 std::unique_ptr<BlockTemplate> block_template = mining->createNewBlock(options,
false);
837 BOOST_REQUIRE(block_template);
843 HasReason(
"block_reserved_weight (8000) exceeds block_max_weight (7999)"));
846 CBlock block{block_template->getBlock()};
850 BOOST_REQUIRE(!mining->checkBlock(block, {.check_pow = false}, reason, debug));
851 BOOST_REQUIRE_EQUAL(reason,
"bad-txnmrklroot");
852 BOOST_REQUIRE_EQUAL(debug,
"hashMerkleRoot mismatch");
860 BOOST_REQUIRE(mining->checkBlock(block, {.check_pow = false}, reason, debug));
861 BOOST_REQUIRE_EQUAL(reason,
"");
862 BOOST_REQUIRE_EQUAL(debug,
"");
874 BOOST_REQUIRE(!mining->checkBlock(block, {.check_pow = true}, reason, debug));
875 BOOST_REQUIRE_EQUAL(reason,
"high-hash");
876 BOOST_REQUIRE_EQUAL(debug,
"proof of work failed");
882 static_assert(std::size(
BLOCKINFO) == 110,
"Should have 110 blocks to import");
884 std::vector<CTransactionRef> txFirst;
894 block_template = mining->createNewBlock(options,
false);
895 BOOST_REQUIRE(block_template);
898 CBlock block{block_template->getBlock()};
903 block.
nTime =
Assert(m_node.chainman)->ActiveChain().Tip()->GetMedianTimePast()+1;
906 txCoinbase.
vout.resize(1);
908 block.
vtx[0] = MakeTransactionRef(txCoinbase);
909 if (txFirst.size() == 0)
911 if (txFirst.size() < 4)
912 txFirst.push_back(block.
vtx[0]);
918 std::string reason{
"stale reason"};
919 std::string debug{
"stale debug"};
921 BOOST_REQUIRE(mining->submitBlock(block, reason, debug));
922 BOOST_REQUIRE_EQUAL(reason,
"");
923 BOOST_REQUIRE_EQUAL(debug,
"");
925 reason =
"stale reason";
926 debug =
"stale debug";
927 BOOST_REQUIRE(!mining->submitBlock(block, reason, debug));
928 BOOST_REQUIRE_EQUAL(reason,
"duplicate");
929 BOOST_REQUIRE_EQUAL(debug,
"");
931 reason =
"stale reason";
932 debug =
"stale debug";
933 BOOST_REQUIRE(block_template->submitSolution(block.
nVersion, block.
nTime, block.
nNonce, MakeTransactionRef(txCoinbase), reason, debug));
934 BOOST_REQUIRE_EQUAL(reason,
"");
935 BOOST_REQUIRE_EQUAL(debug,
"");
937 MakeTransactionRef(txCoinbase)),
944 auto maybe_new_tip{
Assert(m_node.chainman)->ActiveChain().Tip()};
945 BOOST_REQUIRE_EQUAL(maybe_new_tip->GetBlockHash(), block.
GetHash());
948 block_template = block_template->waitNext();
949 BOOST_REQUIRE(block_template);
958 TestBasicMining(scriptPubKey, txFirst, baseheight);
960 m_node.chainman->ActiveChain().Tip()->nHeight--;
962 TestPackageSelection(scriptPubKey, txFirst);
964 m_node.chainman->ActiveChain().Tip()->nHeight--;
966 TestPrioritisedMining(scriptPubKey, txFirst);
968 TestSigOpsAdjustedWeightChunkLimit(scriptPubKey, txFirst);
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
int64_t CAmount
Amount in satoshis (Can be negative).
constexpr CAmount COIN
The amount of satoshis in one BTC.
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
#define Assert(val)
Identity function.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
void BuildSkip()
Build the skiplist pointer for this entry.
uint256 GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
static constexpr int nMedianTimeSpan
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
CCoinsView that brings transactions from a mempool into view.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
CAmount GetFee(int32_t virtual_bytes) const
Return the fee in satoshis for the given vsize in vbytes.
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
CTransaction(const CMutableTransaction &tx)
Convert a CMutableTransaction into a CTransaction.
static constexpr int SEQUENCE_LOCKTIME_GRANULARITY
In order to use the same number of bits to encode roughly the same wall-clock duration,...
static constexpr uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG
If CTxIn::nSequence encodes a relative lock-time and this flag is set, the relative lock-time has uni...
static constexpr uint32_t MAX_SEQUENCE_NONFINAL
This is the maximum sequence number that enables both nLockTime and OP_CHECKLOCKTIMEVERIFY (BIP 65).
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void PrioritiseTransaction(const Txid &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
std::optional< txiter > GetIter(const Txid &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given hash, if found.
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
unsigned long size() const
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
void set(NodeSeconds t)
Set mocktime.
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
Block template interface.
Generate a new block, without valid proof-of-work.
std::unique_ptr< CBlockTemplate > CreateNewBlock()
Construct a new block template.
const uint256 & ToUint256() const LIFETIMEBOUND
static transaction_identifier FromUint256(const uint256 &id)
constexpr uint256()=default
static const uint256 ZERO
uint32_t current_height
Current height in the simulation.
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE
Flags for nSequence and nLockTime locks.
constexpr int64_t MAX_BLOCK_SIGOPS_COST
The maximum allowed number of signature check operations in a block (network rule).
constexpr int WITNESS_SCALE_FACTOR
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EXCEPTION(req.LoadBody(reader), std::runtime_error, HasReason{"Cannot parse Content-Length value"})
BOOST_AUTO_TEST_CASE(ipc_tests)
@ REPLACED
Removed for replacement.
std::vector< CTransactionRef > CreateBigSigOpsCluster(const CTransactionRef &first_tx)
static CMutableTransaction CreateBigSigOpsTx(const COutPoint &input, unsigned int num_outputs)
static std::unique_ptr< CBlockIndex > CreateBlockIndex(int nHeight, CBlockIndex *active_chain_tip) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
static constexpr struct @264074122144367246160252320203044150204025367053 BLOCKINFO[]
static CFeeRate blockMinFeeRate
std::unique_ptr< Mining > MakeMining(const node::NodeContext &node, bool wait_loaded=true)
BlockCreateOptions MergeMiningOptions(BlockCreateOptions x, const BlockCreateOptions &y)
Merge two BlockCreateOptions structs, replacing null values in x with non-null values from y.
""_hex is a compile-time user-defined literal returning a std::array<std::byte>, equivalent to ParseH...
#define BOOST_CHECK_THROW(stmt, excMatch)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE
Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by min...
constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT
Default for -blockreservedweight.
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
constexpr TransactionSerParams TX_WITH_WITNESS
std::shared_ptr< const CTransaction > CTransactionRef
uint64_t GetSerializeSize(const T &t)
A mutable version of CTransaction.
std::vector< CTxOut > vout
Txid GetHash() const
Compute the hash of this CMutableTransaction.
Data structure storing a fee and size.
TestMemPoolEntryHelper & SigOpsCost(unsigned int _sigopsCost)
TestMemPoolEntryHelper & Time(NodeSeconds tp)
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
TestMemPoolEntryHelper & SpendsCoinbase(bool _flag)
TestMemPoolEntryHelper & Fee(CAmount _fee)
TestingSetup(ChainType chainType=ChainType::MAIN, TestOpts={})
std::unique_ptr< Mining > MakeMining()
CTxMemPool & MakeMempool()
void TestPackageSelection(const CScript &scriptPubKey, const std::vector< CTransactionRef > &txFirst) EXCLUSIVE_LOCKS_REQUIRED(void TestBasicMining(const CScript &scriptPubKey, const std::vector< CTransactionRef > &txFirst, int baseheight) EXCLUSIVE_LOCKS_REQUIRED(void TestPrioritisedMining(const CScript &scriptPubKey, const std::vector< CTransactionRef > &txFirst) EXCLUSIVE_LOCKS_REQUIRED(void TestSigOpsAdjustedWeightChunkLimit(const CScript &scriptPubKey, const std::vector< CTransactionRef > &txFirst) EXCLUSIVE_LOCKS_REQUIRED(bool TestSequenceLocks(const CTransaction &tx, CTxMemPool &tx_mempool) EXCLUSIVE_LOCKS_REQUIRED(
Block template creation options.
std::optional< uint64_t > block_max_weight
Maximum block weight, defaults to -maxblockweight.
std::unique_ptr< CTxMemPool > mempool
std::unique_ptr< ChainstateManager > chainman
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
transaction_identifier< false > Txid
Txid commits to all transaction fields except the witness.
void BulkTransaction(CMutableTransaction &tx, int32_t target_weight)
unsigned int GetLegacySigOpCount(const CTransaction &tx)
Auxiliary functions for transaction validation (ideally should not be exposed).
bool SequenceLocks(const CTransaction &tx, int flags, std::vector< int > &prevHeights, const CBlockIndex &block)
Check if transaction is final per BIP 68 sequence numbers and can be included in a block.
bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
Check if transaction is final and can be included in a block with the specified height and time.
std::chrono::duration< double, std::chrono::milliseconds::period > MillisecondsDouble
T Now()
Return the current time point cast to the given precision.
bool CheckFinalTxAtTip(const CBlockIndex &active_chain_tip, const CTransaction &tx)
bool CheckSequenceLocksAtTip(CBlockIndex *tip, const LockPoints &lock_points)
Check if transaction will be BIP68 final in the next block to be created on top of tip.
bool CheckFinalTxAtTip(const CBlockIndex &active_chain_tip, const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(std::optional< LockPoints > CalculateLockPointsAtTip(CBlockIndex *tip, const CCoinsView &coins_view, const CTransaction &tx)
Check if transaction will be final in the next block to be created.
constexpr int32_t VERSIONBITS_TOP_BITS
What bits to set in version for versionbits blocks.