CoinGrinder marks its result as completed when it exhausts the search space before reaching TOTAL_TRIES, and leaves it incomplete when it stops at the limit. No unit test reads this flag, and the coin_grinder and coin_grinder_is_optimal fuzz targets only use it to decide whether to assert optimality, so a wrong value would go unnoticed.
This PR checks GetAlgoCompleted() in coin_grinder_tests for cases that finish below the attempt limit (100,000), and asserts in both fuzz targets that the flag is true below the limit and false once it is reached.
Kills the following mutants:
https://mutanthub.space/mutants/4402
--- a/src/wallet/coinselection.cpp
+++ b/src/wallet/coinselection.cpp
@@ -561,7 +561,7 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c
if (curr_selection.empty()) {
// Exhausted search space before running into attempt limit
is_done = true;
- result.SetAlgoCompleted(true);
+ result.SetAlgoCompleted(false);
break;
}
next_utxo = curr_selection.back() + 1;
https://mutanthub.space/mutants/4401
--- a/src/wallet/coinselection.cpp
+++ b/src/wallet/coinselection.cpp
@@ -539,7 +539,7 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c
if (curr_try >= TOTAL_TRIES) {
// Solution is not guaranteed to be optimal if `curr_try` hit TOTAL_TRIES
- result.SetAlgoCompleted(false);
+ result.SetAlgoCompleted(true);
break;
}