pub use hopr_types::{internal::routing::PathId, primitive::bounded::BoundedVec};
pub use libp2p_identity::PeerId;

/// Network health represented with colors, where green is the best and red
/// is the worst possible observed network quality.
///
/// The assignment of the color spectrum is the responsibility of the implementation
/// of the [`crate::network::traits::NetworkView`] trait.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, strum::Display, strum::EnumString, strum::EnumIter)]
pub enum Health {
    /// Unknown health, on application startup
    Unknown = 0,
    /// No connection, default
    Red = 1,
    /// Low-quality connection to at least 1 public relay
    Orange = 2,
    /// High-quality connection to at least 1 public relay
    Yellow = 3,
    /// High-quality connection to at least 1 public relay and 1 NAT node
    Green = 4,
}

/// Events generated by the network for external consumption.
///
/// May or may not be ignored by the implementation.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum NetworkEvent {
    /// A peer has been connected to.
    PeerConnected(PeerId),
    /// A peer has been disconnected from.
    PeerDisconnected(PeerId),
}

#[cfg(test)]
mod tests {
    use insta::assert_debug_snapshot;
    use strum::IntoEnumIterator;

    use super::Health;

    #[test]
    fn network_health_should_be_representable_numerically_and_ordered() {
        assert_debug_snapshot!(Health::iter().map(|v| v as i32).collect::<Vec::<_>>());
    }

    #[test]
    fn network_health_should_serialize_to_and_deserialize_from_a_proper_string() {
        assert_debug_snapshot!(Health::iter().collect::<Vec::<_>>());
    }
}
