v29.4-roots.2 · Commit 3: [PATCH 03/21] policy: restore conservative relay and network controls
src/test/mempool_tests.cpp
Before: src/test/mempool_tests.cpp · After: src/test/mempool_tests.cpp
File metadata
index aa6333321f1f60d66771ae8ef8dc233ea3d5074b..9acdec12f4adee1184fd2636da95eb073db2a2ea 100644
Download original patch · Release notes
Diff rows 1–44 of 44. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
src/test/mempool_tests.cpp
CHANGED
|
@@ -435,6 +435,8 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
|
|
| 435 |
{
|
| 436 |
auto& pool = static_cast<MemPoolTest&>(*Assert(m_node.mempool));
|
| 437 |
LOCK2(cs_main, pool.cs);
|
|
|
|
|
|
|
| 438 |
TestMemPoolEntryHelper entry;
|
| 439 |
|
| 440 |
CMutableTransaction tx1 = CMutableTransaction();
|
|
@@ -482,7 +484,7 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
|
|
| 482 |
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx3.GetHash())));
|
| 483 |
|
| 484 |
CFeeRate maxFeeRateRemoved(2500, GetVirtualTransactionSize(CTransaction(tx3)) + GetVirtualTransactionSize(CTransaction(tx2)));
|
| 485 |
-
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + DEFAULT_INCREMENTAL_RELAY_FEE);
|
| 486 |
|
| 487 |
CMutableTransaction tx4 = CMutableTransaction();
|
| 488 |
tx4.vin.resize(2);
|
|
@@ -559,23 +561,23 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
|
|
| 559 |
std::vector<CTransactionRef> vtx;
|
| 560 |
SetMockTime(42);
|
| 561 |
SetMockTime(42 + CTxMemPool::ROLLING_FEE_HALFLIFE);
|
| 562 |
-
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + DEFAULT_INCREMENTAL_RELAY_FEE);
|
| 563 |
// ... we should keep the same min fee until we get a block
|
| 564 |
pool.removeForBlock(vtx, 1);
|
| 565 |
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE);
|
| 566 |
-
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), llround((maxFeeRateRemoved.GetFeePerK() + DEFAULT_INCREMENTAL_RELAY_FEE)/2.0));
|
| 567 |
// ... then feerate should drop 1/2 each halflife
|
| 568 |
|
| 569 |
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2);
|
| 570 |
-
BOOST_CHECK_EQUAL(pool.GetMinFee(pool.DynamicMemoryUsage() * 5 / 2).GetFeePerK(), llround((maxFeeRateRemoved.GetFeePerK() + DEFAULT_INCREMENTAL_RELAY_FEE)/4.0));
|
| 571 |
// ... with a 1/2 halflife when mempool is < 1/2 its target size
|
| 572 |
|
| 573 |
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2 + CTxMemPool::ROLLING_FEE_HALFLIFE/4);
|
| 574 |
-
BOOST_CHECK_EQUAL(pool.GetMinFee(pool.DynamicMemoryUsage() * 9 / 2).GetFeePerK(), llround((maxFeeRateRemoved.GetFeePerK() + DEFAULT_INCREMENTAL_RELAY_FEE)/8.0));
|
| 575 |
// ... with a 1/4 halflife when mempool is < 1/4 its target size
|
| 576 |
|
| 577 |
SetMockTime(42 + 7*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2 + CTxMemPool::ROLLING_FEE_HALFLIFE/4);
|
| 578 |
-
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), DEFAULT_INCREMENTAL_RELAY_FEE);
|
| 579 |
// ... but feerate should never drop below DEFAULT_INCREMENTAL_RELAY_FEE
|
| 580 |
|
| 581 |
SetMockTime(42 + 8*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2 + CTxMemPool::ROLLING_FEE_HALFLIFE/4);
|
|
|
|
| 435 |
{
|
| 436 |
auto& pool = static_cast<MemPoolTest&>(*Assert(m_node.mempool));
|
| 437 |
LOCK2(cs_main, pool.cs);
|
| 438 |
+
pool.m_opts.min_relay_feerate = CFeeRate{CORE_INCREMENTAL_RELAY_FEE};
|
| 439 |
+
pool.m_opts.incremental_relay_feerate = CFeeRate{CORE_INCREMENTAL_RELAY_FEE};
|
| 440 |
TestMemPoolEntryHelper entry;
|
| 441 |
|
| 442 |
CMutableTransaction tx1 = CMutableTransaction();
|
|
|
|
| 484 |
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx3.GetHash())));
|
| 485 |
|
| 486 |
CFeeRate maxFeeRateRemoved(2500, GetVirtualTransactionSize(CTransaction(tx3)) + GetVirtualTransactionSize(CTransaction(tx2)));
|
| 487 |
+
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + pool.m_opts.incremental_relay_feerate.GetFeePerK());
|
| 488 |
|
| 489 |
CMutableTransaction tx4 = CMutableTransaction();
|
| 490 |
tx4.vin.resize(2);
|
|
|
|
| 561 |
std::vector<CTransactionRef> vtx;
|
| 562 |
SetMockTime(42);
|
| 563 |
SetMockTime(42 + CTxMemPool::ROLLING_FEE_HALFLIFE);
|
| 564 |
+
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + pool.m_opts.incremental_relay_feerate.GetFeePerK());
|
| 565 |
// ... we should keep the same min fee until we get a block
|
| 566 |
pool.removeForBlock(vtx, 1);
|
| 567 |
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE);
|
| 568 |
+
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), llround((maxFeeRateRemoved.GetFeePerK() + pool.m_opts.incremental_relay_feerate.GetFeePerK())/2.0));
|
| 569 |
// ... then feerate should drop 1/2 each halflife
|
| 570 |
|
| 571 |
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2);
|
| 572 |
+
BOOST_CHECK_EQUAL(pool.GetMinFee(pool.DynamicMemoryUsage() * 5 / 2).GetFeePerK(), llround((maxFeeRateRemoved.GetFeePerK() + pool.m_opts.incremental_relay_feerate.GetFeePerK())/4.0));
|
| 573 |
// ... with a 1/2 halflife when mempool is < 1/2 its target size
|
| 574 |
|
| 575 |
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2 + CTxMemPool::ROLLING_FEE_HALFLIFE/4);
|
| 576 |
+
BOOST_CHECK_EQUAL(pool.GetMinFee(pool.DynamicMemoryUsage() * 9 / 2).GetFeePerK(), llround((maxFeeRateRemoved.GetFeePerK() + pool.m_opts.incremental_relay_feerate.GetFeePerK())/8.0));
|
| 577 |
// ... with a 1/4 halflife when mempool is < 1/4 its target size
|
| 578 |
|
| 579 |
SetMockTime(42 + 7*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2 + CTxMemPool::ROLLING_FEE_HALFLIFE/4);
|
| 580 |
+
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), pool.m_opts.incremental_relay_feerate.GetFeePerK());
|
| 581 |
// ... but feerate should never drop below DEFAULT_INCREMENTAL_RELAY_FEE
|
| 582 |
|
| 583 |
SetMockTime(42 + 8*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2 + CTxMemPool::ROLLING_FEE_HALFLIFE/4);
|