test: fuzz: check CoinGrinder completed flag #36905

pull Conradgabe wants to merge 1 commits into bitcoin:master from Conradgabe:test-coingrinder-algo-completed changing 2 files +8 −0
  1. Conradgabe commented at 9:36 PM on November 17, 2026: contributor

    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;
             }
    
    
  2. test: check CoinGrinder completed flag
    CoinGrinder marks its result as completed when it exhausts the
    search space before reaching TOTAL_TRIES. No unit test reads
    this flag, and the coin_grinder and coin_grinder_is_optimal fuzz
    targets only use it to decide whether to check optimality, so a
    wrong value here goes unnoticed.
    
    Check GetAlgoCompleted() in coin_grinder_tests for cases that
    finish below the attempt limit, and assert in both fuzz targets
    that the flag is true exactly when fewer than TOTAL_TRIES
    selections were evaluated.
    e5ee8a9658
  3. DrahtBot added the label Tests on Nov 17, 2026
  4. DrahtBot commented at 9:36 PM on November 17, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK yancyribbens

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. yancyribbens commented at 10:30 AM on November 18, 2026: contributor

    ACK e5ee8a9658888907306feb0af4bfa141ce7eed42


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-18 16:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me