@@ -1111,7 +1111,7 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
11111111 // 4) Test that two less valuable UTXOs with a combined lower weight are preferred over a more valuable heavier UTXO
11121112 // 5) Test finding a solution in a UTXO pool with mixed weights
11131113 // 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
11151115
11161116 FastRandomContext rand;
11171117 CoinSelectionParams dummy_params{ // Only used to provide the 'avoid_partial' flag.
@@ -1180,7 +1180,7 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
11801180 });
11811181 BOOST_CHECK (res);
11821182 // 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 ;
11841184 BOOST_CHECK_MESSAGE (res->GetSelectionsEvaluated () == expected_attempts, strprintf (" Expected %i attempts, but got %i" , expected_attempts, res->GetSelectionsEvaluated ()));
11851185 }
11861186
@@ -1231,7 +1231,7 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
12311231 add_coin (4 * COIN, 3 , expected_result);
12321232 BOOST_CHECK (EquivalentResult (expected_result, *res));
12331233 // 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 ;
12351235 BOOST_CHECK_MESSAGE (res->GetSelectionsEvaluated () == expected_attempts, strprintf (" Expected %i attempts, but got %i" , expected_attempts, res->GetSelectionsEvaluated ()));
12361236 }
12371237
@@ -1270,14 +1270,13 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
12701270 add_coin (1 * COIN, 0 , expected_result);
12711271 BOOST_CHECK (EquivalentResult (expected_result, *res));
12721272 // 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 ;
12751274 BOOST_CHECK_MESSAGE (res->GetSelectionsEvaluated () == expected_attempts, strprintf (" Expected %i attempts, but got %i" , expected_attempts, res->GetSelectionsEvaluated ()));
12761275 }
12771276
12781277 {
12791278 // #################################################################################################################
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
12811280 // #################################################################################################################
12821281 CAmount target = 1 .9L * COIN;
12831282 int max_weight = 40000 ; // WU
@@ -1293,11 +1292,11 @@ BOOST_AUTO_TEST_CASE(coin_grinder_tests)
12931292 return available_coins;
12941293 });
12951294 SelectionResult expected_result (CAmount (0 ), SelectionAlgorithm::CG);
1296- add_coin (1.8 * COIN, 1 , expected_result);
1295+ add_coin (1 * COIN, 1 , expected_result);
12971296 add_coin (1 * COIN, 2 , expected_result);
12981297 BOOST_CHECK (EquivalentResult (expected_result, *res));
12991298 // 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 ;
13011300 BOOST_CHECK_MESSAGE (res->GetSelectionsEvaluated () == expected_attempts, strprintf (" Expected %i attempts, but got %i" , expected_attempts, res->GetSelectionsEvaluated ()));
13021301 }
13031302}
0 commit comments