Skip to content

Commit 7a2eba4

Browse files
committed
test (seals): cover yet uncovered fragments
1 parent 220568a commit 7a2eba4

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

single_use_seals/src/lib.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ where
433433
}
434434

435435
#[cfg(test)]
436+
#[cfg_attr(coverage_nightly, coverage(off))]
436437
mod tests {
437438
use super::*;
438439

@@ -546,6 +547,14 @@ mod tests {
546547
}
547548
impl Error for Invalid {}
548549

550+
#[test]
551+
fn verify_no_client_witness() {
552+
let mut a = NoClientWitness::default();
553+
let b = NoClientWitness::<DumbSeal>::new();
554+
assert_eq!(a, b);
555+
a.merge(b).unwrap();
556+
}
557+
549558
#[test]
550559
fn verify_success() {
551560
let seal = DumbSeal(0xCA);
@@ -571,8 +580,12 @@ mod tests {
571580
];
572581
let witness =
573582
SealWitness::new(DumbPubWitness(message, fake_seal), NoClientWitness::default());
583+
let res = witness.verify_seal_closing(seal, message).unwrap_err();
584+
// We need this to test cover Debug and Display impl for SealError
585+
println!("{res}");
586+
println!("{res:?}");
574587
assert!(matches!(
575-
witness.verify_seal_closing(seal, message).unwrap_err(),
588+
res,
576589
SealError::NotIncluded(s, 0x00) if s == seal
577590
));
578591
}
@@ -587,10 +600,11 @@ mod tests {
587600
let mut fake_message = message;
588601
fake_message[0] = 0x00;
589602
let witness = SealWitness::new(DumbPubWitness(message, seal), NoClientWitness::default());
590-
assert!(matches!(
591-
witness.verify_seal_closing(seal, fake_message).unwrap_err(),
592-
SealError::Published(Invalid)
593-
));
603+
let res = witness.verify_seal_closing(seal, fake_message).unwrap_err();
604+
// We need this to test cover Debug and Display impl for SealError
605+
println!("{res}");
606+
println!("{res:?}");
607+
assert!(matches!(res, SealError::Published(Invalid)));
594608
}
595609

596610
#[test]
@@ -601,9 +615,10 @@ mod tests {
601615
0xDA, 0xFE,
602616
];
603617
let witness = SealWitness::new(DumbPubWitness(message, seal), FailingCliWitness::default());
604-
assert!(matches!(
605-
witness.verify_seal_closing(seal, message).unwrap_err(),
606-
SealError::Client(Invalid)
607-
));
618+
let res = witness.verify_seal_closing(seal, message).unwrap_err();
619+
// We need this to test cover Debug and Display impl for SealError
620+
println!("{res}");
621+
println!("{res:?}");
622+
assert!(matches!(res, SealError::Client(Invalid)));
608623
}
609624
}

0 commit comments

Comments
 (0)