14#include <validation.h>
25struct FeeEstimatorManTestingSetup :
public TestingSetup {
30 ~FeeEstimatorManTestingSetup()
35 void SetFeeEstimatorMan(std::unique_ptr<FeeRateEstimatorManager> fee_estimator_man)
41FeeEstimatorManTestingSetup*
g_setup;
58 auto res = GetFeeRateEstimate(confTarget, conservative);
59 if (res) res->feerate_estimator = type;
62 unsigned int MaximumTarget()
const override
68void initialize_setup()
70 static const auto testing_setup = MakeNoLogFileContext<FeeEstimatorManTestingSetup>();
88 node.mempool = std::make_unique<CTxMemPool>(mempool_opts, error);
89 std::unique_ptr<FeeRateEstimatorManager> fee_estimator_man = std::make_unique<FuzzedFeeEstimatorMan>(
fuzzed_data_provider, *
node.mempool, *
node.chainman);
90 g_setup->SetFeeEstimatorMan(std::move(fee_estimator_man));
92 if (target_feerate >
node.mempool->m_opts.incremental_relay_feerate &&
93 target_feerate >
node.mempool->m_opts.min_relay_feerate) {
97 CWallet&
wallet{*wallet_ptr};
120 CCoinControl coin_control;
134 std::optional<int> returned_target;
138 MinimumFeeRateResult min_fee_rate{
constexpr CAmount COIN
The amount of satoshis in one BTC.
const TestingSetup * g_setup
uint256 GetBlockHash() const
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
FeePerVSize m_feerate
Fee rate in sats/vB (satoshis per N virtualbytes)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Chainstate stores and provides an API to update our local knowledge of the current best chain.
CChain m_chain
The current chain of blockheaders we consult and build on.
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainsta...
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
Manages fee rate estimators.
T ConsumeIntegralInRange(T min, T max)
T PickValueInArray(const T(&array)[size])
The util::Expected class provides a standard way for low-level functions to return either error value...
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase()
CFeeRate GetRequiredFeeRate(const CWallet &wallet)
Return the minimum required feerate taking into account the minimum relay feerate and user set minimu...
MinimumFeeRateResult GetMinimumFeeRate(const CWallet &wallet, const CCoinControl &coin_control)
Estimate the minimum fee rate considering user set parameters and the required fee.
CAmount GetMinimumFee(const MinimumFeeRateResult &min_fee_rate, unsigned int nTxBytes)
Return the minimum fee for this size given a fee rate result.
FUZZ_TARGET(coin_grinder)
CFeeRate GetDiscardRate(const CWallet &wallet)
Return the maximum feerate for discarding change.
CAmount GetRequiredFee(const CWallet &wallet, unsigned int nTxBytes)
Return the minimum required absolute fee for this size based on the required fee rate.
A successful fee rate estimate returned by a fee rate estimator.
Testing setup that configures a complete environment.
Options struct containing options for constructing a CTxMemPool.
CFeeRate incremental_relay_feerate
std::unique_ptr< FeeRateEstimatorManager > fee_estimator_man
SeedRandomStateForTest(SeedRand::ZEROS)
FuzzedDataProvider provider
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
CAmount ConsumeMoney(FuzzedDataProvider &fuzzed_data_provider, const std::optional< CAmount > &max) noexcept
@ ZEROS
Seed with a compile time constant of zeros.
void MockMempoolMinFee(const CFeeRate &target_feerate, CTxMemPool &mempool)
Mock the mempool minimum feerate by adding a transaction and calling TrimToSize(0),...
FeeRateEstimatorType
Identifier for fee rate estimator.
@ CONSERVATIVE
Force Fee rate estimator to return conservative estimates.
@ ECONOMICAL
Force Fee rate estimator to return non-conservative estimates.
FuzzedDataProvider & fuzzed_data_provider