coin-grinder missing test for TOTAL_TRIES #33419

issue yancyribbens opened 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

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

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

    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:

        {
            // #################################################################################################################
            // 8) Max iterations
            // #################################################################################################################
            CAmount target =  8 * COIN;
            int max_selection_weight = 3200; // WU
            const auto& res = CoinGrinder(target, dummy_params, m_node, max_selection_weight, [&](CWallet& wallet) {
                CoinsResult doppelgangers;
                for (int i = 0; i < 19; ++i) {
                    add_coin(doppelgangers, wallet, CAmount(1 * COIN + i), CFeeRate(0), 144, false, 0, true, 96 + i);
                } 
                return doppelgangers;
            });
            BOOST_CHECK(!res);
        }
    
  6. maflcko closed this on Mar 24, 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-04-25 00:12 UTC

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