18#include <validation.h>
20#include <boost/test/unit_test.hpp>
33 tx.vin[0].prevout.n = 0;
36 tx.vout[0].nValue =
COIN;
45 auto block = std::make_shared<CBlock>();
46 std::vector<RemovedMempoolTransactionInfo>
removed_txs;
54 block->vtx.emplace_back(tx);
137 const std::string
unloaded_err =
strprintf(
"%s: Mempool not loaded yet, no fee rate estimate available",
176 unsigned int height = 100;
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.
Wrapper around FeeFrac & derived types, which adds a feerate-based ordering which treats equal-feerat...
Serialized script, used inside transaction inputs and outputs.
int32_t GetTxSize() const
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
MemPoolFeeRateEstimatorCache holds a cache of recent fee rate estimates.
std::optional< FeeRateEstimate > GetCachedEstimate(const uint256 &tip_hash) const
Returns cached estimates if not stale and computed on tip_hash, nullopt otherwise.
bool IsStale() const
Returns true if the cache is empty or older than CACHE_LIFE.
void Update(FeePerVSize conservative, FeePerVSize economical, const uint256 &tip_hash)
Update the cache with new estimates computed on tip_hash.
Estimate the fee rate required for a transaction to be included in the next block.
static Percentiles CalculateMaxWeightPercentiles(std::span< const FeePerVSize > chunk_feerates)
Calculate the 50th and 75th percentile fee rates from block template chunks, sorted in descending min...
@ INSUFFICIENT_DATA
Too few recent mined blocks to estimate a fee rate.
uint256 rand256() noexcept
generate a random uint256.
static transaction_identifier FromUint256(const uint256 &id)
static int32_t GetTransactionWeight(const CTransaction &tx)
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()
fs::path MempoolPolicyEstimatorPath(const ArgsManager &argsman)
constexpr int MEMPOOL_FEE_ESTIMATOR_MAX_TARGET
constexpr std::chrono::seconds CACHE_LIFE
constexpr size_t MEMPOOL_HEALTH_WINDOW_BLOCKS
void AddRemovedBlock(MemPoolFeeRateEstimator &fee_est, int32_t removed_txs_weight, int32_t block_txs_weight, unsigned int &height)
BOOST_AUTO_TEST_CASE(calculate_max_weight_percentiles)
static CTransactionRef MakeRandomTx()
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT
Default for -blockmaxweight, which controls the range of block weights the mining code will create.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
A mutable version of CTransaction.
Data structure storing a fee and size.
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
TestMemPoolEntryHelper & Fee(CAmount _fee)
Testing setup that configures a complete environment.
std::unique_ptr< CTxMemPool > mempool
std::unique_ptr< ChainstateManager > chainman
std::string_view FeeRateEstimatorTypeToString(FeeRateEstimatorType feerate_estimator_type)
void SetMockTime(std::chrono::time_point< NodeClock, std::chrono::seconds > mock)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.