coin-grinder missing test for TOTAL_TRIES #33419

issue yancyribbens openend this issue on September 17, 2025
  1. yancyribbens commented at 4:24 pm on September 17, 2025: contributor

    The following (mutation) code can be remove from coin-grinder here without encountering a test failure

    0if (curr_try >= TOTAL_TRIES) {
    1    // Solution is not guaranteed to be optimal if `curr_try` hit TOTAL_TRIES
    2    result.SetAlgoCompleted(false);
    3    break;
    4}
    

    This ought to be a similar test to Test BnB attempt limit (TOTAL_TRIES)

  2. yancyribbens commented at 4:26 pm on September 17, 2025: contributor
  3. fanquake added the label Tests on Sep 18, 2025
  4. murchandamus commented at 7:55 pm on October 16, 2025: contributor
    Yeah, it would be good to add this test. If someone wants to work on this, I would like to suggest that they peruse the very similar test for BnB here: https://github.com/bitcoin/bitcoin/blob/e744fd1249bf9577274614eaf3997bf4bbb612ff/src/wallet/test/coinselection_tests.cpp#L166 And to understand what CoinGrinder is actually doing and how it work, I would suggest that prospective implementers peruse the PR that added CoinGrinder starting with this commit: https://github.com/bitcoin/bitcoin/pull/27877/commits/6cc9a46cd0f4ed80d4523bbef1508142e0c80d27
  5. yancyribbens commented at 1:20 am on October 24, 2025: contributor

    Something like this would work:

     0    {
     1        // #################################################################################################################
     2        // 8) Max iterations
     3        // #################################################################################################################
     4        CAmount target =  8 * COIN;
     5        int max_selection_weight = 3200; // WU
     6        const auto& res = CoinGrinder(target, dummy_params, m_node, max_selection_weight, [&](CWallet& wallet) {
     7            CoinsResult doppelgangers;
     8            for (int i = 0; i < 19; ++i) {
     9                add_coin(doppelgangers, wallet, CAmount(1 * COIN + i), CFeeRate(0), 144, false, 0, true, 96 + i);
    10            } 
    11            return doppelgangers;
    12        });
    13        BOOST_CHECK(!res);
    14    }
    

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-06 06:13 UTC

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