Skip to content

Commit cbf0b9f

Browse files
committed
scripted-diff: Use SelectionResult in coin selector tests
Replace the CoinSet actual_selection with a SelectionResult expected_result. We don't use the SelectionResult functions yet, but will soon. -BEGIN VERIFY SCRIPT- sed -i 's/CoinSet actual_selection/SelectionResult expected_result(CAmount(0))/' src/wallet/test/coinselector_tests.cpp sed -i 's/actual_selection/expected_result.m_selected_inputs/' src/wallet/test/coinselector_tests.cpp sed -i 's/expected_result.m_selected_inputs.clear/expected_result.Clear/' src/wallet/test/coinselector_tests.cpp -END VERIFY SCRIPT-
1 parent 9d1d86d commit cbf0b9f

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

src/wallet/test/coinselector_tests.cpp

+32-32
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
157157
// Setup
158158
std::vector<CInputCoin> utxo_pool;
159159
CoinSet selection;
160-
CoinSet actual_selection;
160+
SelectionResult expected_result(CAmount(0));
161161
CAmount value_ret = 0;
162162

163163
/////////////////////////
@@ -175,72 +175,72 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
175175
add_coin(4 * CENT, 4, utxo_pool);
176176

177177
// Select 1 Cent
178-
add_coin(1 * CENT, 1, actual_selection);
178+
add_coin(1 * CENT, 1, expected_result.m_selected_inputs);
179179
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 1 * CENT, 0.5 * CENT, selection, value_ret));
180-
BOOST_CHECK(equivalent_sets(selection, actual_selection));
180+
BOOST_CHECK(equivalent_sets(selection, expected_result.m_selected_inputs));
181181
BOOST_CHECK_EQUAL(value_ret, 1 * CENT);
182-
actual_selection.clear();
182+
expected_result.Clear();
183183
selection.clear();
184184

185185
// Select 2 Cent
186-
add_coin(2 * CENT, 2, actual_selection);
186+
add_coin(2 * CENT, 2, expected_result.m_selected_inputs);
187187
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 2 * CENT, 0.5 * CENT, selection, value_ret));
188-
BOOST_CHECK(equivalent_sets(selection, actual_selection));
188+
BOOST_CHECK(equivalent_sets(selection, expected_result.m_selected_inputs));
189189
BOOST_CHECK_EQUAL(value_ret, 2 * CENT);
190-
actual_selection.clear();
190+
expected_result.Clear();
191191
selection.clear();
192192

193193
// Select 5 Cent
194-
add_coin(4 * CENT, 4, actual_selection);
195-
add_coin(1 * CENT, 1, actual_selection);
194+
add_coin(4 * CENT, 4, expected_result.m_selected_inputs);
195+
add_coin(1 * CENT, 1, expected_result.m_selected_inputs);
196196
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 5 * CENT, 0.5 * CENT, selection, value_ret));
197-
BOOST_CHECK(equivalent_sets(selection, actual_selection));
197+
BOOST_CHECK(equivalent_sets(selection, expected_result.m_selected_inputs));
198198
BOOST_CHECK_EQUAL(value_ret, 5 * CENT);
199-
actual_selection.clear();
199+
expected_result.Clear();
200200
selection.clear();
201201

202202
// Select 11 Cent, not possible
203203
BOOST_CHECK(!SelectCoinsBnB(GroupCoins(utxo_pool), 11 * CENT, 0.5 * CENT, selection, value_ret));
204-
actual_selection.clear();
204+
expected_result.Clear();
205205
selection.clear();
206206

207207
// Cost of change is greater than the difference between target value and utxo sum
208-
add_coin(1 * CENT, 1, actual_selection);
208+
add_coin(1 * CENT, 1, expected_result.m_selected_inputs);
209209
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 0.9 * CENT, 0.5 * CENT, selection, value_ret));
210210
BOOST_CHECK_EQUAL(value_ret, 1 * CENT);
211-
BOOST_CHECK(equivalent_sets(selection, actual_selection));
212-
actual_selection.clear();
211+
BOOST_CHECK(equivalent_sets(selection, expected_result.m_selected_inputs));
212+
expected_result.Clear();
213213
selection.clear();
214214

