mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
test: Descriptor roundtrip and raw()/ addr() coverage #36013
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!36013
Loading…
Reference in a new issue
No description provided.
Delete branch "descriptor/roundtrip-raw-addr-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?
Part 1 of 2, reviving #24361.
Ports the two test-only commits from the original PR above, re-applied against the current
descriptor_tests.cpp— the original no longer applies cleanly, sinceDoCheck()'s signature has changed substantially since the original PR was created back in 2022.norm_prvwas dropped, andop_desc_id,spender_nlocktime,spender_nsequence,preimages,expected_prv/expected_pub, anddesc_indexwere all added - so the original diff no longer applies...(For more details check 1st commit body)
Check()coverage for validraw()andaddr()descriptors, previously exercised only for invalid inputs and only in the script-to-descriptor direction. Added a newNO_KEYSflag, since these descriptors have zero keys and several existing checks assumed at least one.(For more details check 2nd commit body)
No behavior change, test-only.
Part 2 (not yet opened): the
ToString()/ToPrivateString()merge from #24361, independent of this PR — needs more design work before it's ready.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:
BOOST_FAILand add info in descriptor_tests by rustaceanrob)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.
Concept ACK
Now that we have a few checks in the
truepart of theifbranch below, perhaps we can change this to beBOOST_TEST_INFO_SCOPEso the descriptor is also printed ifBOOST_CHECK_EQUAL(parse_pub->GetKeyCount(), 0U);fails.Same feedback as the comment above, perhaps could be
BOOST_TEST_INFO_SCOPELeft a comment regarding
BOOST_TEST_INFO, which only prints the value the next failing check, not any check in scopeDone in
2d230d8366, thanks!Done in
2d230d8366, thanks!-Updates:
BOOST_TEST_INFOwithBOOST_TEST_INFO_SCOPEingithub.com/bitcoin/bitcoin@2d230d8366.Concept ACK
Built at the head, ran the unit suite, and checked the six new addresses by decoding them outside of Core.
The multipath alternative here seems avoidable. It only exists because the roundtrip comparison uses
pub, the literal test string. In these checks,pub1is expanded, andDoCheck()already compares it againstpub, or the expandedexpected_publiteral for multipath. With the oldSTR_KEYSTEPand the comparison onpub1, the suite passes. Both forms run the same 666 roundtrip checks and produce the same 60 failures under the testedInferScript()mutation.mark_count()is worth keeping either way. Is the literal intended to catch somethingpub1would not?nit: this matches
sortedmulti(but notsortedmulti_a(, whichInferMultiA()gives back asmulti_a. No vector uses it today, so nothing breaks, but I flipped the existing 1-of-1multi_avector tosortedmulti_a, same script by construction, and only the roundtrip comparison failed, six times,multi_aversussortedmulti_a. Allowing an optional_ahere and keeping it in the replacement fixes it, ran that and the suite went back to green.Could we assert the
ToPrivateString()contract forNO_KEYShere instead of only skipping the block? The header promises afalsereturn when no private keys are available at all, which is exactly theraw()andaddr()case. I changed both implementations to returntrueand the whole unit suite stayed green. Anelse if (flags & NO_KEYS)with the two negative checks closes it. I ran that, and the same mutation now fails 14 times, twice per new vector.Base:
2034d3078ee1df99cdbfab738b1f2b54c30bd022Head:
cf9821aaa5ed971c9e3eb16bbf5daed0495a9252Findings
Suggestions
Include
<iterator>directly (src/test/descriptor_tests.cpp:217, head)This code uses
std::ostreambuf_iterator, but the file does not include<iterator>. Add the direct include rather than relying on a transitive include that may change.Full review report
ACK
2d230d8366Built
test_bitcoinat the head and randescriptor_tests, no errors. Recomputed the six newaddr()vectors with btclib: the scriptPubKeys, the addresses back from them, the witness versions and programs, and the legacy/bech32/bech32m output types all match. One nit: the v1 vector cannot be a plain taproot address, since a P2TR script infers back as a solvablerawtr()and fails both the new structure compare and the existing solvability checks (triedaddr(bc1padda8…)for5120eb5b…); a short comment saying why it is a 40-byte program instead would spare the next reader the experiment.Thanks! The multipath branch was only needed because the comparison at line ~531 used
pubdirectly instead ofpub1. I'll switch it topub1, reverting this to the simpler form.Thanks! I'll include a short comment explaining the 40-byte choice.
🚧 At least one of the CI tasks failed.
Task
tidy: https://github.com/bitcoin/bitcoin/actions/runs/37714644244/job/113108232448LLM reason (✨ experimental): CI failed because clang-tidy flagged
/*op_desc_id=*/comments indescriptor_tests.cppas mismatched with the parameter nameop_compat_desc_hash(warnings treated as errors).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.
Done.
Done, thanks!
Done.
Done, thanks!
-Updates:
DescriptorID/op_desc_idtoCompatDescriptorHash/op_compat_desc_hash, leaving a few comments out of sync and failing tidy CI. Fixed.reACK
cf9821aaa5descriptor_testspasses at the new head, and theraw()/addr()vectors are unchanged since2d230d8, so my earlier check of them still holds. Thanks for the comment on the 40-byte v1 program.Not sure if I am missing something, but it seems like this function can be simplified using
regex_replaceandstd::regex:nit: Could use
(flags & NO_KEYS) != 0for legibility. Had to look up the!!case🐙 This pull request conflicts with the target branch and needs rebase.
You can remove this line as of #36772, the descriptor is added as context at the top of
DoChecknow