fn check_if_only_up_to_date_peers_are_live<D, C>(
    peer_set: &mut PeerSet<D, C>,
    harnesses: &mut Vec<ClientTestHarness>,
    minimum_version: Version,
) -> Result<(), TestCaseError>
where
    D: Discover<Key = SocketAddr, Service = LoadTrackedClient> + Unpin,
    D::Error: Into<BoxError>,
    C: ChainTip,
{
    // Force `poll_discover` to be called to process all discovered peers.
    let poll_result = peer_set.ready().now_or_never();
    let all_peers_are_outdated = harnesses
        .iter()
        .all(|harness| harness.version() < minimum_version);

    if all_peers_are_outdated {
        prop_assert!(matches!(poll_result, None));
    } else {
        prop_assert!(matches!(poll_result, Some(Ok(_))));
    }

    for harness in harnesses {
        let is_outdated = harness.version() < minimum_version;
        let is_connected = harness.wants_connection_heartbeats();

        prop_assert!(
            is_connected != is_outdated,
            "is_connected: {}, is_outdated: {}",
            is_connected,
            is_outdated,
        );
    }

    Ok(())
}
/// Check if only peers with up-to-date protocol versions are live.
///
/// This will poll the `peer_set` to allow it to drop outdated peers, and then check the peer
/// `harnesses` to assert that only up-to-date peers are kept by the `peer_set`.
Check if only peers with up-to-date protocol versions are live.
Check if only peers with up - to - date protocol versions are live .
fn check_if_only_up_to_date_peers_are_live<D, C>(
    peer_set: &mut PeerSet<D, C>,
    harnesses: &mut Vec<ClientTestHarness>,
    minimum_version: Version,
) -> Result<(), TestCaseError>
where
    D: Discover<Key = SocketAddr, Service = LoadTrackedClient> + Unpin,
    D::Error: Into<BoxError>,
    C: ChainTip,
{
    // Force `poll_discover` to be called to process all discovered peers.
    let poll_result = peer_set.ready().now_or_never();
    let all_peers_are_outdated = harnesses
        .iter()
        .all(|harness| harness.version() < minimum_version);
    if all_peers_are_outdated {
        prop_assert!(matches!(poll_result, None));
    } else {
        prop_assert!(matches!(poll_result, Some(Ok(_))));
    }
    for harness in harnesses {
        let is_outdated = harness.version() < minimum_version;
        let is_connected = harness.wants_connection_heartbeats();
        prop_assert!(
            is_connected != is_outdated,
            "is_connected: {}, is_outdated: {}",
            is_connected,
            is_outdated,
        );
    }
    Ok(())
}
fn check_if_only_up_to_date_peers_are_live < D , C > ( peer_set : & mut PeerSet < D , C > , harnesses : & mut Vec < ClientTestHarness > , minimum_version : Version , ) -> Result < ( ) , TestCaseError > where D : Discover < Key = SocketAddr , Service = LoadTrackedClient > + Unpin , D :: Error : Into < BoxError > , C : ChainTip , { // Force `poll_discover` to be called to process all discovered peers. let poll_result = peer_set . ready ( ) . now_or_never ( ) ; let all_peers_are_outdated = harnesses . iter ( ) . all ( | harness | harness . version ( ) < minimum_version ) ; if all_peers_are_outdated { prop_assert ! ( matches ( poll_result None ) ) ; } else { prop_assert ! ( matches ( poll_result Some ( Ok ( ) ) ) ) ; } for harness in harnesses { let is_outdated = harness . version ( ) < minimum_version ; let is_connected = harness . wants_connection_heartbeats ( ) ; prop_assert ! ( is_connected is_outdated " " is_connected is_outdated ) ; } Ok ( ( ) ) }
Check if only peers with up-to-date protocol versions are live.
Check if only peers with up - to - date protocol versions are live .
peer_set
&mut PeerSet<D, C>
harnesses
&mut Vec<ClientTestHarness>
minimum_version
Version