215215
// Cost of change is less than the difference between target value and utxo sum
216216
BOOST_CHECK(!SelectCoinsBnB(GroupCoins(utxo_pool), 0.9 * CENT, 0, selection, value_ret));
217-
actual_selection.clear();
217+
expected_result.Clear();
218218
selection.clear();
219219

220220
// Select 10 Cent
221221
add_coin(5 * CENT, 5, utxo_pool);
222-
add_coin(5 * CENT, 5, actual_selection);
223-
add_coin(4 * CENT, 4, actual_selection);
224-
add_coin(1 * CENT, 1, actual_selection);
222+
add_coin(5 * CENT, 5, expected_result.m_selected_inputs);
223+
add_coin(4 * CENT, 4, expected_result.m_selected_inputs);
224+
add_coin(1 * CENT, 1, expected_result.m_selected_inputs);
225225
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 10 * CENT, 0.5 * CENT, selection, value_ret));
226-
BOOST_CHECK(equivalent_sets(selection, actual_selection));
226+
BOOST_CHECK(equivalent_sets(selection, expected_result.m_selected_inputs));
227227
BOOST_CHECK_EQUAL(value_ret, 10 * CENT);
228-
actual_selection.clear();
228+
expected_result.Clear();
229229
selection.clear();
230230

231231
// Negative effective value
232232
// Select 10 Cent but have 1 Cent not be possible because too small
233-
add_coin(5 * CENT, 5, actual_selection);
234-
add_coin(3 * CENT, 3, actual_selection);
235-
add_coin(2 * CENT, 2, actual_selection);
233+
add_coin(5 * CENT, 5, expected_result.m_selected_inputs);
234+
add_coin(3 * CENT, 3, expected_result.m_selected_inputs);
235+
add_coin(2 * CENT, 2, expected_result.m_selected_inputs);
236236
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 10 * CENT, 5000, selection, value_ret));
237237
BOOST_CHECK_EQUAL(value_ret, 10 * CENT);
238238
// FIXME: this test is redundant with the above, because 1 Cent is selected, not "too small"
239-
// BOOST_CHECK(equivalent_sets(selection, actual_selection));
239+
// BOOST_CHECK(equivalent_sets(selection, expected_result.m_selected_inputs));
240240

241241
// Select 0.25 Cent, not possible
242242
BOOST_CHECK(!SelectCoinsBnB(GroupCoins(utxo_pool), 0.25 * CENT, 0.5 * CENT, selection, value_ret));
243-
actual_selection.clear();
243+
expected_result.Clear();
244244
selection.clear();
245245

246246
// Iteration exhaustion test
@@ -251,11 +251,11 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
251251

252252
// Test same value early bailout optimization
253253
utxo_pool.clear();
254-
add_coin(7 * CENT, 7, actual_selection);
255-
add_coin(7 * CENT, 7, actual_selection);
256-
add_coin(7 * CENT, 7, actual_selection);
257-
add_coin(7 * CENT, 7, actual_selection);
258-
add_coin(2 * CENT, 7, actual_selection);
254+
add_coin(7 * CENT, 7, expected_result.m_selected_inputs);
255+
add_coin(7 * CENT, 7, expected_result.m_selected_inputs);
256+
add_coin(7 * CENT, 7, expected_result.m_selected_inputs);
257+
add_coin(7 * CENT, 7, expected_result.m_selected_inputs);
258+
add_coin(2 * CENT, 7, expected_result.m_selected_inputs);
259259
add_coin(7 * CENT, 7, utxo_pool);
260260
add_coin(7 * CENT, 7, utxo_pool);
261261
add_coin(7 * CENT, 7, utxo_pool);
@@ -266,7 +266,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
266266
}
267267
BOOST_CHECK(SelectCoinsBnB(GroupCoins(utxo_pool), 30 * CENT, 5000, selection, value_ret));
268268
BOOST_CHECK_EQUAL(value_ret, 30 * CENT);
269-
BOOST_CHECK(equivalent_sets(selection, actual_selection));
269+
BOOST_CHECK(equivalent_sets(selection, expected_result.m_selected_inputs));
270270

271271
////////////////////
272272
// Behavior tests //

0 commit comments

Comments
 (0)