From 114e2989fa05aef69361ceb07bc4382c9be6a4c4 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 20 May 2019 13:02:44 -0700 Subject: [PATCH] Improve PoH unit test asserts (#4351) automerge --- core/src/poh.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/poh.rs b/core/src/poh.rs index ccee17bb56..8e66bf82e6 100644 --- a/core/src/poh.rs +++ b/core/src/poh.rs @@ -226,7 +226,7 @@ mod tests { assert_eq!(poh.remaining_hashes, 2); assert!(poh.tick().is_none()); assert_eq!(poh.remaining_hashes, 1); - assert!(poh.tick().is_some()); + assert_matches!(poh.tick(), Some(PohEntry { num_hashes: 2, .. })); assert_eq!(poh.remaining_hashes, 2); // Ready for the next tick } @@ -255,7 +255,11 @@ mod tests { assert!(poh.hash(9)); assert_eq!(poh.remaining_hashes, 1); assert!(poh.record(Hash::default()).is_none()); // <-- record() rejected to avoid exceeding hashes_per_tick - poh.tick(); - assert!(poh.record(Hash::default()).is_some()); // <-- record() ok + assert_matches!(poh.tick(), Some(PohEntry { num_hashes: 10, .. })); + assert_matches!( + poh.record(Hash::default()), + Some(PohEntry { num_hashes: 1, .. }) // <-- record() ok + ); + assert_eq!(poh.remaining_hashes, 9); } }