Skip to content
Bitcoin Roots

v30.3-roots.1 · Commit 54: [PATCH 54/68] mempool: snapshot dynamic dust for standardness checks

src/test/mempool_tests.cpp

Before: src/test/mempool_tests.cpp · After: src/test/mempool_tests.cpp

File metadata
index 14862d9b209a0d2107a96fa233843217f455d9f1..2904eac54f2278a6bb757965a35c21e4e7f22650 100644

Download original patch · Release notes

Diff rows 1–36 of 36. 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
@@ -2,6 +2,7 @@
2
2
  // Distributed under the MIT software license, see the accompanying
3
3
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
 
5
+ #include <addresstype.h>
5
6
  #include <common/system.h>
6
7
  #include <policy/policy.h>
7
8
  #include <scheduler.h>
@@ -31,6 +32,7 @@ BOOST_AUTO_TEST_CASE(DynamicDustFeePublication)
31
32
  opts.dust_relay_target = 1;
32
33
  opts.dust_relay_multiplier = 1000;
33
34
  opts.dust_relay_feerate = CFeeRate{3000};
35
+ opts.permitephemeral_send = false;
34
36
  bilingual_str error;
35
37
  CTxMemPool pool{opts, error};
36
38
  BOOST_REQUIRE(error.empty());
@@ -45,6 +47,14 @@ BOOST_AUTO_TEST_CASE(DynamicDustFeePublication)
45
47
  BOOST_CHECK(pool.GetDustRelayFee() == opts.dust_relay_feerate);
46
48
  pool.UpdateDynamicDustFeerate();
47
49
  BOOST_CHECK_EQUAL(pool.GetDustRelayFee().GetFeePerK(), expected.GetFeePerK());
50
+ CMutableTransaction probe;
51
+ probe.vin.resize(1);
52
+ const CScript destination{GetScriptForDestination(PKHash{})};
53
+ probe.vout.emplace_back(GetDustThreshold(CTxOut{0, destination}, opts.dust_relay_feerate), destination);
54
+ std::string reason;
55
+ BOOST_CHECK(IsStandardTx(CTransaction{probe}, opts, reason));
56
+ BOOST_CHECK(!IsStandardTx(CTransaction{probe}, pool.GetStandardnessOptions(), reason));
57
+ BOOST_CHECK_EQUAL(reason, "dust-nonanchor");
48
58
 
49
59
  // Exercise the scheduler's writer concurrently with the public snapshot
50
60
  // reader. The guarded state also exposes unsynchronized access to Clang's
@@ -71,6 +81,8 @@ BOOST_AUTO_TEST_CASE(DynamicDustFeePublication)
71
81
  WITH_LOCK(pool.cs, pool.removeRecursive(*txref, MemPoolRemovalReason::EXPIRY));
72
82
  pool.UpdateDynamicDustFeerate();
73
83
  BOOST_CHECK(pool.GetDustRelayFee() == opts.dust_relay_feerate);
84
+ reason.clear();
85
+ BOOST_CHECK(IsStandardTx(CTransaction{probe}, pool.GetStandardnessOptions(), reason));
74
86
  }
75
87
 
76
88
  BOOST_AUTO_TEST_CASE(MempoolExtraWeightBoundary)