test: add case where TOTAL_TRIES is exceeded yet solution remains #33701

pull yancyribbens wants to merge 1 commits into bitcoin:master from yancyribbens:coin-grinder-iter-limit changing 1 files +33 −0
  1. yancyribbens commented at 0:30 am on October 25, 2025: contributor

    Show that CoinGrider halts searching when the number of attempts exceeds TOTAL_TRIES. To do so, show that a solution is found, then add one more entry to the same set of inputs. Since the search orders by effective_value, the solution is constructed such that only values with the lowest effective_value have the least weight. Only the lowest weight values will not exceed the max_selection_weight. Therefore, CoinGrinder will not evaluate all lowest weight solutions together before exceeding TOTAL_TRIES since they are last found.

    This test case was inspired by a similar test for BnB currently named bnb_test.

  2. test: add case where `TOTAL_TRIES` is exceeded yet solution remains
    Show that `CoinGrider` halts searching when the number of attempts exceeds
    `TOTAL_TRIES`.  To do so, show that a solution is found, then add one
    more entry to the same set of inputs.  Since the search orders by
    `effective_value`, the solution is constructed such that only values
    with the lowest `effective_value` have the least weight.  Only the
    lowest weight values will not exceed the `max_selection_weight`.
    Therefore, `CoinGrinder` will not evaluate all lowest weight solutions
    together before exceeding `TOTAL_TRIES` since they are last found.
    
    This test case was inspired by a similar test for `BnB` currently
    named `bnb_test`.
    922345de3f
  3. DrahtBot added the label Tests on Oct 25, 2025
  4. DrahtBot commented at 0:30 am on October 25, 2025: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33701.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK alvroble

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    LLM Linter (✨ experimental)

    Possible typos and grammar issues:

    • “8) Test input set that has a solution will not find a solution before reaching the attempt limit” -> “8) Test input set that has a solution will find a solution before reaching the attempt limit” [The original phrase contradicts the test intent and following comments; “will not find” makes the sentence misleading and harms comprehension.]

    drahtbot_id_5_m

  5. yancyribbens commented at 0:30 am on October 25, 2025: contributor
  6. in src/wallet/test/coinselector_tests.cpp:1161 in 922345de3f
    1156+        // #################################################################################################################
    1157+        CAmount target =  8 * COIN;
    1158+        int max_selection_weight = 3200; // WU
    1159+        dummy_params.m_min_change_target = 0;
    1160+        const auto& result_a = CoinGrinder(target, dummy_params, m_node, max_selection_weight, [&](CWallet& wallet) {
    1161+            CoinsResult doppelgangers;
    


    alvroble commented at 11:37 am on October 25, 2025:
    Maybe it’d be better to use res_a/res_b instead of result_a/result_b and available_coins instead of doppelgangers for naming consistency.

    yancyribbens commented at 1:26 pm on October 25, 2025:

    Thanks for taking a look. The name doppelgangers comes from a similar test for BnB: https://github.com/bitcoin/bitcoin/blob/e744fd1249bf9577274614eaf3997bf4bbb612ff/src/wallet/test/coinselection_tests.cpp#L166.

    I’m impartial on res_a vs result_a. I couldn’t name it just res because there would be multiple assignments to res which the compiler complains about.

  7. alvroble commented at 11:42 am on October 25, 2025: none
    Hey, I’m new to this project. So just learning. Ran the tests and they were not broken, and I agree with the rationale. Concept ACK.

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: 2025-11-02 18:12 UTC

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