22#include <boost/test/unit_test.hpp>
40 mtx.vin[i].prevout.n = 0;
57 "02000000000101964b8aa63509579ca6086e6012eeaa4c2f4dd1e283da29b67c8eea38b3c6fd220000000000fdffffff0294c618000000000017a9145afbbb42f4e83312666d0697f9e66259912ecde38768fa2c0000000000160014897388a0889390fd0e153a22bb2cf9d8f019faf50247304402200547406380719f84d68cf4e96cc3e4a1688309ef475b150be2b471c70ea562aa02206d255f5acc40fd95981874d77201d2eb07883657ce1c796513f32b6079545cdf0121023ae77335cefcb5ab4c1dc1fb0d2acfece184e593727d7d5906c78e564c7c11d125cf0c00"_hex,
64 "01000000010b26e9b7735eb6aabdf358bab62f9816a21ba9ebdb719d5299e88607d722c190000000008b4830450220070aca44506c5cef3a16ed519d7c3c39f8aab192c4e1c90d065f37b8a4af6141022100a8e160b856c2d43d27d8fba71e5aef6405b8643ac4cb7cb3c462aced7f14711a0141046d11fee51b0e60666d5049a9101a72741df480b96ee26488a4d3466b95c9a40ac5eeef87e10a5cd336c19a84565f80fa6c547957b7700ff4dfbdefe76036c339ffffffff021bff3d11000000001976a91404943fdd508053c75000106d3bc6e2754dbcff1988ac2f15de00000000001976a914a266436d2965547608b9e15d9032a7b9d64fa43188ac00000000"_hex,
71 "0200000000010177862801f77c2c068a70372b4c435ef8dd621291c36a64eb4dd491f02218f5324600000000fdffffff014a0100000000000022512035ea312034cfac01e956a269f3bf147f569c2fbb00180677421262da042290d803402be713325ff285e66b0380f53f2fae0d0fb4e16f378a440fed51ce835061437566729d4883bc917632f3cff474d6384bc8b989961a1d730d4a87ed38ad28bd337b20f1d658c6c138b1c312e072b4446f50f01ae0da03a42e6274f8788aae53416a7fac0063036f7264010118746578742f706c61696e3b636861727365743d7574662d3800357b2270223a226272632d3230222c226f70223a226d696e74222c227469636b223a224342414c222c22616d74223a2236393639227d6821c1f1d658c6c138b1c312e072b4446f50f01ae0da03a42e6274f8788aae53416a7f00000000"_hex,
77 constexpr Wtxid wtxid_1{
"85cd1a31eb38f74ed5742ec9cb546712ab5aaf747de28a9168b53e846cbda17f"};
78 constexpr Wtxid wtxid_2{
"b4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b"};
79 constexpr Wtxid wtxid_3{
"e065bac15f62bb4e761d761db928ddee65a47296b2b776785abb912cdec474e3"};
88 constexpr Txid txid_1{
"bd0f71c1d5e50589063e134fad22053cdae5ab2320db5bf5e540198b0b5a4e69"};
89 constexpr Txid txid_2{
"b4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b"};
90 constexpr Txid txid_3{
"ee707be5201160e32c4fc715bec227d1aeea5940fb4295605e7373edce3b1a93"};
164 for (
auto i{0}; i < 3; ++i) {
212 auto mtx_parent = CreateValidMempoolTransaction(m_coinbase_txns[0], 0,
269 auto mtx_parent = CreateValidMempoolTransaction(m_coinbase_txns[0], 0, 0, coinbaseKey,
spk,
295 for (
int i{0}; i < 24; ++i) {
296 auto parent =
MakeTransactionRef(CreateValidMempoolTransaction(m_coinbase_txns[i + 1],
369 for (
size_t i{0}; i < 10; ++i) {
370 auto mtx = CreateValidMempoolTransaction(m_coinbase_txns[i + 25], 0,
387 auto mtx_parent = CreateValidMempoolTransaction(m_coinbase_txns[0], 0,
454 "Package validation unexpectedly failed: " <<
submit_parent_child.m_state.GetRejectReason());
554 auto mtx_single = CreateValidMempoolTransaction(m_coinbase_txns[0], 0,
564 "Package validation unexpectedly failed: " <<
result_single_tx.m_state.ToString());
570 auto mtx_parent = CreateValidMempoolTransaction(m_coinbase_txns[1], 0,
645 auto mtx_parent = CreateValidMempoolTransaction(m_coinbase_txns[0], 0,
766 auto mtx_parent1 = CreateValidMempoolTransaction(m_coinbase_txns[1], 0,
784 auto mtx_grandparent2 = CreateValidMempoolTransaction(m_coinbase_txns[2], 0,
812 auto mtx_parent3 = CreateValidMempoolTransaction(m_coinbase_txns[3], 0,
885 auto mtx_parent = CreateValidMempoolTransaction(m_coinbase_txns[0], 0,
958 auto mtx_parent_cheap = CreateValidMempoolTransaction(m_coinbase_txns[1], 0,
1036 auto mtx_parent_rich = CreateValidMempoolTransaction(m_coinbase_txns[2], 0,
1097 auto mtx_parent = CreateValidMempoolTransaction(m_coinbase_txns[0], 0,
1143 m_coinbase_txns[1], 0, 0,
1150 m_coinbase_txns[1], 0, 0,
1157 m_coinbase_txns[1], 0, 0,
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.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
An encapsulated private key.
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.
Double ended buffer combining vector and stream-like interfaces.
A writer stream (for serialization) that computes a 256-bit hash.
uint256 rand256() noexcept
generate a random uint256.
std::string GetRejectReason() const
transaction_identifier represents the two canonical transaction identifier types (txid,...
static transaction_identifier FromUint256(const uint256 &id)
static int32_t GetTransactionWeight(const CTransaction &tx)
@ TX_MISSING_INPUTS
transaction was missing some of its inputs
@ TX_WITNESS_MUTATED
Transaction might have a witness prior to SegWit activation, or witness may have been malleated (whic...
@ TX_RECONSIDERABLE
fails some policy, but might be acceptable if submitted in a (different) package
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()
CKey GenerateRandomKey(bool compressed) noexcept
""_hex is a compile-time user-defined literal returning a std::array<std::byte>, equivalent to ParseH...
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
bool IsChildWithParents(const Package &package)
Context-free check that a package is exactly one child and its parents; not all parents need to be pr...
bool IsWellFormedPackage(const Package &txns, PackageValidationState &state)
Context-free package policy checks:
bool IsConsistentPackage(const Package &txns)
Checks that these transactions don't conflict, i.e., spend the same prevout.
bool IsChildWithParentsTree(const Package &package)
Context-free check that a package IsChildWithParents() and none of the parents depend on each other (...
bool IsTopoSortedPackage(const Package &txns, std::unordered_set< Txid, SaltedTxidHasher > &later_txids)
IsTopoSortedPackage where a set of txids has been pre-populated.
uint256 GetPackageHash(const std::vector< CTransactionRef > &transactions)
Get the hash of the concatenated wtxids of transactions, with wtxids treated as a little-endian numbe...
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
static constexpr uint32_t MAX_PACKAGE_WEIGHT
Default maximum total weight of transactions in a package in weight to allow for context-less checks.
static constexpr uint32_t MAX_PACKAGE_COUNT
Default maximum number of transactions in a package.
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
@ PCKG_TX
At least one tx is invalid.
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
static constexpr unsigned int DEFAULT_CLUSTER_SIZE_LIMIT_KVB
Maximum size of cluster in virtual kilobytes.
static constexpr TransactionSerParams TX_WITH_WITNESS
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
std::vector< unsigned char > ToByteVector(const T &in)
constexpr deserialize_type deserialize
static constexpr CAmount CENT
A mutable version of CTransaction.
std::vector< std::vector< unsigned char > > stack
Validation result for a transaction evaluated by MemPoolAccept (single or package).
@ DIFFERENT_WITNESS
Valid, transaction was already in the mempool.
@ INVALID
Fully validated, valid.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outputs)
std::unique_ptr< CTxMemPool > mempool
std::unique_ptr< ChainstateManager > chainman
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
static const CScript P2WSH_OP_TRUE
std::optional< std::string > CheckPackageMempoolAcceptResult(const Package &txns, const PackageMempoolAcceptResult &result, bool expect_valid, const CTxMemPool *mempool)
Check expected properties for every PackageMempoolAcceptResult, regardless of value.
void MockMempoolMinFee(const CFeeRate &target_feerate, CTxMemPool &mempool)
Mock the mempool minimum feerate by adding a transaction and calling TrimToSize(0),...
static const CAmount low_fee_amt
BOOST_AUTO_TEST_CASE(package_hash_tests)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
PackageMempoolAcceptResult ProcessNewPackage(Chainstate &active_chainstate, CTxMemPool &pool, const Package &package, bool test_accept, const std::optional< CFeeRate > &client_maxfeerate)
Validate (and maybe submit) a package to the mempool.