mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
WIP: Refactor CoinGrinder tests #36255
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36255
Loading…
Reference in a new issue
No description provided.
Delete branch "2026-09-refactor-coingrinder-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR migrates the CoinGrinder tests from
coinselector_tests.cppto the new coin selection test suitecoinselection_tests.cppwhere we use effective values, actual feerates, and avoid setting coin selection parameters that never appear in production.Most of the tests are exact replications of the originals in the new framework, just the CoinGrinder exhaustion test was slightly refactored to simplify: it was using different weights for every single UTXO, but just two different weights are sufficient to replicate the relevant behavior for the test.
Each commit migrates one test to simplify review.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
LLM Linter (✨ experimental)
Possible typos and grammar issues:
The inputs size exceeds the maximum weight->The input size exceeds the maximum weight[“inputs size” is grammatically incorrect and reads awkwardly]2026-09-14 22:56:14
Made available as a PR, because I was discussing it with a colleague who wanted to provide feedback, but there are still a couple minor things that I want to tweak anyway.
🚧 At least one of the CI tasks failed.
Task
No wallet: https://github.com/bitcoin/bitcoin/actions/runs/34906476628/job/104184206297LLM reason (✨ experimental): CI failed because
clang++-17crashed (segmentation fault, exit code 139) while compilingsrc/ipc/libmultiprocess/src/mp/util.cpp.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Concept ACK
I left a few suggestions to make the test categories independently runnable (each one exercising multiple scenarios, grouping by category), untangling the separate test cases and simplified the helpers, assertions, and amount expressions.
I've implemented them in https://github.com/l0rinc/bitcoin/pull/297/commits (see last commit) - feel free to pick and choose and split and fold them back into your commits if you agree with the direction.
Note that the CI failure seems unrelated.
Here we can remove the
default_cs_paramsas well now, right?Since every caller uses effective values, could we remove
is_eff_valuealtogether?The previous implementation was indeed hard to understand.
This is basically a permutation check of a subset of fields, and since we have very few elements here (given it's test code), we could either simplify further to:
or if you don't find this readable we could extract the common parts that prepare the final comparable objects and compare those directly at the call site:
and in the assertion we can have
directly.
Assertions inside these helpers report the helper's source line, so
test_titlehas to identify the individual scenario. Could we organize the scenarios into named Boost test cases and share the repeated assertions through small macros, as in the headers-sync tests? That would keep failure locations at each call site and make the test categories independently runnable. Cases with the same setup and checks can share a small table of inputs and expectations, while cases with different assertion flows can remain separate.HaveEquivalentInputsalready compares the input values, andGetSelectedValue()just sums them. Could we dropexpected_amount, its accumulation, and this assertion? For the remaining scalar checks, Boost already prints the operands:I would keep the weight check because
GetWeight()reads separately maintained state. The same simplifications apply to the BnB helper.Could we use integer amounts throughout the migrated tests, e.g. 33 * CENT here and 2'533 * CENT for the target below? This expresses the intended satoshi amounts directly and avoids floating-point multiplication followed by conversion to
CAmount.Could
AddDuplicateCoinstake an optional input size so these four loops become four calls to the existing helper? We could also buildexpected_inputsonce and initializeutxo_poolfrom it before adding the heavier clones, which avoids constructing the four expected coins twice.This is a strange max_selection_weight. It would be better to use real values, like max transaction weight of of 400_000 I think, although that's unrelated to this change.
Unrelated to this change, but why choose a set and target of 40000? I had thought at first this was 400000 which would make more sense, so I wonder if this was a typo.
Concept ACK. Thanks for following up on this. It would be nice to see the coinselector test file removed entirely in the future since having multiple test files has caused confusion. Also minor nit, but your older commit messages have different capitalization than your newer messages.
🔵 Suggestion · Migrated insufficient-funds tests lose the empty-error check
The migrated CoinGrinder insufficient-funds tests would accept unrelated non-empty errors, losing the explicit empty-error assertion in the removed test.
Location:
src/wallet/test/coinselection_tests.cpp:275(head).Review coverage was incomplete.
Reviewed:
08ee40f1deb4· Full review report · Previous reportspermalink
TestSRDSuccesscallsutxo_poolinstead of themixed_weight_poolit builds. As a result, the tie-break test passes even when #33223 is reverted. There's nothing checking the tie-break. Also coin eviction never happens because the current max weight (804 WU) fits any two coins (544 WU).Yes, that looks like an oversight in the test. Although, I think it would be better addressed with a separate PR since this PR is specific to coin-grinder, and the test in question is for SRD. Also, that line is not touched by this PR.
Looking a little closer at the test, I think there is more wrong than simply it should be
mixed_weight_poolinstead ofutxo_pool. We want to test that the larger UTXO is evicted from the selection since all effective_values are tied. However, since the target only takes two utxos to reach, it is unlikely to hold the smaller weight utxo in the selection to be evicted. I would also have expected a sort of test to assert the resulting utxos on success. I'll let @murchandamus reply though before going further since maybe i'm missing some simple typo that would make the test work as expected.sure, I have a draft; I wanted to check before opening a PR
I will take a look if you want to open a PR to fix the test. It might take murch a while to respond.