@@ -13,7 +13,9 @@ fn test_after_with_invalid_abslocktime_zero() {
1313 ) ;
1414
1515 // Check for the correct error variant
16- if let Err ( descriptor:: DescriptorError :: AbsLockTime ( _) ) = result {
16+ if let Err ( descriptor:: DescriptorError :: Miniscript ( miniscript:: Error :: AbsoluteLockTime ( _) ) ) =
17+ result
18+ {
1719 // Success: Error was caught and mapped correctly
1820 } else {
1921 panic ! ( "Expected AbsLockTime error, got {:?}" , result) ;
@@ -55,8 +57,13 @@ fn test_after_with_invalid_just_above_max() {
5557 let result = descriptor ! ( wsh( after( too_large) ) ) ;
5658
5759 assert ! (
58- result. is_err( ) ,
59- "Value 2,147,483,649 should return a DescriptorError::AbsLockTime"
60+ matches!(
61+ result,
62+ Err ( descriptor:: DescriptorError :: Miniscript (
63+ miniscript:: Error :: AbsoluteLockTime ( _)
64+ ) )
65+ ) ,
66+ "Should fail specifically with a Miniscript AbsoluteLockTime error"
6067 ) ;
6168}
6269
@@ -74,21 +81,26 @@ fn test_after_with_u32_max_is_invalid() {
7481
7582#[ test]
7683fn test_abs_lock_time_error_mapping ( ) {
77- // Manually trigger the error to verify the From conversion into DescriptorError
7884 let invalid_value = 0 ;
7985 let abs_lock_result = AbsLockTime :: from_consensus ( invalid_value) ;
8086
8187 assert ! ( abs_lock_result. is_err( ) ) ;
8288 let abs_err = abs_lock_result. unwrap_err ( ) ;
8389
84- // Verify the conversion into your custom DescriptorError
85- let error: descriptor:: DescriptorError = abs_err. into ( ) ;
86- assert ! ( matches!( error, descriptor:: DescriptorError :: AbsLockTime ( _) ) ) ;
90+ // Wrap in the general Miniscript Error enum
91+ let minisc_err = miniscript:: Error :: AbsoluteLockTime ( abs_err) ;
92+
93+ // Convert to your local Error type using .into()
94+ let error: descriptor:: DescriptorError = minisc_err. into ( ) ;
95+
96+ // Assert it landed in the Miniscript variant
97+ assert ! ( matches!( error, descriptor:: DescriptorError :: Miniscript ( _) ) ) ;
8798
88- // Check that the error message is descriptive
99+ // Verify the error message contains the expected text
89100 let display_string = format ! ( "{}" , error) ;
90101 assert ! (
91- display_string. contains( "AbsLockTime" ) ,
92- "Error message should mention AbsLockTime"
102+ display_string. contains( "absolute locktime" ) ,
103+ "Error message '{}' should mention locktime" ,
104+ display_string
93105 ) ;
94106}
0 commit comments