16 #include <boost/test/unit_test.hpp> 28 std::vector<CAmount> feeV;
32 for (
int j = 0; j < 10; j++) {
33 feeV.push_back(basefee * (j+1));
40 std::vector<uint256> txHashes[10];
44 for (
unsigned int i = 0; i < 128; i++)
48 tx.
vin[0].scriptSig = garbage;
50 tx.
vout[0].nValue=0LL;
54 std::vector<CTransactionRef> block;
60 while (blocknum < 200) {
61 for (
int j = 0; j < 10; j++) {
62 for (
int k = 0;
k < 4;
k++) {
63 tx.
vin[0].prevout.n = 10000*blocknum+100*j+
k;
81 txHashes[j].push_back(hash);
85 for (
int h = 0; h <= blocknum%10; h++) {
89 while (txHashes[9-h].size()) {
93 txHashes[9-h].pop_back();
119 std::vector<CAmount> origFeeEst;
126 for (
int i = 1; i < 10;i++) {
127 origFeeEst.push_back(feeEst.estimateFee(i).GetFeePerK());
138 for (
int i = 10; i <= 48; i++) {
139 origFeeEst.push_back(feeEst.estimateFee(i).GetFeePerK());
144 while (blocknum < 250) {
153 for (
int i = 2; i < 10;i++) {
154 BOOST_CHECK(feeEst.estimateFee(i).GetFeePerK() < origFeeEst[i-1] + deltaFee);
155 BOOST_CHECK(feeEst.estimateFee(i).GetFeePerK() > origFeeEst[i-1] - deltaFee);
161 while (blocknum < 265) {
162 for (
int j = 0; j < 10; j++) {
163 for (
int k = 0;
k < 4;
k++) {
164 tx.
vin[0].prevout.n = 10000*blocknum+100*j+
k;
182 txHashes[j].push_back(hash);
194 for (
int i = 1; i < 10;i++) {
200 for (
int j = 0; j < 10; j++) {
201 while(txHashes[j].size()) {
204 block.push_back(ptx);
205 txHashes[j].pop_back();
219 for (
int i = 2; i < 10;i++) {
225 while (blocknum < 665) {
226 for (
int j = 0; j < 10; j++) {
227 for (
int k = 0;
k < 4;
k++) {
228 tx.
vin[0].prevout.n = 10000*blocknum+100*j+
k;
248 block.push_back(ptx);
263 for (
int i = 2; i < 9; i++) {
264 BOOST_CHECK(feeEst.estimateFee(i).GetFeePerK() < origFeeEst[i-1] - deltaFee);
std::shared_ptr< const CTransaction > CTransactionRef
Testing setup that performs all steps up until right before ChainstateManager gets initialized...
fs::path FeeestPath(const ArgsManager &argsman)
TestMemPoolEntryHelper & Fee(CAmount _fee)
static constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
std::unique_ptr< CTxMemPool > mempool
int64_t CAmount
Amount in satoshis (Can be negative)
void push_back(const T &value)
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
BOOST_AUTO_TEST_SUITE_END()
Txid GetHash() const
Compute the hash of this CMutableTransaction.
AddToMempool(pool, CTxMemPoolEntry(tx, fee, nTime, nHeight, sequence, spendsCoinbase, sigOpCost, lp))
std::vector< CTxOut > vout
TestMemPoolEntryHelper & Height(unsigned int _height)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
uint64_t GetAndIncrementSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Guards this internal counter for external reporting.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Serialized script, used inside transaction inputs and outputs.
TestMemPoolEntryHelper & Time(NodeSeconds tp)
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
A mutable version of CTransaction.
CTransactionRef get(const uint256 &hash) const
The basic transaction that is broadcasted on the network and contained in blocks. ...
BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
void removeForBlock(const std::vector< CTransactionRef > &vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs)
Called when a block is connected.
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
#define Assert(val)
Identity function.
#define BOOST_CHECK(expr)