v30.3-roots.1 · Commit 53: [PATCH 53/68] test: exercise changing dynamic dust publication
src/test/mempool_tests.cpp
Before: src/test/mempool_tests.cpp · After: src/test/mempool_tests.cpp
File metadata
index 313c9725b3c6027a5428db4d2da91790fdc2cb4e..14862d9b209a0d2107a96fa233843217f455d9f1 100644
Download original patch · Release notes
Diff rows 1–41 of 41. 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
|
@@ -13,6 +13,7 @@
|
|
| 13 |
|
| 14 |
#include <boost/test/unit_test.hpp>
|
| 15 |
#include <array>
|
|
|
|
| 16 |
#include <limits>
|
| 17 |
#include <thread>
|
| 18 |
#include <vector>
|
|
@@ -26,6 +27,7 @@ BOOST_AUTO_TEST_CASE(DynamicDustFeePublication)
|
|
| 26 |
CScheduler scheduler;
|
| 27 |
auto opts{MemPoolOptionsForTest(m_node)};
|
| 28 |
opts.scheduler = &scheduler;
|
|
|
|
| 29 |
opts.dust_relay_target = 1;
|
| 30 |
opts.dust_relay_multiplier = 1000;
|
| 31 |
opts.dust_relay_feerate = CFeeRate{3000};
|
|
@@ -47,13 +49,25 @@ BOOST_AUTO_TEST_CASE(DynamicDustFeePublication)
|
|
| 47 |
// Exercise the scheduler's writer concurrently with the public snapshot
|
| 48 |
// reader. The guarded state also exposes unsynchronized access to Clang's
|
| 49 |
// thread-safety analysis and race-detecting builds.
|
|
|
|
| 50 |
std::thread updater{[&] {
|
| 51 |
-
for (int i{0}; i < 1000; ++i) pool.UpdateDynamicDustFeerate();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
}};
|
| 53 |
bool consistent{true};
|
| 54 |
-
for (int i{0}; i < 1000; ++i) consistent &= pool.GetDustRelayFee() == expected;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
updater.join();
|
| 56 |
BOOST_CHECK(consistent);
|
|
|
|
| 57 |
WITH_LOCK(pool.cs, pool.removeRecursive(*txref, MemPoolRemovalReason::EXPIRY));
|
| 58 |
pool.UpdateDynamicDustFeerate();
|
| 59 |
BOOST_CHECK(pool.GetDustRelayFee() == opts.dust_relay_feerate);
|
|
|
|
| 13 |
|
| 14 |
#include <boost/test/unit_test.hpp>
|
| 15 |
#include <array>
|
| 16 |
+
#include <barrier>
|
| 17 |
#include <limits>
|
| 18 |
#include <thread>
|
| 19 |
#include <vector>
|
|
|
|
| 27 |
CScheduler scheduler;
|
| 28 |
auto opts{MemPoolOptionsForTest(m_node)};
|
| 29 |
opts.scheduler = &scheduler;
|
| 30 |
+
opts.signals = nullptr;
|
| 31 |
opts.dust_relay_target = 1;
|
| 32 |
opts.dust_relay_multiplier = 1000;
|
| 33 |
opts.dust_relay_feerate = CFeeRate{3000};
|
|
|
|
| 49 |
// Exercise the scheduler's writer concurrently with the public snapshot
|
| 50 |
// reader. The guarded state also exposes unsynchronized access to Clang's
|
| 51 |
// thread-safety analysis and race-detecting builds.
|
| 52 |
+
std::barrier start{2};
|
| 53 |
std::thread updater{[&] {
|
| 54 |
+
start.arrive_and_wait();
|
| 55 |
+
for (int i{0}; i < 1000; ++i) {
|
| 56 |
+
WITH_LOCK(pool.cs, pool.removeRecursive(*txref, MemPoolRemovalReason::EXPIRY));
|
| 57 |
+
pool.UpdateDynamicDustFeerate();
|
| 58 |
+
AddToMempool(pool, TestMemPoolEntryHelper{}.Fee(fee).FromTx(txref));
|
| 59 |
+
pool.UpdateDynamicDustFeerate();
|
| 60 |
+
}
|
| 61 |
}};
|
| 62 |
bool consistent{true};
|
| 63 |
+
start.arrive_and_wait();
|
| 64 |
+
for (int i{0}; i < 1000; ++i) {
|
| 65 |
+
const CFeeRate rate{pool.GetDustRelayFee()};
|
| 66 |
+
consistent &= rate == expected || rate == opts.dust_relay_feerate;
|
| 67 |
+
}
|
| 68 |
updater.join();
|
| 69 |
BOOST_CHECK(consistent);
|
| 70 |
+
BOOST_CHECK(pool.GetDustRelayFee() == expected);
|
| 71 |
WITH_LOCK(pool.cs, pool.removeRecursive(*txref, MemPoolRemovalReason::EXPIRY));
|
| 72 |
pool.UpdateDynamicDustFeerate();
|
| 73 |
BOOST_CHECK(pool.GetDustRelayFee() == opts.dust_relay_feerate);
|