Add proptest for future `last_seen` correction
Given a generated list of gossiped peers, ensure that after running the `validate_addrs` function none of the resulting peers have a `last_seen` time that's after the specified limit.
This commit is contained in:
parent
63672a2633
commit
83ac1519e9
|
|
@ -1,3 +1,4 @@
|
|||
//! [`CandidateSet`] tests.
|
||||
|
||||
mod prop;
|
||||
mod vectors;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
use proptest::{collection::vec, prelude::*};
|
||||
|
||||
use zebra_chain::serialization::DateTime32;
|
||||
|
||||
use super::super::validate_addrs;
|
||||
use crate::types::MetaAddr;
|
||||
|
||||
proptest! {
|
||||
/// Test that validated gossiped peers never have a `last_seen` time that's in the future.
|
||||
#[test]
|
||||
fn no_last_seen_times_are_in_the_future(
|
||||
gossiped_peers in vec(MetaAddr::gossiped_strategy(), 1..10),
|
||||
last_seen_limit in any::<DateTime32>(),
|
||||
) {
|
||||
zebra_test::init();
|
||||
|
||||
let validated_peers = validate_addrs(gossiped_peers, last_seen_limit);
|
||||
|
||||
for peer in validated_peers {
|
||||
prop_assert![peer.get_last_seen() <= last_seen_limit];
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue