test: cover SelectionResult::Merge, GetTotalBumpFees and EligibleForSpending #36614

pull Naomi-Gift wants to merge 3 commits into bitcoin:master from Naomi-Gift:test-selectionresult-merge-algo changing 2 files +49 −0
  1. Naomi-Gift commented at 6:14 PM on October 22, 2026: none

    Adds tests that kill two surviving mutants in src/wallet/coinselection.cpp.

    SelectionResult::Merge()

    -    if (m_algo == SelectionAlgorithm::MANUAL) {
    +    if (m_algo != SelectionAlgorithm::MANUAL) {
    

    With this mutant, merged results report the wrong algorithm. The test fails with manual != bnb.

    SelectionResult::GetTotalBumpFees()

    -    return std::accumulate(...) - bump_fee_group_discount;
    +    return std::accumulate(...) + bump_fee_group_discount;
    

    With this mutant, the wallet overpays fees. The test fails with 90 != 30. OutputGroup::EligibleForSpending()

    - return m_depth >= (m_from_me ? eligibility_filter.conf_mine : eligibility_filter.conf_theirs)
    + return m_depth > (m_from_me ? eligibility_filter.conf_mine : eligibility_filter.conf_theirs)
    

    With this mutant, a coin with exactly the required number of confirmations is incorrectly rejected. The test checks that a coin with exactly the required confirmations is eligible, while one with fewer confirmations is not. The test passes on the branch and fails with the mutant applied.

  2. DrahtBot added the label Tests on Oct 22, 2026
  3. DrahtBot commented at 6:14 PM on October 22, 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 Conradgabe, Zippo76
    Stale ACK mercie-ux

    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-->

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • src/wallet/test/coinselection_tests.cpp: std::make_shared<COutput>(..., true, true, 0, from_me, 0)
    • src/wallet/test/coinselection_tests.cpp: group.Insert(..., 0, 0)

    <sup>2026-11-11 13:31:23</sup>

  4. fanquake commented at 7:30 PM on October 22, 2026: member
  5. mercie-ux commented at 6:14 AM on October 23, 2026: contributor

    ACK 4959d34130

    This covers the surviving mutant https://bitcoincore.space/src/wallet/coinselection.cpp#3707.

  6. Naomi-Gift renamed this:
    test: check algorithm after SelectionResult::Merge
    test: cover SelectionResult::Merge and GetTotalBumpFees in coin selection
    on Nov 3, 2026
  7. Naomi-Gift renamed this:
    test: cover SelectionResult::Merge and GetTotalBumpFees in coin selection
    test: cover SelectionResult::Merge and GetTotalBumpFees
    on Nov 3, 2026
  8. Naomi-Gift force-pushed on Nov 3, 2026
  9. Zippo76 commented at 8:01 PM on November 3, 2026: none

    tACK 8d074ed174

    Tested on macOS 27.0.1 arm64. The coinselector_tests suite passes on the PR. I reproduced both mutations from the description. For each mutation, the PR's suite fails while the suite from master fb19fed3df passes:

    Merge: == changed to !=
      merge_algo_test: [manual != bnb] in both merge directions
    
    GetTotalBumpFees: group discount added instead of subtracted
      bump_fee_test: selection.GetTotalBumpFees() == 30 has failed [90 != 30]
    

    For the second mutation, the initial check against 60 still passes because the discount is zero. The check after applying the 30-sat discount catches the incorrect sign.

  10. DrahtBot added the label CI failed on Nov 5, 2026
  11. test: check algorithm after SelectionResult::Merge
    No test checks which algorithm a SelectionResult reports after
    Merge(). Check that preset (MANUAL) inputs merged into an automatic
    result keep the automatic algorithm, and that a MANUAL result takes
    the algorithm of the result merged into it.
    
    Kills mutant https://bitcoincore.space/src/wallet/coinselection.cpp#3707
    278ea0c9f5
  12. test: check GetTotalBumpFees with a group discount
    GetTotalBumpFees() is used to compute the fee a transaction needs,
    but no test checks its value. Check it in bump_fee_test before and
    after a discount is applied.
    
    Kills mutant https://bitcoincore.space/src/wallet/coinselection.cpp#3700
    56c8c4993d
  13. Naomi-Gift force-pushed on Nov 6, 2026
  14. Zippo76 commented at 5:00 PM on November 7, 2026: none

    re-ACK 56c8c4993d

    The range-diff against the two commits ending at 8d074ed174 shows both patches are unchanged.

  15. DrahtBot removed the label CI failed on Nov 9, 2026
  16. test: check EligibleForSpending accepts the exact confirmation count 8889c29ea2
  17. Naomi-Gift renamed this:
    test: cover SelectionResult::Merge and GetTotalBumpFees
    test: cover SelectionResult::Merge, GetTotalBumpFees and EligibleForSpending
    on Nov 11, 2026
  18. Naomi-Gift commented at 1:40 PM on November 11, 2026: none

    I've added a third commit covering another surviving coin selection mutant.

  19. Conradgabe commented at 2:30 PM on November 11, 2026: contributor

    tACK 8889c29ea216ea5981b052e68ba299db0f6ce5b6

    Ran test for all 3 surviving mutants (merge_algo_test, GetTotalBumpFees, eligible_for_spending_test) from the PR, all mutants were killed.

  20. DrahtBot requested review from Zippo76 on Nov 11, 2026
  21. Zippo76 commented at 8:44 PM on November 12, 2026: none

    tACK 8889c29ea2

    Retested on macOS 27.2.1 arm64 against master 9183edd25e. The first two commits are unchanged from my November 7 re-ACK; the third is new. Both coinselector_tests and coinselection_tests pass.

    Confirmed that each of the three mutations described in the PR is caught by the PR's tests and survives with master's tests.

  22. DrahtBot added the label CI failed on Nov 14, 2026

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