Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/coinselector_tests.cpp
Show First 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(bnb_search_test) { | ||||
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 2 * CENT, CENT / 2, | BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 2 * CENT, CENT / 2, | ||||
selection, value_ret, not_input_fees)); | selection, value_ret, not_input_fees)); | ||||
BOOST_CHECK(equal_sets(selection, actual_selection)); | BOOST_CHECK(equal_sets(selection, actual_selection)); | ||||
BOOST_CHECK_EQUAL(value_ret, 2 * CENT); | BOOST_CHECK_EQUAL(value_ret, 2 * CENT); | ||||
actual_selection.clear(); | actual_selection.clear(); | ||||
selection.clear(); | selection.clear(); | ||||
// Select 5 Cent | // Select 5 Cent | ||||
add_coin(3 * CENT, 3, actual_selection); | add_coin(4 * CENT, 4, actual_selection); | ||||
add_coin(2 * CENT, 2, actual_selection); | add_coin(1 * CENT, 1, actual_selection); | ||||
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 5 * CENT, CENT / 2, | BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 5 * CENT, CENT / 2, | ||||
selection, value_ret, not_input_fees)); | selection, value_ret, not_input_fees)); | ||||
BOOST_CHECK(equal_sets(selection, actual_selection)); | BOOST_CHECK(equal_sets(selection, actual_selection)); | ||||
BOOST_CHECK_EQUAL(value_ret, 5 * CENT); | BOOST_CHECK_EQUAL(value_ret, 5 * CENT); | ||||
actual_selection.clear(); | actual_selection.clear(); | ||||
selection.clear(); | selection.clear(); | ||||
// Select 11 Cent, not possible | // Select 11 Cent, not possible | ||||
BOOST_CHECK(!SelectCoinsBnB(GroupCoins(utxo_pool), 11 * CENT, CENT / 2, | BOOST_CHECK(!SelectCoinsBnB(GroupCoins(utxo_pool), 11 * CENT, CENT / 2, | ||||
selection, value_ret, not_input_fees)); | selection, value_ret, not_input_fees)); | ||||
actual_selection.clear(); | actual_selection.clear(); | ||||
selection.clear(); | selection.clear(); | ||||
// Select 10 Cent | // Select 10 Cent | ||||
add_coin(5 * CENT, 5, utxo_pool); | add_coin(5 * CENT, 5, utxo_pool); | ||||
add_coin(5 * CENT, 5, actual_selection); | |||||
add_coin(4 * CENT, 4, 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); | add_coin(1 * CENT, 1, actual_selection); | ||||
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 10 * CENT, CENT / 2, | BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 10 * CENT, CENT / 2, | ||||
selection, value_ret, not_input_fees)); | selection, value_ret, not_input_fees)); | ||||
BOOST_CHECK(equal_sets(selection, actual_selection)); | BOOST_CHECK(equal_sets(selection, actual_selection)); | ||||
BOOST_CHECK_EQUAL(value_ret, 10 * CENT); | BOOST_CHECK_EQUAL(value_ret, 10 * CENT); | ||||
actual_selection.clear(); | actual_selection.clear(); | ||||
selection.clear(); | selection.clear(); | ||||
▲ Show 20 Lines • Show All 594 Lines • Show Last 20 Lines |