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. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

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