#35170 test: Better test coverage for ParseHDKeypath()
| Reviewability | Reviews | Agreement | Size | ||||
|---|---|---|---|---|---|---|---|
| #35170 test: Better test coverage for ParseHDKeypath() | Ready | 1 (+3) | Strong | 0 + 120 tests | |||
|
|
|
| ||||
Reviewability: ReadyStalePaused Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs. Size: lines added or modified outside tests, then in tests; greener = smaller. | |||||||
Goal
Restructures the parse_hd_keypath unit test in bip32_tests into a table-driven test and verifies the parsed numeric keypath vector against expected values rather than only asserting boolean success. It also adds round-trip formatting checks with FormatHDKeypath and tests additional edge cases.
Problem: The unit test for ParseHDKeypath previously asserted only the boolean return status for most test inputs. A broken parser implementation returning true while clearing or corrupting the output vector would still pass unit tests.
Evidence of importance:
- PR description: 'This can be demonstrated by breaking the implementation by adding a keypath.clear(); statement just before the final return true;. With this obviously broken implementation the tests pass.'
Risk of a mistake: low (tests). Touches only unit test assertions in bip32_tests; a mistake would cause false-positive test failures.
Changed since the previous assessment: Dropped the codebase-wide scripted rename of ParseHDKeypath to ParseHDKeypathLegacy, restricting the PR strictly to unit test coverage in bip32_tests.cpp.
Reviewability
Ready
Nothing known that would invalidate a review now.
Waiting on (from the thread read):
- nothing: no pending actions
Agreement
Strong
substantive support, no open objection (haishmg)
Thread notes: Added Sjors' suggestion regarding temporary coverage reduction in the first commit; author addressed it by keeping the test case separate initially and updating the commit message, and Sjors re-ACKed.
Objections, suggestions, and questions:
| Reviewer | Type | Harm, request, or question | Status | Must be | Author replied | Quote |
|---|---|---|---|---|---|---|
| l0rinc (member) | suggestion, approach | Swap the order of arguments to store the value first and the validity next to match usage | answered · author explained keeping boolean first avoids excessive whitespace from string length variance | answered | yes | 2026-04-28: 'could we swap the order to store the value first and the validity next to follow the order in the usage' Status from: 2026-04-29: optout21: 'That's how it was done first, but to keep the formatting so that items align to the same columns, it produced a lot of e' |
| l0rinc (member) | suggestion, approach | Do not correlate the two calls for the fuzzer by consuming separate booleans | fixed · fix pushed · author implemented separate fuzzed boolean consumption in push | answered | yes | 2026-04-28: 'we don't want to correlate the two calls for the fuzzer' Status from: 2026-04-29: optout21: 'Done.' |
| l0rinc (member) | suggestion, approach | Make the rename a scripted diff for simplicity | fixed · fix pushed · author implemented as scripted diff in push | answered | yes | 2026-04-28: 'Can you make this a scripted diff for simplicity?' Status from: 2026-04-29: optout21: 'Thanks for insisting, done.' |
| brunoerg (member) | suggestion, style | Remove comments like 'num -> str2' and 'str2 -> num2' as unnecessary | fixed · fix pushed · author removed the comments during conflict resolution | answered | yes | 2026-07-24: 'nit: These comments "num -> str2" and "str2 -> num2" seem unnecessary, the code is already clear.' Status from: 2026-08-18: optout21: 'Applied (as I had to touch due to merge conflict).' |
| brunoerg (member) | question, approach | How effective is fuzzing FormatHDKeypath if WriteHDKeypath can call it again with the same values? | answered · author noted irrelevant after upstream merge #32784 resolved fuzzing independently | answered | yes | 2026-07-24: 'I'm just wondering how effective is fuzzing FormatHDKeypath if WriteHDKeypath can exactly call FormatHDKeypath again with same values.' Status from: 2026-08-18: optout21: 'Note: this is irrelevant now, as #32784 had solved this (in a different way).' |
| sedited (member) | suggestion, scope | Keep ParseHDKeypath without renaming it to ParseHDKeypathLegacy | fixed · fix pushed · author dropped the rename commit in push | answered | yes | 2026-10-05: 'I'm not convinced this rename makes sense after the addition of `derivehdkey`. I'd prefer keeping it as is.' Status from: 2026-10-06: optout21: 'Dropped the rename, and updated the OD accordingly.' |
| achow101 (member) | suggestion, scope | Keep the original naming as there is nothing legacy about ParseHDKeypath | fixed · fix pushed · author dropped the rename commit in push | answered | yes | 2026-10-06: 'Agree with keeping the original naming. There is nothing legacy about this function.' Status from: 2026-10-06: optout21: 'Dropped the rename, and updated the OD accordingly.' |
| Sjors (member) | suggestion, correctness | Avoid temporarily reducing test coverage in the refactor commit or document it in the commit message | accepted · fix pushed · author kept the test case separate in the first commit and updated the commit message; Sjors re-ACKed | answered | yes | 2026-10-28: 'IIUC this temporarily reduces test coverage. The commit message could mention it, or leave it out of the array initially:' Status from: 2026-10-28: Sjors: 're-ACK 3ce3641' |
Support:
- haishmg (none) (ACK, 2026-04-28) [both: src/test/bip32_tests.cpp, src/test/fuzz/key_io.cpp]: Reviewed the test refactor and added coverage, the ParseHDKeypathLegacy rename, and the fuzz target change. The new assertions cover returned path elements and round-trip behavior without changing the
- l0rinc (member) (Concept ACK, 2026-04-28): only reviewed lightly to understand the extent of the change [not substantive]
- brunoerg (member) (Concept ACK, 2026-07-24): Concept ACK [not substantive]
- brunoerg (member) (ACK, 2026-07-24): code review ACK cf76d345c85283e64a37e850b92b748c5ee29d2b [not substantive]
- w0xlt (contributor) (Concept ACK, 2026-08-18): Concept ACK [not substantive]
- brunoerg (member) (ACK, 2026-09-30): reACK 56b1a59b47bf7eb80bad5cbaf115e524a4192d57 [not substantive]
- w0xlt (contributor) (ACK, 2026-09-30): ACK 56b1a59b47bf7eb80bad5cbaf115e524a4192d57 [not substantive]
- w0xlt (contributor) (ACK, 2026-10-22): reACK dd665be15b553ef4aa5913c03f4b5e3a53751ce3 [not substantive]
- Sjors (member) (ACK, 2026-10-28): re-ACK 3ce3641 [not substantive]
- Sjors (member) (ACK, 2026-10-28): Concept ACK and ACK dd665be15b553ef4aa5913c03f4b5e3a53751ce3 [not substantive]
Participants:
- haishmg (none, support, 1 statements 2026-04-28 to 2026-04-28): ACK with local testing and review of coverage improvements
- l0rinc (member, support, 4 statements 2026-04-28 to 2026-04-28): Concept ACK; reviewed fuzz and unit test structure, made suggestions
- brunoerg (member, support, 5 statements 2026-07-24 to 2026-09-30): ACK and reACK after rebases; noted non-blocking nit and question
- w0xlt (contributor, support, 3 statements 2026-08-18 to 2026-10-22): Concept ACK, ACK, and reACK after rebase
- sedited (member, neutral, 1 statements 2026-10-05 to 2026-10-05): suggested keeping ParseHDKeypath name as is rather than renaming to ParseHDKeypathLegacy
- achow101 (member, neutral, 1 statements 2026-10-06 to 2026-10-06): agreed with keeping original naming rather than renaming to ParseHDKeypathLegacy
- Sjors (member, support, 3 statements 2026-10-28 to 2026-10-28): ACK, noted temporary reduction of coverage in first commit, and re-ACKed after author's fix
Files
216 lines under test/bench/ci.
- src/test/bip32_tests.cpp +120/-96
Card
The short text the ranking pass compares across PRs.
Restructures unit tests for ParseHDKeypath in bip32_tests into a table-driven test that verifies exact parsed numeric derivation paths and round-trip formatting. Existing tests only checked the boolean return value, allowing an implementation that cleared or corrupted the output vector to pass tests unnoticed. This change strictly modifies test code to ensure keypath parsing accuracy without altering runtime behavior.
Data
thread read through 2026-10-28 (34 statements), head 3ce364124c
labels: Tests
Categories
Utilities (logging, arguments, libraries)
P3 · test coverage (ranking pass: Moved down: test-only hardening with no active bug, below the behaviour-affecting fixes in this band.)
Improves unit test coverage for ParseHDKeypath by validating parsed vector values and round-trip formatting rather than merely checking boolean return status. The author showed the test suite previously had a blind spot where an 'obviously broken implementation' such as inserting keypath.clear() before return true would still pass. While worthwhile to protect parser correctness, it addresses no active production bug and is reasonably deferrable.
Membership: Modifies src/test/bip32_tests.cpp to test the ParseHDKeypath and FormatHDKeypath utilities in src/util/bip32.cpp.
Factors: security/stability 1, bug 0, performance 0, user value 0, leverage 0