@@ -1111,7 +1111,7 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
1111
1111
// 4) Test that two less valuable UTXOs with a combined lower weight are preferred over a more valuable heavier UTXO
1112
1112
// 5) Test finding a solution in a UTXO pool with mixed weights
1113
1113
// 6) Test that the lightest solution among many clones is found
1114
- // 7) Lots of tiny UTXOs of different amounts quickly exhausts the search attempts
1114
+ // 7) Test that lots of tiny UTXOs can be skipped if they are too heavy while there are enough funds in lookahead
1115
1115
1116
1116
FastRandomContext rand;
1117
1117
CoinSelectionParams dummy_params{ // Only used to provide the 'avoid_partial' flag.
@@ -1180,7 +1180,7 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
1180
1180
});
1181
1181
BOOST_CHECK (res);
1182
1182
// Demonstrate how following improvements reduce iteration count and catch any regressions in the future.
1183
- size_t expected_attempts = 184 ;
1183
+ size_t expected_attempts = 37 ;
1184
1184
BOOST_CHECK_MESSAGE (res->GetSelectionsEvaluated () == expected_attempts, strprintf (" Expected %i attempts, but got %i" , expected_attempts, res->GetSelectionsEvaluated ()));
1185
1185
}
1186
1186
@@ -1231,7 +1231,7 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
1231
1231
add_coin (4 * COIN, 3 , expected_result);
1232
1232
BOOST_CHECK (EquivalentResult (expected_result, *res));
1233
1233
// Demonstrate how following improvements reduce iteration count and catch any regressions in the future.
1234
- size_t expected_attempts = 218 ;
1234
+ size_t expected_attempts = 92 ;
1235
1235
BOOST_CHECK_MESSAGE (res->GetSelectionsEvaluated () == expected_attempts, strprintf (" Expected %i attempts, but got %i" , expected_attempts, res->GetSelectionsEvaluated ()));
1236
1236
}
1237
1237
@@ -1270,14 +1270,13 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
1270
1270
add_coin (1 * COIN, 0 , expected_result);
1271
1271
BOOST_CHECK (EquivalentResult (expected_result, *res));
1272
1272
// Demonstrate how following improvements reduce iteration count and catch any regressions in the future.
1273
- // If this takes more attempts, the implementation has regressed
1274
- size_t expected_attempts = 42 ;
1273
+ size_t expected_attempts = 38 ;
1275
1274
BOOST_CHECK_MESSAGE (res->GetSelectionsEvaluated () == expected_attempts, strprintf (" Expected %i attempts, but got %i" , expected_attempts, res->GetSelectionsEvaluated ()));
1276
1275
}
1277
1276
1278
1277
{
1279
1278
// #################################################################################################################
1280
- // 7) Lots of tiny UTXOs of different amounts quickly exhausts the search attempts
1279
+ // 7) Test that lots of tiny UTXOs can be skipped if they are too heavy while there are enough funds in lookahead
1281
1280
// #################################################################################################################
1282
1281
CAmount target = 1 .9L * COIN;
1283
1282
int max_weight = 40000 ; // WU
@@ -1293,11 +1292,11 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
1293
1292
return available_coins;
1294
1293
});
1295
1294
SelectionResult expected_result (CAmount (0 ), SelectionAlgorithm::CG);
1296
- add_coin (1.8 * COIN, 1 , expected_result);
1295
+ add_coin (1 * COIN, 1 , expected_result);
1297
1296
add_coin (1 * COIN, 2 , expected_result);
1298
1297
BOOST_CHECK (EquivalentResult (expected_result, *res));
1299
1298
// Demonstrate how following improvements reduce iteration count and catch any regressions in the future.
1300
- size_t expected_attempts = 100'000 ;
1299
+ size_t expected_attempts = 7 ;
1301
1300
BOOST_CHECK_MESSAGE (res->GetSelectionsEvaluated () == expected_attempts, strprintf (" Expected %i attempts, but got %i" , expected_attempts, res->GetSelectionsEvaluated ()));
1302
1301
}
1303
1302
}
0 commit comments