diff options
author | Andrew Chow <achow101-github@achow101.com> | 2018-03-12 19:43:32 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2018-03-13 12:39:35 -0400 |
commit | 73b5bf2cb40720bb4e4436ea63b5badf3d89ceb9 (patch) | |
tree | 02aee7c0c32709e73e512847eba36de40c6c8b48 /src/wallet | |
parent | 76d2f068a4cbd2bfe50c166fe0babfc5f17acaf4 (diff) |
Add a test to make sure that negative effective values are filtered
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/test/coinselector_tests.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp index d295398301..f05c81cd4c 100644 --- a/src/wallet/test/coinselector_tests.cpp +++ b/src/wallet/test/coinselector_tests.cpp @@ -30,6 +30,11 @@ static std::vector<COutput> vCoins; static const CWallet testWallet("dummy", CWalletDBWrapper::CreateDummy()); static CAmount balance = 0; +CoinEligibilityFilter filter_standard(1, 6, 0); +CoinEligibilityFilter filter_confirmed(1, 1, 0); +CoinEligibilityFilter filter_standard_extra(6, 6, 0); +CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(0), 0); + static void add_coin(const CAmount& nValue, int nInput, std::vector<CInputCoin>& set) { CMutableTransaction tx; @@ -207,12 +212,17 @@ BOOST_AUTO_TEST_CASE(bnb_search_test) for (int i = 0; i < 100; ++i) { BOOST_CHECK(!SelectCoinsBnB(utxo_pool, 1 * CENT, 2 * CENT, selection, value_ret, not_input_fees)); } -} -CoinEligibilityFilter filter_standard(1, 6, 0); -CoinEligibilityFilter filter_confirmed(1, 1, 0); -CoinEligibilityFilter filter_standard_extra(6, 6, 0); -CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(0), 0); + // Make sure that effective value is working in SelectCoinsMinConf when BnB is used + CoinSelectionParams coin_selection_params_bnb(true, 0, 0, CFeeRate(3000), 0); + CoinSet setCoinsRet; + CAmount nValueRet; + bool bnb_used; + empty_wallet(); + add_coin(1); + vCoins.at(0).nInputBytes = 40; // Make sure that it has a negative effective value. The next check should assert if this somehow got through. Otherwise it will fail + BOOST_CHECK(!testWallet.SelectCoinsMinConf( 1 * CENT, filter_standard, vCoins, setCoinsRet, nValueRet, coin_selection_params_bnb, bnb_used)); +} BOOST_AUTO_TEST_CASE(knapsack_solver_test) { |