test: cover missing BIP352 cases #36995

Open
devdavidejesus wants to merge 1 commit from test-bip352-mutants into master AGit
devdavidejesus commented 2026-11-27 12:20:23 +00:00 (Migrated from github.com)

The existing BIP352 tests leave several cases insufficiently covered. To identify these gaps, I ran manual mutation testing against src/common/bip352.cpp, complemented by bcore-mutation. Out of 55 mutations, 33 survived with the existing tests.

With these tests, 52 of the 55 mutations are detected. The three remaining mutations are equivalent to the original implementation.

One mutation replaces the return std::nullopt with break when GetOp fails while scanning a P2PKH scriptSig. The function reaches the same return std::nullopt after the loop. Another removes the early return for the case where there are no eligible keys, checking only whether there are no inputs. With no keys, libsecp256k1 already returns a failure, so the result remains NOT_ELIGIBLE. The third mutation changes the P2PKH scriptSig scanning loop condition from pc < txin.scriptSig.end() to pc <= txin.scriptSig.end(). When pc reaches the end of the scriptSig, GetOp fails, and the function returns the same std::nullopt.

The new tests cover scan label reporting, P2PKH public key extraction when the scriptSig contains unrelated pushes, invalid public keys across supported input types, P2SH-P2WPKH eligibility, Taproot script-path spends, annex handling, control block validation, prevouts summary errors, Silent Payments destination validation, label copy assignment, maximum-size control block acceptance, and the behavior of Scan when none of the outputs is a valid x-only key.

The existing bip352_skips_transactions_spending_unknown_segwit_versions test is also extended to cover SegWit versions v2 through v16 and check the exact NOT_ELIGIBLE error. The address decoding tests also cover a v0 address with a valid Bech32m checksum but one extra data byte (67 instead of 66). The existing bip352_scan_skips_invalid_taproot_outputs test is extended to verify that Scan returns an empty list, rather than an error, when none of the outputs is a valid x-only key.

The changes are limited to src/test/bip352_tests.cpp. No production code is modified.

The tests also pass on top of the P2SH changes from #36776. The annex-related mutations are detected independently of #36992.

Using bcore-mutation with --one-mutant and the bip352_tests test suite, the mutation score improves from 83.93% (9 of 56 mutations surviving on master) to 91.07% (5 of 56 surviving with the first PR version) and finally to 98.21% (1 of 56 surviving with this version). The only remaining survivor is the equivalent P2PKH loop-boundary mutation described above.

src/common/bip352.cpp is not included in the continuous mutation-testing runs on corecheck, so these gaps are not covered by those runs.

The existing BIP352 tests leave several cases insufficiently covered. To identify these gaps, I ran manual mutation testing against `src/common/bip352.cpp`, complemented by `bcore-mutation`. Out of 55 mutations, 33 survived with the existing tests. With these tests, 52 of the 55 mutations are detected. The three remaining mutations are equivalent to the original implementation. One mutation replaces the `return std::nullopt` with `break` when `GetOp` fails while scanning a P2PKH scriptSig. The function reaches the same `return std::nullopt` after the loop. Another removes the early return for the case where there are no eligible keys, checking only whether there are no inputs. With no keys, libsecp256k1 already returns a failure, so the result remains `NOT_ELIGIBLE`. The third mutation changes the P2PKH scriptSig scanning loop condition from `pc < txin.scriptSig.end()` to `pc <= txin.scriptSig.end()`. When `pc` reaches the end of the scriptSig, `GetOp` fails, and the function returns the same `std::nullopt`. The new tests cover scan label reporting, P2PKH public key extraction when the `scriptSig` contains unrelated pushes, invalid public keys across supported input types, P2SH-P2WPKH eligibility, Taproot script-path spends, annex handling, control block validation, prevouts summary errors, Silent Payments destination validation, label copy assignment, maximum-size control block acceptance, and the behavior of `Scan` when none of the outputs is a valid x-only key. The existing `bip352_skips_transactions_spending_unknown_segwit_versions` test is also extended to cover SegWit versions v2 through v16 and check the exact `NOT_ELIGIBLE` error. The address decoding tests also cover a v0 address with a valid Bech32m checksum but one extra data byte (67 instead of 66). The existing `bip352_scan_skips_invalid_taproot_outputs` test is extended to verify that `Scan` returns an empty list, rather than an error, when none of the outputs is a valid x-only key. The changes are limited to `src/test/bip352_tests.cpp`. No production code is modified. The tests also pass on top of the P2SH changes from #36776. The annex-related mutations are detected independently of #36992. Using `bcore-mutation` with `--one-mutant` and the `bip352_tests` test suite, the mutation score improves from 83.93% (9 of 56 mutations surviving on master) to 91.07% (5 of 56 surviving with the first PR version) and finally to 98.21% (1 of 56 surviving with this version). The only remaining survivor is the equivalent P2PKH loop-boundary mutation described above. `src/common/bip352.cpp` is not included in the continuous mutation-testing runs on corecheck, so these gaps are not covered by those runs.
DrahtBot commented 2026-11-27 12:20:33 +00:00 (Migrated from github.com)

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.
A summary of reviews will appear here.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36995 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36995.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36995#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

I found no actionable issues in this static review.


Reviewed: e8f9dd94b694 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:312ddb2095238aa2ca395a9cc39b05ab5a38a7177afbdb0d69098df9c3e0bef9:9a7f127b15c6116c267953d38288a9f17ec7c7bcd3a975fb71a2db8bfd974dbf --> <!-- ralph-base:afedb19cca4c3b40d89514fb0c66b0c20e4f5d62 --> <!-- ralph-head:e8f9dd94b6941521e1ceded7145f36ba445b6758 --> <!-- ralph-case:8fd4de162ba8db72d18ea3f4a46d6354afa8342a88cab59e30c2ca69ec56d7b5 --> I found no actionable issues in this static review. <!-- Review tier: routine --> --- Reviewed: [`e8f9dd94b694`](<https://git.fish.foo/bitcoin/bitcoin/commit/e8f9dd94b6941521e1ceded7145f36ba445b6758>) · [Review report](<https://review.fish.foo/report/36995-e8f9dd94b6941521e1ceded7145f36ba445b6758-3280-2.html>) · [Previous reports](<https://review.fish.foo/traces/36995/>) [permalink](<https://review.fish.foo/report/36995-e8f9dd94b6941521e1ceded7145f36ba445b6758-3280-2.html>)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36995
No description provided.