v31.1-roots.1 · Commit 3: [PATCH 03/17] feat(policy): preserve cluster accounting and repair dynamic dust
src/test/amount_tests.cpp
Before: src/test/amount_tests.cpp · After: src/test/amount_tests.cpp
File metadata
index e1630b41948dc47849ea670d8c8e90613afddf37..c65c67ed10df733780441e2a90343e64ad4fd8b4 100644
Download original patch · Release notes
Diff rows 1–46 of 46. 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/amount_tests.cpp
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
#include <consensus/amount.h>
|
|
6
6
|
#include <policy/feerate.h>
|
|
7
|
+
#include <policy/policy.h>
|
|
7
8
|
|
|
8
9
|
#include <limits>
|
|
9
10
|
|
|
@@ -116,6 +117,20 @@ BOOST_AUTO_TEST_CASE(GetFeeTest)
|
|
|
116
117
|
BOOST_CHECK(5 * feeRate == CFeeRate(0));
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
BOOST_AUTO_TEST_CASE(FeeRateSaturatedEvaluation)
|
|
121
|
+
{
|
|
122
|
+
constexpr CAmount maximum{std::numeric_limits<CAmount>::max()};
|
|
123
|
+
constexpr CAmount minimum{std::numeric_limits<CAmount>::min()};
|
|
124
|
+
BOOST_CHECK_EQUAL(CFeeRate(maximum, 1).GetFee(2), maximum);
|
|
125
|
+
BOOST_CHECK_EQUAL(CFeeRate(minimum, 1).GetFee(2), minimum);
|
|
126
|
+
BOOST_CHECK_EQUAL(CFeeRate(maximum, 1).GetFee(1), maximum);
|
|
127
|
+
BOOST_CHECK_EQUAL(CFeeRate(minimum, 1).GetFee(1), minimum);
|
|
128
|
+
BOOST_CHECK_EQUAL(CFeeRate(maximum).GetFee(0), 0);
|
|
129
|
+
const CTxOut large_output{0, CScript{} << std::vector<unsigned char>(1000, 1) << OP_DROP << OP_TRUE};
|
|
130
|
+
BOOST_CHECK_EQUAL(GetDustThreshold(large_output, CFeeRate{maximum}), maximum);
|
|
131
|
+
BOOST_CHECK_EQUAL(CFeeRate(maximum).GetFee(999), maximum / 1000 * 999 + (maximum % 1000 * 999 + 999) / 1000);
|
|
132
|
+
}
|
|
133
|
+
|
|
119
134
|
BOOST_AUTO_TEST_CASE(BinaryOperatorTest)
|
|
120
135
|
{
|
|
121
136
|
CFeeRate a, b;
|
|
@@ -142,4 +157,19 @@ BOOST_AUTO_TEST_CASE(ToStringTest)
|
|
|
142
157
|
BOOST_CHECK_EQUAL(feeRate.ToString(FeeRateFormat::SAT_VB), "0.001 sat/vB");
|
|
143
158
|
}
|
|
144
159
|
|
|
160
|
+
BOOST_AUTO_TEST_CASE(DynamicDustScaling)
|
|
161
|
+
{
|
|
162
|
+
constexpr CAmount maximum{std::numeric_limits<CAmount>::max()};
|
|
163
|
+
BOOST_CHECK_EQUAL(CFeeRate(maximum, 1).GetFeePerK(), maximum);
|
|
164
|
+
BOOST_CHECK_EQUAL(CFeeRate(std::numeric_limits<CAmount>::min(), 1).GetFeePerK(), std::numeric_limits<CAmount>::min());
|
|
165
|
+
BOOST_CHECK_EQUAL(ScaleDustFee(CFeeRate{1234}, 1000).GetFeePerK(), 1234);
|
|
166
|
+
BOOST_CHECK_EQUAL(ScaleDustFee(CFeeRate{1234}, 3000).GetFeePerK(), 3702);
|
|
167
|
+
BOOST_CHECK_EQUAL(ScaleDustFee(CFeeRate{1234}, 1).GetFeePerK(), 1);
|
|
168
|
+
BOOST_CHECK_EQUAL(ScaleDustFee(CFeeRate{maximum}, 1000).GetFeePerK(), maximum);
|
|
169
|
+
BOOST_CHECK_EQUAL(ScaleDustFee(CFeeRate{maximum}, INT32_MAX).GetFeePerK(), maximum);
|
|
170
|
+
BOOST_CHECK_EQUAL(ScaleDustFee(CFeeRate{-1}, INT32_MAX).GetFeePerK(), 0);
|
|
171
|
+
BOOST_CHECK_EQUAL(ScaleDustFee(CFeeRate{0}, INT32_MAX).GetFeePerK(), 0);
|
|
172
|
+
BOOST_CHECK_EQUAL(ScaleDustFee(CFeeRate{maximum / 3000 * 1000}, 3000).GetFeePerK(), maximum / 3000 * 3000);
|
|
173
|
+
}
|
|
174
|
+
|
|
145
175
|
BOOST_AUTO_TEST_SUITE_END()
|