15#include <boost/test/unit_test.hpp>
25 std::vector<CAmount> feeV;
29 for (
int j = 0; j < 10; j++) {
30 feeV.push_back(basefee * (j+1));
37 std::list<CTxMemPoolEntry> mempool_txs[10];
41 for (
unsigned int i = 0; i < 128; i++)
45 tx.
vin[0].scriptSig = garbage;
47 tx.
vout[0].nValue=0LL;
51 std::vector<RemovedMempoolTransactionInfo> block_txs;
57 while (blocknum < 200) {
58 for (
int j = 0; j < 10; j++) {
59 for (
int k = 0;
k < 4;
k++) {
60 tx.
vin[0].prevout.n = 10000*blocknum+100*j+
k;
62 mempool_txs[j].emplace_back(entry.
Fee(feeV[j]).
Time(Now<NodeSeconds>()).
Height(blocknum).
FromTx(tx));
72 feeEst.processTransaction(tx_info);
76 for (
int h = 0; h <= blocknum%10; h++) {
80 while (mempool_txs[9 - h].size()) {
81 auto& tx_entry = mempool_txs[9 - h].back();
82 block_txs.emplace_back(tx_entry);
83 mempool_txs[9 - h].pop_back();
87 feeEst.processBlock(block_txs, ++blocknum);
100 std::vector<CAmount> origFeeEst;
107 for (
int i = 1; i < 10;i++) {
108 origFeeEst.push_back(feeEst.estimateFee(i).GetFeePerK());
119 for (
int i = 10; i <= 48; i++) {
120 origFeeEst.push_back(feeEst.estimateFee(i).GetFeePerK());
125 while (blocknum < 250) {
126 feeEst.processBlock(block_txs, ++blocknum);
130 for (
int i = 2; i < 10;i++) {
131 BOOST_CHECK(feeEst.estimateFee(i).GetFeePerK() < origFeeEst[i-1] + deltaFee);
132 BOOST_CHECK(feeEst.estimateFee(i).GetFeePerK() > origFeeEst[i-1] - deltaFee);
138 while (blocknum < 265) {
139 for (
int j = 0; j < 10; j++) {
140 for (
int k = 0;
k < 4;
k++) {
141 tx.
vin[0].prevout.n = 10000*blocknum+100*j+
k;
143 mempool_txs[j].emplace_back(entry.
Fee(feeV[j]).
Time(Now<NodeSeconds>()).
Height(blocknum).
FromTx(tx));
153 feeEst.processTransaction(tx_info);
156 feeEst.processBlock(block_txs, ++blocknum);
159 for (
int i = 1; i < 10;i++) {
165 for (
int j = 0; j < 10; j++) {
166 while (mempool_txs[j].size()) {
167 auto& tx_entry = mempool_txs[j].back();
168 block_txs.emplace_back(tx_entry);
169 mempool_txs[j].pop_back();
173 feeEst.processBlock(block_txs, ++blocknum);
177 for (
int i = 2; i < 10;i++) {
183 while (blocknum < 665) {
184 for (
int j = 0; j < 10; j++) {
185 for (
int k = 0;
k < 4;
k++) {
186 tx.
vin[0].prevout.n = 10000*blocknum+100*j+
k;
200 feeEst.processTransaction(tx_info);
201 block_txs.emplace_back(tx_entry);
205 feeEst.processBlock(block_txs, ++blocknum);
209 for (
int i = 2; i < 9; i++) {
210 BOOST_CHECK(feeEst.estimateFee(i).GetFeePerK() < origFeeEst[i-1] - deltaFee);
int64_t CAmount
Amount in satoshis (Can be negative)
constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES
BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
void push_back(const T &value)
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
fs::path BlockPolicyFeeEstPath(const ArgsManager &argsman)
#define BOOST_CHECK(expr)
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
static CTransactionRef MakeTransactionRef(Tx &&txIn)
A mutable version of CTransaction.
std::vector< CTxOut > vout
Testing setup that performs all steps up until right before ChainstateManager gets initialized.
TestMemPoolEntryHelper & Time(NodeSeconds tp)
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
TestMemPoolEntryHelper & Height(unsigned int _height)
TestMemPoolEntryHelper & Fee(CAmount _fee)