Skip to content

coin-grinder missing test for TOTAL_TRIES #33419

Closed

Description

@yancyribbens

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)

Activity

  1. yancyribbens commented on Sep 17, 2025

    @yancyribbens
    ContributorAuthor
  2. murchandamus commented on Oct 16, 2025

    @murchandamus
    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:

    /* Test BnB attempt limit (`TOTAL_TRIES`)

    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: 6cc9a46

  3. yancyribbens commented on Oct 24, 2025

    @yancyribbens
    ContributorAuthor

    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);
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions