@@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
157
157
// Setup
158
158
std::vector<CInputCoin> utxo_pool;
159
159
CoinSet selection;
160
- CoinSet actual_selection ;
160
+ SelectionResult expected_result ( CAmount ( 0 )) ;
161
161
CAmount value_ret = 0 ;
162
162
163
163
// ///////////////////////
@@ -175,72 +175,72 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
175
175
add_coin (4 * CENT, 4 , utxo_pool);
176
176
177
177
// Select 1 Cent
178
- add_coin (1 * CENT, 1 , actual_selection );
178
+ add_coin (1 * CENT, 1 , expected_result. m_selected_inputs );
179
179
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 ));
181
181
BOOST_CHECK_EQUAL (value_ret, 1 * CENT);
182
- actual_selection. clear ();
182
+ expected_result. Clear ();
183
183
selection.clear ();
184
184
185
185
// Select 2 Cent
186
- add_coin (2 * CENT, 2 , actual_selection );
186
+ add_coin (2 * CENT, 2 , expected_result. m_selected_inputs );
187
187
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 ));
189
189
BOOST_CHECK_EQUAL (value_ret, 2 * CENT);
190
- actual_selection. clear ();
190
+ expected_result. Clear ();
191
191
selection.clear ();
192
192
193
193
// 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 );
196
196
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 ));
198
198
BOOST_CHECK_EQUAL (value_ret, 5 * CENT);
199
- actual_selection. clear ();
199
+ expected_result. Clear ();
200
200
selection.clear ();
201
201
202
202
// Select 11 Cent, not possible
203
203
BOOST_CHECK (!SelectCoinsBnB (GroupCoins (utxo_pool), 11 * CENT, 0.5 * CENT, selection, value_ret));
204
- actual_selection. clear ();
204
+ expected_result. Clear ();
205
205
selection.clear ();
206
206
207
207
// 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 );
209
209
BOOST_CHECK (SelectCoinsBnB (GroupCoins (utxo_pool), 0.9 * CENT, 0.5 * CENT, selection, value_ret));
210
210
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 ();
213
213
selection.clear ();
214
214
215
215
// Cost of change is less than the difference between target value and utxo sum
216
216
BOOST_CHECK (!SelectCoinsBnB (GroupCoins (utxo_pool), 0.9 * CENT, 0 , selection, value_ret));
217
- actual_selection. clear ();
217
+ expected_result. Clear ();
218
218
selection.clear ();
219
219
220
220
// Select 10 Cent
221
221
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 );
225
225
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 ));
227
227
BOOST_CHECK_EQUAL (value_ret, 10 * CENT);
228
- actual_selection. clear ();
228
+ expected_result. Clear ();
229
229
selection.clear ();
230
230
231
231
// Negative effective value
232
232
// 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 );
236
236
BOOST_CHECK (SelectCoinsBnB (GroupCoins (utxo_pool), 10 * CENT, 5000 , selection, value_ret));
237
237
BOOST_CHECK_EQUAL (value_ret, 10 * CENT);
238
238
// 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 ));
240
240
241
241
// Select 0.25 Cent, not possible
242
242
BOOST_CHECK (!SelectCoinsBnB (GroupCoins (utxo_pool), 0.25 * CENT, 0.5 * CENT, selection, value_ret));
243
- actual_selection. clear ();
243
+ expected_result. Clear ();
244
244
selection.clear ();
245
245
246
246
// Iteration exhaustion test
@@ -251,11 +251,11 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
251
251
252
252
// Test same value early bailout optimization
253
253
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 );
259
259
add_coin (7 * CENT, 7 , utxo_pool);
260
260
add_coin (7 * CENT, 7 , utxo_pool);
261
261
add_coin (7 * CENT, 7 , utxo_pool);
@@ -266,7 +266,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
266
266
}
267
267
BOOST_CHECK (SelectCoinsBnB (GroupCoins (utxo_pool), 30 * CENT, 5000 , selection, value_ret));
268
268
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 ));
270
270
271
271
// //////////////////
272
272
// Behavior tests //
0 commit comments