fix(descriptor): propagate threshold errors instead of panicking - #533
Open
busayo-OD wants to merge 1 commit into
Open
fix(descriptor): propagate threshold errors instead of panicking#533busayo-OD wants to merge 1 commit into
busayo-OD wants to merge 1 commit into
Conversation
thresh_vec, multi_vec, and multi_a_vec panicked via .expect() on Threshold::new whenever k/n were invalid at runtime, even though the surrounding macros return Result<_, DescriptorError>. Reuses the existing miniscript::Error::Threshold case and DescriptorError::Miniscript conversion since miniscript's own descriptor code already surfaces this error the same way.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #533 +/- ##
=======================================
Coverage 81.84% 81.84%
=======================================
Files 25 25
Lines 6487 6490 +3
Branches 296 296
=======================================
+ Hits 5309 5312 +3
Misses 1078 1078
Partials 100 100
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #532
Description
thresh_vec,multi_vec, andmulti_a_vecused.expect(...)onThreshold::new, causing invalid runtime-supplied thresholds to panic instead of returning through the macros' usualResult<_, DescriptorError>.For
thresh_vec, the error is propagated through its existingResultchain. Formulti_vecandmulti_a_vec,keys::make_multinow accepts a closure returningResult<Terminal<...>, DescriptorError>, matching the existingmake_sortedmultipattern and removing the need for.expect(...).Notes to the reviewers
miniscriptalready providesError::Thresholdfor invalid thresholds, andDescriptorErroralready wrapsminiscript::Error, so I reused the existing error path rather than introducing a new variant. Happy to switch to a dedicated variant if you'd rather keep threshold failures more explicit.Checklists
All Submissions
just pbefore pushingBugfixes