38#include <validation.h>
39#include <versionbits.h>
41#include <boost/test/unit_test.hpp>
82 opts.limits.cluster_size_vbytes = 1'200'000;
98constexpr static struct {
101}
BLOCKINFO[]{{0, 3552706918}, {500, 37506755}, {1000, 948987788}, {400, 524762339}, {800, 258510074}, {300, 102309278},
102 {1300, 54365202}, {600, 1107740426}, {1000, 203094491}, {900, 391178848}, {800, 381177271}, {600, 87188412},
103 {0, 66522866}, {800, 874942736}, {1000, 89200838}, {400, 312638088}, {400, 66263693}, {500, 924648304},
104 {400, 369913599}, {500, 47630099}, {500, 115045364}, {100, 277026602}, {1100, 809621409}, {700, 155345322},
105 {800, 943579953}, {400, 28200730}, {900, 77200495}, {0, 105935488}, {400, 698721821}, {500, 111098863},
106 {1300, 445389594}, {500, 621849894}, {1400, 56010046}, {1100, 370669776}, {1200, 380301940}, {1200, 110654905},
107 {400, 213771024}, {1500, 120014726}, {1200, 835019014}, {1500, 624817237}, {900, 1404297}, {400, 189414558},
108 {400, 293178348}, {1100, 15393789}, {600, 396764180}, {800, 1387046371}, {800, 199368303}, {700, 111496662},
109 {100, 129759616}, {200, 536577982}, {500, 125881300}, {500, 101053391}, {1200, 471590548}, {900, 86957729},
110 {1200, 179604104}, {600, 68658642}, {1000, 203295701}, {500, 139615361}, {900, 233693412}, {300, 153225163},
111 {0, 27616254}, {1200, 9856191}, {100, 220392722}, {200, 66257599}, {1100, 145489641}, {1300, 37859442},
112 {400, 5816075}, {1200, 215752117}, {1400, 32361482}, {1400, 6529223}, {500, 143332977}, {800, 878392},
113 {700, 159290408}, {400, 123197595}, {700, 43988693}, {300, 304224916}, {700, 214771621}, {1100, 274148273},
114 {400, 285632418}, {1100, 923451065}, {600, 12818092}, {1200, 736282054}, {1000, 246683167}, {600, 92950402},
115 {1400, 29223405}, {1000, 841327192}, {700, 174301283}, {1400, 214009854}, {1000, 6989517}, {1200, 278226956},
116 {700, 540219613}, {400, 93663104}, {1100, 152345635}, {1500, 464194499}, {1300, 333850111}, {600, 258311263},
117 {600, 90173162}, {1000, 33590797}, {1500, 332866027}, {100, 204704427}, {1000, 463153545}, {800, 303244785},
118 {600, 88096214}, {0, 137477892}, {1200, 195514506}, {300, 704114595}, {900, 292087369}, {1400, 758684870},
119 {1300, 163493028}, {1200, 53151293}};
123 auto index{std::make_unique<CBlockIndex>()};
125 index->pprev = active_chain_tip;
132void MinerTestingSetup::TestPackageSelection(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst)
144 std::unique_ptr<BlockTemplate> block_template = mining->createNewBlock(options,
false);
145 BOOST_REQUIRE(block_template);
146 CBlock block{block_template->getBlock()};
147 BOOST_REQUIRE_EQUAL(block.vtx.size(), 1U);
150 auto should_be_nullptr = block_template->waitNext({.timeout =
MillisecondsDouble{0}, .fee_threshold = 1});
151 BOOST_REQUIRE(should_be_nullptr ==
nullptr);
154 block_template = block_template->waitNext({.timeout =
MillisecondsDouble{0}, .fee_threshold = 0});
155 BOOST_REQUIRE(block_template);
165 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
166 tx.
vin[0].prevout.n = 0;
168 tx.
vout[0].nValue = 5000000000LL - 1000;
175 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
176 tx.
vout[0].nValue = 5000000000LL - 10000;
182 tx.
vin[0].prevout.hash = hashParentTx;
183 tx.
vout[0].nValue = 5000000000LL - 1000 - 50000;
189 const std::vector<Txid> tx_id_list{
193 auto raw_txs = mining->getTransactionsByTxID(tx_id_list);
194 BOOST_REQUIRE_EQUAL(raw_txs.size(), tx_id_list.size());
196 BOOST_CHECK(raw_txs[0]->GetHash() == hashParentTx);
200 const std::vector<Wtxid> wtx_id_list{
204 raw_txs = mining->getTransactionsByWitnessID(wtx_id_list);
205 BOOST_REQUIRE_EQUAL(raw_txs.size(), tx_id_list.size());
207 BOOST_CHECK(raw_txs[0]->GetHash() == hashParentTx);
209 block_template = mining->createNewBlock(options,
false);
210 BOOST_REQUIRE(block_template);
211 block = block_template->getBlock();
212 BOOST_REQUIRE_EQUAL(block.vtx.size(), 4U);
213 BOOST_CHECK(block.vtx[1]->GetHash() == hashParentTx);
214 BOOST_CHECK(block.vtx[2]->GetHash() == hashHighFeeTx);
215 BOOST_CHECK(block.vtx[3]->GetHash() == hashMediumFeeTx);
223 }.CreateNewBlock()->m_package_feerates;
227 const auto combined_txs_fee = parent_tx.GetFee() + high_fee_tx.GetFee();
228 const auto combined_txs_size = parent_tx.GetTxSize() + high_fee_tx.GetTxSize();
229 FeeFrac package_feefrac{combined_txs_fee, combined_txs_size};
231 BOOST_CHECK(block_package_feerates[0] == package_feefrac);
234 FeeFrac medium_tx_feefrac{medium_fee_tx.GetFee(), medium_fee_tx.GetTxSize()};
235 BOOST_CHECK(block_package_feerates[1] == medium_tx_feefrac);
238 tx.
vin[0].prevout.hash = hashHighFeeTx;
239 tx.
vout[0].nValue = 5000000000LL - 1000 - 50000;
248 tx.
vin[0].prevout.hash = hashFreeTx;
249 tx.
vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
254 should_be_nullptr = block_template->waitNext({.timeout =
MillisecondsDouble{0}, .fee_threshold = 1});
255 BOOST_REQUIRE(should_be_nullptr ==
nullptr);
257 block = block_template->getBlock();
259 for (
size_t i=0; i<block.vtx.size(); ++i) {
260 BOOST_CHECK(block.vtx[i]->GetHash() != hashFreeTx);
261 BOOST_CHECK(block.vtx[i]->GetHash() != hashLowFeeTx);
268 tx.
vout[0].nValue -= 2;
273 block_template = block_template->waitNext({.fee_threshold = 1});
274 BOOST_REQUIRE(block_template);
275 block = block_template->getBlock();
276 BOOST_REQUIRE_EQUAL(block.vtx.size(), 6U);
277 BOOST_CHECK(block.vtx[4]->GetHash() == hashFreeTx);
278 BOOST_CHECK(block.vtx[5]->GetHash() == hashLowFeeTx);
283 tx.
vin[0].prevout.hash = txFirst[2]->GetHash();
285 tx.
vout[0].nValue = 5000000000LL - 100000000;
286 tx.
vout[1].nValue = 100000000;
295 tx.
vin[0].prevout.hash = hashFreeTx2;
298 tx.
vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
301 block_template = mining->createNewBlock(options,
false);
302 BOOST_REQUIRE(block_template);
303 block = block_template->getBlock();
306 for (
size_t i=0; i<block.vtx.size(); ++i) {
307 BOOST_CHECK(block.vtx[i]->GetHash() != hashFreeTx2);
308 BOOST_CHECK(block.vtx[i]->GetHash() != hashLowFeeTx2);
313 tx.
vin[0].prevout.n = 1;
314 tx.
vout[0].nValue = 100000000 - 10000;
316 block_template = mining->createNewBlock(options,
false);
317 BOOST_REQUIRE(block_template);
318 block = block_template->getBlock();
319 BOOST_REQUIRE_EQUAL(block.vtx.size(), 9U);
320 BOOST_CHECK(block.vtx[8]->GetHash() == hashLowFeeTx2);
325 std::vector<CTransactionRef>
ret;
332 tx.
vin[0].prevout.hash = first_tx->GetHash();
333 tx.
vin[0].prevout.n = 0;
336 out.nValue = first_tx->vout[0].nValue / 50;
342 ret.push_back(parent_tx);
348 for (
unsigned int i = 0; i < 50; ++i) {
351 tx2.vin[0].prevout.hash = parent_tx->GetHash();
352 tx2.vin[0].prevout.n = i;
355 tx2.vout[0].nValue = parent_tx->vout[i].nValue -
CENT;
356 for (
auto &
out : tx2.vout) {
365void MinerTestingSetup::TestBasicMining(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst,
int baseheight)
381 BOOST_REQUIRE(mining);
392 auto block_template{mining->createNewBlock(options,
false)};
393 BOOST_REQUIRE(block_template);
394 CBlock block{block_template->getBlock()};
398 int64_t legacy_sigops = 0;
399 for (
auto& t : txs) {
404 BOOST_CHECK(tx_mempool.GetIter(
t->GetHash()).has_value());
406 assert(tx_mempool.mapTx.size() == 51);
407 assert(legacy_sigops == 20001);
416 assert(tx_mempool.mapTx.empty());
419 auto block_template{mining->createNewBlock(options,
false)};
420 BOOST_REQUIRE(block_template);
421 CBlock block{block_template->getBlock()};
425 int64_t legacy_sigops = 0;
426 for (
auto& t : txs) {
429 BOOST_CHECK(tx_mempool.GetIter(
t->GetHash()).has_value());
431 assert(tx_mempool.mapTx.size() == 51);
432 assert(legacy_sigops == 20001);
434 BOOST_REQUIRE(mining->createNewBlock(options,
false));
444 tx.
vout[0].nValue = BLOCKSUBSIDY;
446 std::vector<unsigned char> vchData(520);
447 for (
unsigned int i = 0; i < 18; ++i) {
453 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
454 tx.
vin[0].prevout.n = 0;
455 tx.
vout[0].nValue = BLOCKSUBSIDY;
456 for (
unsigned int i = 0; i < 63; ++i) {
457 tx.
vout[0].nValue -= LOWFEE;
462 tx.
vin[0].prevout.hash = hash;
464 BOOST_REQUIRE(mining->createNewBlock(options,
false));
483 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
484 tx.
vout[0].nValue = BLOCKSUBSIDY - HIGHFEE;
487 tx.
vin[0].prevout.hash = hash;
490 tx.
vin[1].prevout.hash = txFirst[0]->GetHash();
491 tx.
vin[1].prevout.n = 0;
492 tx.
vout[0].nValue = tx.
vout[0].nValue + BLOCKSUBSIDY - HIGHERFEE;
495 BOOST_REQUIRE(mining->createNewBlock(options,
false));
504 tx.
vin[0].prevout.SetNull();
506 tx.
vout[0].nValue = 0;
519 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
521 tx.
vout[0].nValue = BLOCKSUBSIDY - HIGHFEE;
548 BOOST_REQUIRE(mining->createNewBlock(options,
false));
560 BOOST_REQUIRE(mining->createNewBlock(options,
false));
563 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
564 tx.
vin[0].prevout.n = 0;
566 tx.
vout[0].nValue = BLOCKSUBSIDY - LOWFEE;
571 tx.
vin[0].prevout.hash = hash;
573 tx.
vout[0].nValue -= LOWFEE;
592 clock.set(std::chrono::seconds{
m_node.
chainman->ActiveChain().Tip()->GetMedianTimePast() + 1});
595 std::vector<int> prevheights;
600 prevheights.resize(1);
601 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
602 tx.
vin[0].prevout.n = 0;
605 prevheights[0] = baseheight + 1;
607 tx.
vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
621 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
623 prevheights[0] = baseheight + 2;
629 const int SEQUENCE_LOCK_TIME = 512;
639 ancestor->nTime -= SEQUENCE_LOCK_TIME;
643 tx.
vin[0].prevout.hash = txFirst[2]->GetHash();
645 prevheights[0] = baseheight + 3;
658 tx.
vin[0].prevout.hash = txFirst[3]->GetHash();
660 prevheights.resize(1);
661 prevheights[0] = baseheight + 4;
669 tx.
vin[0].prevout.hash = hash;
670 prevheights[0] =
m_node.
chainman->ActiveChain().Tip()->nHeight + 1;
672 tx.
vin[0].nSequence = 0;
675 tx.
vin[0].nSequence = 1;
682 auto block_template = mining->createNewBlock(options,
false);
683 BOOST_REQUIRE(block_template);
689 CBlock block{block_template->getBlock()};
694 ancestor->nTime += SEQUENCE_LOCK_TIME;
697 clock.set(std::chrono::seconds{
m_node.
chainman->ActiveChain().Tip()->GetMedianTimePast() + 1});
699 block_template = mining->createNewBlock(options,
false);
700 BOOST_REQUIRE(block_template);
701 block = block_template->getBlock();
705void MinerTestingSetup::TestPrioritisedMining(
const CScript& scriptPubKey,
const std::vector<CTransactionRef>& txFirst)
708 BOOST_REQUIRE(mining);
722 tx.
vin[0].prevout.hash = txFirst[0]->GetHash();
723 tx.
vin[0].prevout.n = 0;
726 tx.
vout[0].nValue = 5000000000LL;
729 tx_mempool.PrioritiseTransaction(hashFreePrioritisedTx, 5 *
COIN);
731 tx.
vin[0].prevout.hash = txFirst[1]->GetHash();
732 tx.
vin[0].prevout.n = 0;
733 tx.
vout[0].nValue = 5000000000LL - 1000;
739 tx.
vin[0].prevout.hash = txFirst[2]->GetHash();
740 tx.
vout[0].nValue = 5000000000LL - 10000;
743 tx_mempool.PrioritiseTransaction(hashMediumFeeTx, -5 *
COIN);
746 tx.
vin[0].prevout.hash = hashParentTx;
747 tx.
vout[0].nValue = 5000000000LL - 1000 - 1000;
750 tx_mempool.PrioritiseTransaction(hashPrioritsedChild, 2 *
COIN);
758 tx.
vin[0].prevout.hash = txFirst[3]->GetHash();
759 tx.
vout[0].nValue = 5000000000LL;
762 tx_mempool.PrioritiseTransaction(hashFreeParent, 10 *
COIN);
764 tx.
vin[0].prevout.hash = hashFreeParent;
765 tx.
vout[0].nValue = 5000000000LL;
768 tx_mempool.PrioritiseTransaction(hashFreeChild, 1 *
COIN);
770 tx.
vin[0].prevout.hash = hashFreeChild;
771 tx.
vout[0].nValue = 5000000000LL;
775 auto block_template = mining->createNewBlock(options,
false);
776 BOOST_REQUIRE(block_template);
777 CBlock block{block_template->getBlock()};
778 BOOST_REQUIRE_EQUAL(block.vtx.size(), 6U);
779 BOOST_CHECK(block.vtx[1]->GetHash() == hashFreeParent);
780 BOOST_CHECK(block.vtx[2]->GetHash() == hashFreePrioritisedTx);
781 BOOST_CHECK(block.vtx[3]->GetHash() == hashParentTx);
782 BOOST_CHECK(block.vtx[4]->GetHash() == hashPrioritsedChild);
783 BOOST_CHECK(block.vtx[5]->GetHash() == hashFreeChild);
784 for (
size_t i=0; i<block.vtx.size(); ++i) {
786 BOOST_CHECK(block.vtx[i]->GetHash() != hashFreeGrandchild);
788 BOOST_CHECK(block.vtx[i]->GetHash() != hashMediumFeeTx);
796 BOOST_REQUIRE(mining);
799 CScript scriptPubKey =
CScript() <<
"04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f"_hex <<
OP_CHECKSIG;
805 std::unique_ptr<BlockTemplate> block_template = mining->createNewBlock(options,
false);
806 BOOST_REQUIRE(block_template);
812 HasReason(
"block_reserved_weight (8000) exceeds block_max_weight (7999)"));
815 CBlock block{block_template->getBlock()};
819 BOOST_REQUIRE(!mining->checkBlock(block, {.check_pow = false}, reason, debug));
820 BOOST_REQUIRE_EQUAL(reason,
"bad-txnmrklroot");
821 BOOST_REQUIRE_EQUAL(debug,
"hashMerkleRoot mismatch");
829 BOOST_REQUIRE(mining->checkBlock(block, {.check_pow = false}, reason, debug));
830 BOOST_REQUIRE_EQUAL(reason,
"");
831 BOOST_REQUIRE_EQUAL(debug,
"");
843 BOOST_REQUIRE(!mining->checkBlock(block, {.check_pow = true}, reason, debug));
844 BOOST_REQUIRE_EQUAL(reason,
"high-hash");
845 BOOST_REQUIRE_EQUAL(debug,
"proof of work failed");
851 static_assert(std::size(
BLOCKINFO) == 110,
"Should have 110 blocks to import");
853 std::vector<CTransactionRef> txFirst;
855 const int current_height{mining->getTip()->height};
862 if (current_height % 2 == 0) {
863 block_template = mining->createNewBlock(options,
false);
864 BOOST_REQUIRE(block_template);
867 CBlock block{block_template->getBlock()};
874 txCoinbase.
vin[0].scriptSig =
CScript{} << (current_height + 1) << bi.extranonce;
875 txCoinbase.
vout.resize(1);
878 if (txFirst.size() == 0)
879 baseheight = current_height;
880 if (txFirst.size() < 4)
881 txFirst.push_back(block.vtx[0]);
883 block.nNonce = bi.nonce;
887 if (current_height % 2 == 0) {
888 std::string reason{
"stale reason"};
889 std::string debug{
"stale debug"};
890 BOOST_REQUIRE(mining->submitBlock(block, reason, debug));
891 BOOST_REQUIRE_EQUAL(reason,
"");
892 BOOST_REQUIRE_EQUAL(debug,
"");
894 reason =
"stale reason";
895 debug =
"stale debug";
896 BOOST_REQUIRE(!mining->submitBlock(block, reason, debug));
897 BOOST_REQUIRE_EQUAL(reason,
"duplicate");
898 BOOST_REQUIRE_EQUAL(debug,
"");
900 BOOST_REQUIRE(block_template->submitSolution(block.nVersion, block.nTime, block.nNonce,
MakeTransactionRef(txCoinbase)));
907 BOOST_REQUIRE_EQUAL(maybe_new_tip->GetBlockHash(), block.GetHash());
909 if (current_height % 2 == 0) {
910 block_template = block_template->waitNext();
911 BOOST_REQUIRE(block_template);
914 mining->waitTipChanged(block.hashPrevBlock);
920 TestBasicMining(scriptPubKey, txFirst, baseheight);
924 TestPackageSelection(scriptPubKey, txFirst);
928 TestPrioritisedMining(scriptPubKey, txFirst);
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
int64_t CAmount
Amount in satoshis (Can be negative)
static 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.
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.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
static const uint32_t MAX_SEQUENCE_NONFINAL
This is the maximum sequence number that enables both nLockTime and OP_CHECKLOCKTIMEVERIFY (BIP 65).
static const 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 const int SEQUENCE_LOCKTIME_GRANULARITY
In order to use the same number of bits to encode roughly the same wall-clock duration,...
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
Block template interface.
Interface giving clients (RPC, Stratum v2 Template Provider in the future) ability to create block te...
Generate a new block, without valid proof-of-work.
const uint256 & ToUint256() const LIFETIMEBOUND
static transaction_identifier FromUint256(const uint256 &id)
static const uint256 ZERO
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE
Flags for nSequence and nLockTime locks.
static const 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_EQUAL(headers.FindFirst("key"), "value")
BOOST_CHECK_EXCEPTION(HTTPHeaders{}.Read(reader), std::runtime_error, HasReason{"Empty HTTP header name"})
@ REPLACED
Removed for replacement.
std::vector< CTransactionRef > CreateBigSigOpsCluster(const CTransactionRef &first_tx)
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
static constexpr struct @13 BLOCKINFO[]
static std::unique_ptr< CBlockIndex > CreateBlockIndex(int nHeight, CBlockIndex *active_chain_tip) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
static CFeeRate blockMinFeeRate
is used externally by mining IPC clients, so it should only declare simple data definitions.
std::unique_ptr< Mining > MakeMining(const node::NodeContext &node, bool wait_loaded=true)
Return implementation of Mining interface.
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(expr)
static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE
Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by min...
static 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.
static constexpr TransactionSerParams TX_WITH_WITNESS
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
uint64_t GetSerializeSize(const T &t)
static constexpr CAmount CENT
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)
Testing setup that configures a complete environment.
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(bool TestSequenceLocks(const CTransaction &tx, CTxMemPool &tx_mempool) EXCLUSIVE_LOCKS_REQUIRED(
Block template creation options.
CScript coinbase_output_script
Script to put in the coinbase transaction.
std::optional< uint64_t > block_max_weight
Maximum block weight, defaults to -maxblockweight.
BlockCreateOptions mining_args
Mining options used to create block templates.
std::unique_ptr< CTxMemPool > mempool
std::unique_ptr< ChainstateManager > chainman
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
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
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.
static const int32_t VERSIONBITS_TOP_BITS
What bits to set in version for versionbits blocks.