Improve relative::LockTime tests

Cargo mutants found some untested mutants.

Add test cases to kill the mutants.
This commit is contained in:
Jamil Lambert, PhD 2025-01-23 18:49:04 +00:00
parent 2c73546454
commit 40dc896932
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
1 changed files with 43 additions and 0 deletions

View File

@ -425,6 +425,31 @@ impl std::error::Error for IncompatibleTimeError {}
mod tests {
use super::*;
#[test]
fn parses_correctly_to_height_or_time() {
let height1 = Height::from(10);
let height2 = Height::from(11);
let time1 = Time::from_512_second_intervals(70);
let time2 = Time::from_512_second_intervals(71);
let lock_height1 = LockTime::from(height1);
let lock_height2 = LockTime::from(height2);
let lock_time1 = LockTime::from(time1);
let lock_time2 = LockTime::from(time2);
assert!(lock_height1.is_block_height());
assert!(!lock_height1.is_block_time());
assert!(!lock_time1.is_block_height());
assert!(lock_time1.is_block_time());
// Test is_same_unit() logic
assert!(lock_height1.is_same_unit(lock_height2));
assert!(!lock_height1.is_same_unit(lock_time1));
assert!(lock_time1.is_same_unit(lock_time2));
assert!(!lock_time1.is_same_unit(lock_height1));
}
#[test]
fn satisfied_by_height() {
let height = Height::from(10);
@ -469,6 +494,24 @@ mod tests {
assert!(lock.is_implied_by(LockTime::from(Time::from_512_second_intervals(71))));
}
#[test]
fn sequence_correctly_implies() {
let height = Height::from(10);
let time = Time::from_512_second_intervals(70);
let lock_height = LockTime::from(height);
let lock_time = LockTime::from(time);
let seq_height = Sequence::from(lock_height);
let seq_time = Sequence::from(lock_time);
assert!(lock_height.is_implied_by_sequence(seq_height));
assert!(!lock_height.is_implied_by_sequence(seq_time));
assert!(lock_time.is_implied_by_sequence(seq_time));
assert!(!lock_time.is_implied_by_sequence(seq_height));
}
#[test]
fn incorrect_units_do_not_imply() {
let time = Time::from_512_second_intervals(70);