Skip to content

Commit 3649850

Browse files
committed
tests: remove all uses of Eq on error types
In the next commit we will remove this.
1 parent 4f52fb7 commit 3649850

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/miniscript/mod.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,13 +1472,16 @@ mod tests {
14721472
fn duplicate_keys() {
14731473
// You cannot parse a Miniscript that has duplicate keys
14741474
let err = Miniscript::<String, Segwitv0>::from_str("and_v(v:pk(A),pk(A))").unwrap_err();
1475-
assert_eq!(err, Error::AnalysisError(crate::AnalysisError::RepeatedPubkeys));
1475+
assert!(matches!(err, Error::AnalysisError(crate::AnalysisError::RepeatedPubkeys)));
14761476

14771477
// ...though you can parse one with from_str_insane
14781478
let ok_insane =
14791479
Miniscript::<String, Segwitv0>::from_str_insane("and_v(v:pk(A),pk(A))").unwrap();
14801480
// ...but this cannot be sanity checked.
1481-
assert_eq!(ok_insane.sanity_check().unwrap_err(), crate::AnalysisError::RepeatedPubkeys);
1481+
assert!(matches!(
1482+
ok_insane.sanity_check().unwrap_err(),
1483+
crate::AnalysisError::RepeatedPubkeys
1484+
));
14821485
// ...it can be lifted, though it's unclear whether this is a deliberate
14831486
// choice or just an accident. It seems weird given that duplicate public
14841487
// keys are forbidden in several other places.
@@ -1492,7 +1495,10 @@ mod tests {
14921495
"and_v(v:and_v(v:older(4194304),pk(A)),and_v(v:older(1),pk(B)))",
14931496
)
14941497
.unwrap_err();
1495-
assert_eq!(err, Error::AnalysisError(crate::AnalysisError::HeightTimelockCombination));
1498+
assert!(matches!(
1499+
err,
1500+
Error::AnalysisError(crate::AnalysisError::HeightTimelockCombination)
1501+
));
14961502

14971503
// Though you can in an or() rather than and()
14981504
let ok_or = Miniscript::<String, Segwitv0>::from_str(
@@ -1512,10 +1518,10 @@ mod tests {
15121518
ok_insane.sanity_check().unwrap_err(),
15131519
crate::AnalysisError::HeightTimelockCombination
15141520
);
1515-
assert_eq!(
1521+
assert!(matches!(
15161522
ok_insane.lift().unwrap_err(),
15171523
Error::LiftError(crate::policy::LiftError::HeightTimelockCombination)
1518-
);
1524+
));
15191525
}
15201526

15211527
#[test]

0 commit comments

Comments
 (0)