Skip to content

Commit 2a51030

Browse files
committed
Removed the RelLockTime enum Error in error.rs
1 parent c538759 commit 2a51030

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

src/descriptor/error.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ pub enum Error {
4444
Hex(bitcoin::hex::HexToBytesError),
4545
/// The provided wallet descriptors are identical
4646
ExternalAndInternalAreTheSame,
47-
/// RelLockTime validation error
48-
RelLockTime(miniscript::RelLockTimeError),
4947
}
5048

5149
impl From<crate::keys::KeyError> for Error {
@@ -86,7 +84,6 @@ impl fmt::Display for Error {
8684
Self::ExternalAndInternalAreTheSame => {
8785
write!(f, "External and internal descriptors are the same")
8886
}
89-
Self::RelLockTime(err) => write!(f, "RelLockTime error: {err}"),
9087
}
9188
}
9289
}

tests/descriptor_macro.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ fn test_older_with_invalid_rellocktime_too_large() {
2020
);
2121

2222
// Check that it's the right kind of error
23-
if let Err(descriptor::DescriptorError::Miniscript(miniscript::Error::RelativeLockTime(_))) = result {
23+
if let Err(descriptor::DescriptorError::Miniscript(miniscript::Error::RelativeLockTime(_))) =
24+
result
25+
{
2426
} else {
2527
panic!("Expected RelLockTime error, got {:?}", result);
2628
}
@@ -91,30 +93,30 @@ fn test_rel_lock_time_error() {
9193
let invalid_value = 0x80000000u32;
9294
let rel_lock_time_result = miniscript::RelLockTime::from_consensus(invalid_value);
9395
assert!(rel_lock_time_result.is_err());
94-
96+
9597
let rel_lock_time_error = rel_lock_time_result.unwrap_err();
96-
98+
9799
// 2. Wrap it in the Miniscript error variant (matching your new macro logic)
98100
let minisc_err = miniscript::Error::RelativeLockTime(rel_lock_time_error);
99-
101+
100102
// 3. Test the From impl (Miniscript -> DescriptorError)
101103
let error: descriptor::DescriptorError = minisc_err.into();
102-
104+
103105
// Check that it matches the nested structure
104106
assert!(matches!(
105-
error,
107+
error,
106108
descriptor::DescriptorError::Miniscript(miniscript::Error::RelativeLockTime(_))
107109
));
108110

109111
// 4. Test the Display impl
110112
let display_string = format!("{}", error);
111-
112-
// FIX: Since the error is now wrapped in DescriptorError::Miniscript,
113+
114+
// FIX: Since the error is now wrapped in DescriptorError::Miniscript,
113115
// the string likely starts with "Miniscript error:" or similar.
114116
// Using .contains() is more robust for nested errors.
115117
assert!(
116118
display_string.contains("relative locktime"),
117-
"Display string was: '{}'", display_string
119+
"Display string was: '{}'",
120+
display_string
118121
);
119122
}
120-

0 commit comments

Comments
 (0)