Merge bitcoin/bitcoin#36775: test: wallet: BnB marks exhaustive search complete
What changed, and why it matters
This commit only adds a new check to an existing unit test. It makes sure that when Bitcoin Core's coin-selection algorithm (called Branch-and-Bound or BnB) finishes searching all possible coin combinations, it correctly reports that the search was completed. The actual production code is unchanged; only the test is strengthened. There is no security fix or vulnerability being patched.
No security action needed. Treat as a normal quality/test-coverage improvement.
Security signals we found
No production code change
Pure test-coverage improvement
No memory safety, cryptography, consensus, or networking changes
Evidence from the diff
The change is in src/wallet/test/coinselection_tests.cpp. The helper TestBnBSuccess now asserts result->GetAlgoCompleted() for BnB runs that finish below the TOTAL_TRIES limit. This closes a test gap where a mutant that flipped SetAlgoCompleted(true) to false in SelectCoinsBnB would not be caught. No production code is modified.
Changed components
src/wallet/test/coinselection_tests.cppInspect captured patch +1 / −0
### src/wallet/test/coinselection_tests.cpp
@@ -128,6 +128,7 @@ static void TestBnBSuccess(std::string test_title, std::vector<OutputGroup>& utx
BOOST_CHECK_MESSAGE(result->GetSelectedValue() == expected_amount, strprintf("Selected amount mismatch in BnB-Success: %s. Expected %d, but got %d", test_title, expected_amount, result->GetSelectedValue()));
BOOST_CHECK_MESSAGE(result->GetWeight() <= max_selection_weight, strprintf("Selected weight is higher than permitted in BnB-Success: %s. Expected %d, but got %d", test_title, max_selection_weight, result->GetWeight()));
BOOST_CHECK_MESSAGE(result->GetSelectionsEvaluated() == expected_attempts, strprintf("Unexpected number of attempts in BnB-Success: %s. Expected %i attempts, but got %i", test_title, expected_attempts, result->GetSelectionsEvaluated()));
+ BOOST_CHECK_MESSAGE(result->GetAlgoCompleted(), "Expected BnB to exhaust the search space in BnB-Success: " + test_title);
}
static void TestBnBFail(std::string test_title, std::vector<OutputGroup>& utxo_pool, const CAmount& selection_target, const CoinSelectionParams& cs_params = default_cs_params, int max_selection_weight = MAX_STANDARD_TX_WEIGHT, const bool expect_max_weight_exceeded = false)Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.