aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/test/wallet_tests.cpp
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2018-01-07 22:56:53 +0000
committerRoss Nicoll <[email protected]>2018-09-19 21:09:16 +0100
commit18850d359bbc4d3333d9f1ac33607242d205c2ce (patch)
tree45cb5ac9949143efb71ddd7f3f7f4cf8c152df2d /src/wallet/test/wallet_tests.cpp
parentVerify when doing 'backupwallet' that destination is not the same path of the... (diff)
downloaddiscoin-18850d359bbc4d3333d9f1ac33607242d205c2ce.tar.xz
discoin-18850d359bbc4d3333d9f1ac33607242d205c2ce.zip
Add Dogecoin current fee calculation logic (#1413)
Introduces 1 COIN/kb fees, rounded up to the next 1 COIN.
Diffstat (limited to 'src/wallet/test/wallet_tests.cpp')
-rw-r--r--src/wallet/test/wallet_tests.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
index 2fbcc3414..c6e10f34f 100644
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -2,6 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include "txmempool.h"
#include "wallet/wallet.h"
#include <set>
@@ -434,7 +435,7 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain240Setup)
// greater or equal than key birthday. Previously there was a bug where
// importwallet RPC would start the scan at the latest block with timestamp less
// than or equal to key birthday.
-BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
+BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain240Setup)
{
CWallet *pwalletMainBackup = ::pwalletMain;
LOCK(cs_main);
@@ -490,4 +491,39 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
::pwalletMain = pwalletMainBackup;
}
+BOOST_AUTO_TEST_CASE(GetMinimumFee_test)
+{
+ uint64_t value = 1000 * COIN; // 1,000 DOGE
+
+ CMutableTransaction tx;
+ CTxMemPool pool(payTxFee);
+ CTxOut txout1(value, (CScript)vector<unsigned char>(24, 0));
+ tx.vout.push_back(txout1);
+
+ int64_t nMinTxFee = COIN;
+
+ BOOST_CHECK_EQUAL(CWallet::GetMinimumFee(tx, 250, 0, pool), nMinTxFee);
+ BOOST_CHECK_EQUAL(CWallet::GetMinimumFee(tx, 1000, 0, pool), 2 * nMinTxFee);
+ BOOST_CHECK_EQUAL(CWallet::GetMinimumFee(tx, 1999, 0, pool), 2 * nMinTxFee);
+}
+
+BOOST_AUTO_TEST_CASE(GetMinimumFee_dust_test)
+{
+ // Derived from main net TX 3d6ec3ae2aca3ae0a6c65074fd8ee888cd7ed262f2cbaa25d33861989324a14e
+ CMutableTransaction tx;
+ CTxMemPool pool(payTxFee);
+ CTxOut txout1(139496846, (CScript)vector<unsigned char>(24, 0)); // Regular output
+ CTxOut txout2(15499649, (CScript)vector<unsigned char>(24, 0)); // Dust output
+ tx.vout.push_back(txout1);
+ tx.vout.push_back(txout2);
+
+ int64_t nMinTxFee = COIN;
+
+ // Confirm dust penalty fees are added on
+
+ BOOST_CHECK_EQUAL(CWallet::GetMinimumFee(tx, 963, 0, pool), 2 * nMinTxFee);
+ BOOST_CHECK_EQUAL(CWallet::GetMinimumFee(tx, 1000, 0, pool), 3 * nMinTxFee);
+ BOOST_CHECK_EQUAL(CWallet::GetMinimumFee(tx, 1999, 0, pool), 3 * nMinTxFee);
+}
+
BOOST_AUTO_TEST_SUITE_END()