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. The two line-number columns refer to before and after.
src/test/mempool_tests.cpp
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
#include <boost/test/unit_test.hpp>
|
|
15
15
|
#include <array>
|
|
16
|
+
#include <barrier>
|
|
16
17
|
#include <limits>
|
|
17
18
|
#include <thread>
|
|
18
19
|
#include <vector>
|
|
@@ -26,6 +27,7 @@ BOOST_AUTO_TEST_CASE(DynamicDustFeePublication)
|
|
|
26
27
|
CScheduler scheduler;
|
|
27
28
|
auto opts{MemPoolOptionsForTest(m_node)};
|
|
28
29
|
opts.scheduler = &scheduler;
|
|
30
|
+
opts.signals = nullptr;
|
|
29
31
|
opts.dust_relay_target = 1;
|
|
30
32
|
opts.dust_relay_multiplier = 1000;
|
|
31
33
|
opts.dust_relay_feerate = CFeeRate{3000};
|
|
@@ -47,13 +49,25 @@ BOOST_AUTO_TEST_CASE(DynamicDustFeePublication)
|
|
|
47
49
|
// Exercise the scheduler's writer concurrently with the public snapshot
|
|
48
50
|
// reader. The guarded state also exposes unsynchronized access to Clang's
|
|
49
51
|
// thread-safety analysis and race-detecting builds.
|
|
52
|
+
std::barrier start{2};
|
|
50
53
|
std::thread updater{[&] {
|
|
51
|
-
for (int i{0}; i < 1000; ++i) pool.UpdateDynamicDustFeerate();
|
|
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
|
+
}
|
|
52
61
|
}};
|
|
53
62
|
bool consistent{true};
|
|
54
|
-
for (int i{0}; i < 1000; ++i) consistent &= pool.GetDustRelayFee() == expected;
|
|
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
|
+
}
|
|
55
68
|
updater.join();
|
|
56
69
|
BOOST_CHECK(consistent);
|
|
70
|
+
BOOST_CHECK(pool.GetDustRelayFee() == expected);
|
|
57
71
|
WITH_LOCK(pool.cs, pool.removeRecursive(*txref, MemPoolRemovalReason::EXPIRY));
|
|
58
72
|
pool.UpdateDynamicDustFeerate();
|
|
59
73
|
BOOST_CHECK(pool.GetDustRelayFee() == opts.dust_relay_feerate);
|