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 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) diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp index 8f22ed723..99ce271e9 100644 --- a/src/test/main_tests.cpp +++ b/src/test/main_tests.cpp @@ -214,7 +214,7 @@ 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) +BOOST_AUTO_TEST_CASE(GetMinFee_createNoFree_test) { uint64_t value = 1000 * COIN; @@ -225,9 +225,12 @@ BOOST_AUTO_TEST_CASE(GetMinFee_createFree_test) 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, 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));