mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
tx-pool: add unit tests for FinalizedBlockTracker update (#10078)
This commit is contained in:
@ -742,4 +742,46 @@ mod tests {
|
|||||||
|
|
||||||
temp_dir.close().unwrap();
|
temp_dir.close().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_update_with_higher_finalized_block() {
|
||||||
|
let mut tracker = FinalizedBlockTracker::new(Some(10));
|
||||||
|
assert_eq!(tracker.update(Some(15)), Some(15));
|
||||||
|
assert_eq!(tracker.last_finalized_block, Some(15));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_update_with_lower_finalized_block() {
|
||||||
|
let mut tracker = FinalizedBlockTracker::new(Some(20));
|
||||||
|
assert_eq!(tracker.update(Some(15)), None);
|
||||||
|
assert_eq!(tracker.last_finalized_block, Some(15));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_update_with_equal_finalized_block() {
|
||||||
|
let mut tracker = FinalizedBlockTracker::new(Some(20));
|
||||||
|
assert_eq!(tracker.update(Some(20)), None);
|
||||||
|
assert_eq!(tracker.last_finalized_block, Some(20));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_update_with_no_last_finalized_block() {
|
||||||
|
let mut tracker = FinalizedBlockTracker::new(None);
|
||||||
|
assert_eq!(tracker.update(Some(10)), Some(10));
|
||||||
|
assert_eq!(tracker.last_finalized_block, Some(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_update_with_no_new_finalized_block() {
|
||||||
|
let mut tracker = FinalizedBlockTracker::new(Some(10));
|
||||||
|
assert_eq!(tracker.update(None), None);
|
||||||
|
assert_eq!(tracker.last_finalized_block, Some(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_update_with_no_finalized_blocks() {
|
||||||
|
let mut tracker = FinalizedBlockTracker::new(None);
|
||||||
|
assert_eq!(tracker.update(None), None);
|
||||||
|
assert_eq!(tracker.last_finalized_block, None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user