Skip to content
Bitcoin Roots

v29.4-roots.3 · Commit 10: [PATCH 10/30] fix: harden final Roots assurance

src/wallet/test/spend_tests.cpp

Before: src/wallet/test/spend_tests.cpp · After: src/wallet/test/spend_tests.cpp

File metadata
index ac76fe4dda0084460858a83336d71cab3bd22e9a..e295002a51f207aa95c04a30a87f57d9ed662a29 100644

Download original patch · Release notes

Diff rows 1–27 of 27. 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/wallet/test/spend_tests.cpp CHANGED
@@ -5,6 +5,8 @@
5
5
  #include <consensus/amount.h>
6
6
  #include <key.h>
7
7
  #include <policy/fees.h>
8
+ #include <policy/policy.h>
9
+ #include <random.h>
8
10
  #include <script/solver.h>
9
11
  #include <validation.h>
10
12
  #include <wallet/coincontrol.h>
@@ -33,6 +35,19 @@ BOOST_AUTO_TEST_CASE(max_signed_input_size_uses_external_outpoint)
33
35
  BOOST_CHECK_EQUAL(high_r, low_r + 1);
34
36
  }
35
37
 
38
+ BOOST_AUTO_TEST_CASE(anti_fee_sniping_avoids_reserved_policy_locktime)
39
+ {
40
+ FastRandomContext rng{/*fDeterministic=*/true};
41
+ const int first_height{static_cast<int>(PARASITE_CAT21_LOCKTIME)};
42
+ for (int height{first_height}; height < first_height + 100; ++height) {
43
+ for (int sample = 0; sample < 1000; ++sample) {
44
+ const uint32_t lock_time{GetAntiFeeSnipingLockTime(height, rng)};
45
+ BOOST_CHECK_NE(lock_time, PARASITE_CAT21_LOCKTIME);
46
+ BOOST_CHECK_LE(lock_time, height);
47
+ }
48
+ }
49
+ }
50
+
36
51
  BOOST_FIXTURE_TEST_CASE(SubtractFee, TestChain100Setup)
37
52
  {
38
53
  CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));