Repository navigation
test: cover missing BIP352 cases - #36995
Open
devdavidejesus wants to merge 1 commit into
Open
devdavidejesus wants to merge 1 commit into
devdavidejesus wants to merge 1 commit into
Conversation
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. |
Add unit tests for BIP352 cases that are not adequately covered by the existing test suite. The tests cover scan labels, P2PKH public key extraction, invalid public keys, P2SH input eligibility, Taproot script-path spends, annex handling, prevouts summary errors, invalid Silent Payments destinations, label copy assignment, maximum-size control blocks, and scanning transactions without valid x-only outputs. These cases were identified through manual mutation testing and bcore-mutation.
devdavidejesus
force-pushed
the
test-bip352-mutants
branch
from
November 27, 2026 20:48
52c04c0 to
e8f9dd9
Compare
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The existing BIP352 tests leave several cases insufficiently covered. To identify these gaps, I ran manual mutation testing against
src/common/bip352.cpp, complemented bybcore-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::nulloptwithbreakwhenGetOpfails while scanning a P2PKH scriptSig. The function reaches the samereturn std::nulloptafter 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 remainsNOT_ELIGIBLE. The third mutation changes the P2PKH scriptSig scanning loop condition frompc < txin.scriptSig.end()topc <= txin.scriptSig.end(). Whenpcreaches the end of the scriptSig,GetOpfails, and the function returns the samestd::nullopt.The new tests cover scan label reporting, P2PKH public key extraction when the
scriptSigcontains 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 ofScanwhen none of the outputs is a valid x-only key.The existing
bip352_skips_transactions_spending_unknown_segwit_versionstest is also extended to cover SegWit versions v2 through v16 and check the exactNOT_ELIGIBLEerror. The address decoding tests also cover a v0 address with a valid Bech32m checksum but one extra data byte (67 instead of 66). The existingbip352_scan_skips_invalid_taproot_outputstest is extended to verify thatScanreturns 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-mutationwith--one-mutantand thebip352_teststest 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.cppis not included in the continuous mutation-testing runs on corecheck, so these gaps are not covered by those runs.