Skip to content

Commit

Permalink
Test state filter is keeping only state with highest block (#20)
Browse files Browse the repository at this point in the history
tests(heart): add test for state filter
  • Loading branch information
etienne-napoleone authored Aug 9, 2022
1 parent 540744c commit b5b920b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/heart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,39 @@ impl Heart {
}
}
}

#[cfg(test)]
mod tests {
use chrono::Utc;
use reqwest::Client;

use super::*;

#[test]
fn filter_state_keep_state_with_highest_block() {
let client = Client::new();
let heart = Heart::new(
"test".into(),
vec![],
client,
"https://test.com".into(),
vec![],
10,
);

let states = vec![10, 1000, 100]
.into_iter()
.map(|h| ClientState {
height: h,
jailed_until: Utc::now(),
tombstoned: false,
missed_blocks: 0,
})
.map(Ok)
.collect::<Vec<_>>();

let state = heart.freshest_state(states).unwrap();

assert_eq!(state.height, 1000)
}
}

0 comments on commit b5b920b

Please sign in to comment.