aboutsummaryrefslogtreecommitdiff
path: root/src/test/transaction_tests.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2015-10-13 19:23:11 +0200
committerMarcoFalke <falke.marco@gmail.com>2015-11-09 21:00:16 +0100
commit5f46a7d0689ff1457b016fdf0de89e5153058864 (patch)
tree2dc4685628cd5f641156ce4a17bc047704e8898d /src/test/transaction_tests.cpp
parent503ff6e1ae6932b63892099b4c63e92a9263fed6 (diff)
transaction_tests: Be more strict checking dust
* Don't allow off-by-one or more * Make clear dust is coupled with minRelayTxFee * Check rounding for odd values
Diffstat (limited to 'src/test/transaction_tests.cpp')
-rw-r--r--src/test/transaction_tests.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index f9423bc0de..c840f4c9fd 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -342,11 +342,26 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
string reason;
BOOST_CHECK(IsStandardTx(t, reason));
- t.vout[0].nValue = 501; // dust
+ // Check dust with default relay fee:
+ CAmount nDustThreshold = 182 * minRelayTxFee.GetFeePerK()/1000 * 3;
+ BOOST_CHECK_EQUAL(nDustThreshold, 546);
+ // dust:
+ t.vout[0].nValue = nDustThreshold - 1;
BOOST_CHECK(!IsStandardTx(t, reason));
+ // not dust:
+ t.vout[0].nValue = nDustThreshold;
+ BOOST_CHECK(IsStandardTx(t, reason));
- t.vout[0].nValue = 2730; // not dust
+ // Check dust with odd relay fee to verify rounding:
+ // nDustThreshold = 182 * 1234 / 1000 * 3
+ minRelayTxFee = CFeeRate(1234);
+ // dust:
+ t.vout[0].nValue = 672 - 1;
+ BOOST_CHECK(!IsStandardTx(t, reason));
+ // not dust:
+ t.vout[0].nValue = 672;
BOOST_CHECK(IsStandardTx(t, reason));
+ minRelayTxFee = CFeeRate(1000);
t.vout[0].scriptPubKey = CScript() << OP_1;
BOOST_CHECK(!IsStandardTx(t, reason));