From 145bc31b83ca7df01e202f7e3fb7c6722a8fe4d9 Mon Sep 17 00:00:00 2001 From: Jannis Froese Date: Thu, 1 May 2014 21:10:19 +0200 Subject: [PATCH 1/4] don't send feeless transactions (cherry picked from commit 9a2f7a86fca6e243db7745cb1b15b35ce1b97b2e) --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 763b30f99..a95f7cf2d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -791,7 +791,7 @@ int64_t GetMinFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree, int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee; - if (fAllowFree) + if (fAllowFree && mode != GMF_SEND) { // Free transaction area if (nBytes < 26000) From 19653cea9dfff89a50b4c025b87c8556bc4eb375 Mon Sep 17 00:00:00 2001 From: Jannis Froese Date: Mon, 9 Jun 2014 00:46:52 +0200 Subject: [PATCH 2/4] Revert "remove unit tests for new fee mode" This reverts commit 78ed897c4adf021c30cdf10eebf4663f12f78fd1. --- src/test/main_tests.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp index 8f22ed723..8675c1c86 100644 --- a/src/test/main_tests.cpp +++ b/src/test/main_tests.cpp @@ -235,4 +235,28 @@ BOOST_AUTO_TEST_CASE(GetMinFee_createFree_test) BOOST_CHECK(GetMinFee(tx, MAX_STANDARD_TX_SIZE, true, GMF_SEND) == (1+(MAX_STANDARD_TX_SIZE/1000))*CTransaction::nMinTxFee); } +BOOST_AUTO_TEST_CASE(GetMinFee_createNoFree_test) +{ + uint64_t value = 1000 * COIN; + + CTransaction tx; + CTxOut txout1(value, (CScript)vector(24, 0)); + tx.vout.push_back(txout1); + + if(CTransaction::nMinTxFee == CTransaction::nMinRelayTxFee) + CTransaction::nMinTxFee++; + + BOOST_CHECK(GetMinFee(tx, 100, true, GMF_SEND) > 0); + BOOST_CHECK(GetMinFee(tx, 100, true, GMF_SEND) == GetMinFee(tx, 100, false, GMF_SEND)); + BOOST_CHECK(GetMinFee(tx, 1000, true, GMF_SEND) > 0); + BOOST_CHECK(GetMinFee(tx, 1000, true, GMF_SEND) == GetMinFee(tx, 1000, false, GMF_SEND)); + BOOST_CHECK(GetMinFee(tx, 25999, true, GMF_SEND) > 0); + BOOST_CHECK(GetMinFee(tx, 25999, true, GMF_SEND) == GetMinFee(tx, 25999, false, GMF_SEND)); + + BOOST_CHECK(GetMinFee(tx, 26000, true, GMF_SEND) > 0); + BOOST_CHECK(GetMinFee(tx, 26000, true, GMF_SEND) == GetMinFee(tx, 26000, false, GMF_SEND)); + + BOOST_CHECK(GetMinFee(tx, MAX_STANDARD_TX_SIZE, true, GMF_SEND) == (1+(MAX_STANDARD_TX_SIZE/1000))*CTransaction::nMinTxFee); +} + BOOST_AUTO_TEST_SUITE_END() From 23a761453d67f98526678e0919b1c814130d2111 Mon Sep 17 00:00:00 2001 From: Jannis Froese Date: Mon, 9 Jun 2014 00:51:20 +0200 Subject: [PATCH 3/4] remove unit tests for old fee mode --- src/test/main_tests.cpp | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp index 8675c1c86..99ce271e9 100644 --- a/src/test/main_tests.cpp +++ b/src/test/main_tests.cpp @@ -214,27 +214,6 @@ BOOST_AUTO_TEST_CASE(GetMinFee_relayfree_test) BOOST_CHECK(GetMinFee(tx, MAX_STANDARD_TX_SIZE, true, GMF_RELAY) == (1+(MAX_STANDARD_TX_SIZE/1000))*CTransaction::nMinRelayTxFee); } -BOOST_AUTO_TEST_CASE(GetMinFee_createFree_test) -{ - uint64_t value = 1000 * COIN; - - CTransaction tx; - CTxOut txout1(value, (CScript)vector(24, 0)); - tx.vout.push_back(txout1); - - if(CTransaction::nMinTxFee == CTransaction::nMinRelayTxFee) - CTransaction::nMinTxFee++; - - BOOST_CHECK(GetMinFee(tx, 100, true, GMF_SEND) == 0); - BOOST_CHECK(GetMinFee(tx, 1000, true, GMF_SEND) == 0); - BOOST_CHECK(GetMinFee(tx, 25999, true, GMF_SEND) == 0); - - BOOST_CHECK(GetMinFee(tx, 26000, true, GMF_SEND) > 0); - BOOST_CHECK(GetMinFee(tx, 26000, true, GMF_SEND) == GetMinFee(tx, 26000, false, GMF_SEND)); - - BOOST_CHECK(GetMinFee(tx, MAX_STANDARD_TX_SIZE, true, GMF_SEND) == (1+(MAX_STANDARD_TX_SIZE/1000))*CTransaction::nMinTxFee); -} - BOOST_AUTO_TEST_CASE(GetMinFee_createNoFree_test) { uint64_t value = 1000 * COIN; From d0dd93bbb744fdc2413d73dfbb1c1932a084263f Mon Sep 17 00:00:00 2001 From: Jannis Froese Date: Mon, 9 Jun 2014 01:25:11 +0200 Subject: [PATCH 4/4] adapt rpc tests to mandatory fees --- qa/rpc-tests/conflictedbalance.sh | 6 +++--- qa/rpc-tests/txnmall.sh | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/qa/rpc-tests/conflictedbalance.sh b/qa/rpc-tests/conflictedbalance.sh index 7873c0c65..ae6d7cbb2 100755 --- a/qa/rpc-tests/conflictedbalance.sh +++ b/qa/rpc-tests/conflictedbalance.sh @@ -107,7 +107,7 @@ B2ADDRESS=$( $CLI $B2ARGS getnewaddress ) TXID_C=$( $CLI $B1ARGS sendtoaddress $B1ADDRESS 500000.0) # Transaction D: spends B and C -TXID_D=$( $CLI $B1ARGS sendtoaddress $B2ADDRESS 1000000.0) +TXID_D=$( $CLI $B1ARGS sendtoaddress $B2ADDRESS 999998.0) CheckBalance "$B1ARGS" 0 @@ -133,9 +133,9 @@ WaitPeers "$B1ARGS" 1 $CLI $B2ARGS setgenerate true 1 WaitBlocks -# B1 should still be able to spend 1000000, because D is conflicted +# B1 should still be able to spend 1000000 (-1 DOGE fee for the successful transaction), because D is conflicted # so does not count as a spend of B -CheckBalance "$B1ARGS" 1000000 +CheckBalance "$B1ARGS" "1000000-1" $CLI $B2ARGS stop > /dev/null 2>&1 wait $B2PID diff --git a/qa/rpc-tests/txnmall.sh b/qa/rpc-tests/txnmall.sh index b5732127a..65cd35781 100755 --- a/qa/rpc-tests/txnmall.sh +++ b/qa/rpc-tests/txnmall.sh @@ -97,7 +97,7 @@ B2ADDRESS=$( $CLI $B2ARGS getaccountaddress "from1" ) $CLI $B1ARGS move "" "foo" 10.0 > /dev/null $CLI $B1ARGS move "" "bar" 10.0 > /dev/null TXID1=$( $CLI $B1ARGS sendfrom foo $B2ADDRESS 1.0 0) -TXID2=$( $CLI $B1ARGS sendfrom bar $B2ADDRESS 2.0 0) +TXID2=$( $CLI $B1ARGS sendfrom bar $B2ADDRESS 5.0 0) # Mutate TXID1 and add it to B2's memory pool: RAWTX1=$( $CLI $B1ARGS getrawtransaction $TXID1 ) @@ -130,12 +130,12 @@ $CLI $B2ARGS addnode 127.0.0.1:11000 onetry $CLI $B2ARGS setgenerate true 1 WaitBlocks -# B1 should have 499999 DOGE; the 2 DOGE send is +# B1 should have 499998 DOGE; the 5 DOGE send is # conflicted, and should not count in # balances. -CheckBalance "$B1ARGS" 499999 -CheckBalance "$B1ARGS" 499999 "*" -CheckBalance "$B1ARGS" 9 "foo" +CheckBalance "$B1ARGS" 499998 +CheckBalance "$B1ARGS" 499998 "*" +CheckBalance "$B1ARGS" 8 "foo" CheckBalance "$B1ARGS" 10 "bar" # B2 should have 500001 DOGE