aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/test
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2020-03-04 16:35:15 -0500
committerAndrew Chow <achow101-github@achow101.com>2020-03-04 16:35:15 -0500
commit9b5950db8683f9b4be03f79ee0aae8a780b01a4b (patch)
treec7deccff2bbd4c744bc288bddd5e097ddd4a2a8b /src/wallet/test
parenta71c34742c24245a0d642e68f9e61f46cc7573fb (diff)
downloadbitcoin-9b5950db8683f9b4be03f79ee0aae8a780b01a4b.tar.xz
bnb: exit selection when best_waste is 0
If we find a solution which has no waste, just use that. This solution is what we would consider to be optimal, and other solutions we find would have to also have 0 waste, so they are equivalent to the first one with 0 waste. Thus we can optimize by just choosing the first one with 0 waste.
Diffstat (limited to 'src/wallet/test')
-rw-r--r--src/wallet/test/coinselector_tests.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp
index 21d57cb898..2081518909 100644
--- a/src/wallet/test/coinselector_tests.cpp
+++ b/src/wallet/test/coinselector_tests.cpp
@@ -176,8 +176,8 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
selection.clear();
// Select 5 Cent
- add_coin(3 * CENT, 3, actual_selection);
- add_coin(2 * CENT, 2, actual_selection);
+ add_coin(4 * CENT, 4, actual_selection);
+ add_coin(1 * CENT, 1, actual_selection);
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 5 * CENT, 0.5 * CENT, selection, value_ret, not_input_fees));
BOOST_CHECK(equal_sets(selection, actual_selection));
BOOST_CHECK_EQUAL(value_ret, 5 * CENT);
@@ -204,9 +204,8 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
// Select 10 Cent
add_coin(5 * CENT, 5, utxo_pool);
+ add_coin(5 * CENT, 5, actual_selection);
add_coin(4 * CENT, 4, actual_selection);
- add_coin(3 * CENT, 3, actual_selection);
- add_coin(2 * CENT, 2, actual_selection);
add_coin(1 * CENT, 1, actual_selection);
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 10 * CENT, 0.5 * CENT, selection, value_ret, not_input_fees));
BOOST_CHECK(equal_sets(selection, actual_selection));