Skip to content

Commit

Permalink
Merge rust-bitcoin#4037: primitives: Add tests to LockTime
Browse files Browse the repository at this point in the history
6cecc40 Test LockTime PartialOrd (Jamil Lambert, PhD)

Pull request description:

  Add tests to kill the mutants in both relative and absolute PartialOrd.

ACKs for top commit:
  tcharding:
    ACK 6cecc40
  apoelstra:
    ACK 6cecc40; successfully ran local tests; thanks!

Tree-SHA512: dba7d90e3f6e62f0d3417bacc09d38145dd29bf654f84c2d3bc68af30c0e65b105146466a384bd35ef4326913ca414fd31f92daa3d7ffe3ff409c49bd1c05d96
  • Loading branch information
apoelstra committed Feb 15, 2025
2 parents e1cb0f1 + 6cecc40 commit 007f4d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions primitives/src/locktime/absolute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ mod tests {
assert!(lock_by_height.is_satisfied_by(height_same, time));
assert!(lock_by_height.is_satisfied_by(height_above, time));
assert!(!lock_by_height.is_satisfied_by(height_below, time));

let lock_by_height_above = LockTime::from_consensus(800_000);
assert!(lock_by_height < lock_by_height_above)
}

#[test]
Expand All @@ -516,6 +519,9 @@ mod tests {
assert!(lock_by_time.is_satisfied_by(height, time_same));
assert!(lock_by_time.is_satisfied_by(height, time_after));
assert!(!lock_by_time.is_satisfied_by(height, time_before));

let lock_by_time_after = LockTime::from_consensus(1653282000);
assert!(lock_by_time < lock_by_time_after);
}

#[test]
Expand Down
3 changes: 3 additions & 0 deletions primitives/src/locktime/relative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ mod tests {
assert!(!lock_by_height1.is_same_unit(lock_by_time1));
assert!(lock_by_time1.is_same_unit(lock_by_time2));
assert!(!lock_by_time1.is_same_unit(lock_by_height1));

assert!(lock_by_height1 < lock_by_height2);
assert!(lock_by_time1 < lock_by_time2);
}

#[test]
Expand Down

0 comments on commit 007f4d3

Please sign in to comment.