Add tests for SyncState::get_scan_range method

This commit is contained in:
silverpill 2022-07-28 11:16:32 +00:00
parent 67c6b76bcb
commit c47822ff53

View file

@ -114,3 +114,38 @@ impl SyncState {
Ok(()) Ok(())
} }
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_scan_range_from_zero() {
let address = Address::default();
let sync_state = SyncState::new(
0,
vec![address.clone()],
100,
10,
Path::new("test"),
);
let (from_block, to_block) = sync_state.get_scan_range(&address);
assert_eq!(from_block, 0);
assert_eq!(to_block, 100);
}
#[test]
fn test_get_scan_range() {
let address = Address::default();
let sync_state = SyncState::new(
500,
vec![address.clone()],
100,
10,
Path::new("test"),
);
let (from_block, to_block) = sync_state.get_scan_range(&address);
assert_eq!(from_block, 490);
assert_eq!(to_block, 590);
}
}