pub use keetanetwork_block::Network;
#[derive(Debug, Clone, Copy)]
pub struct ValidationConfig {
pub allowed_slop_ms: i64,
pub permanent_vote_threshold_ms: i64,
}
impl ValidationConfig {
pub const DEFAULT_SLOP_MS: i64 = 60 * 1000;
pub const DEFAULT_PERMANENT_THRESHOLD_MS: i64 = 100 * 365 * 86_400 * 1000;
}
impl Default for ValidationConfig {
fn default() -> Self {
Self {
allowed_slop_ms: Self::DEFAULT_SLOP_MS,
permanent_vote_threshold_ms: Self::DEFAULT_PERMANENT_THRESHOLD_MS,
}
}
}
impl From<Network> for ValidationConfig {
fn from(_network: Network) -> Self {
Self::default()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_defaults_match_reference_constants() {
let config = ValidationConfig::default();
assert_eq!(config.allowed_slop_ms, 60_000);
assert_eq!(config.permanent_vote_threshold_ms, 100i64 * 365 * 86_400 * 1000);
}
#[test]
fn test_from_network_uses_defaults() {
let config = ValidationConfig::from(Network::Test);
assert_eq!(config.allowed_slop_ms, ValidationConfig::DEFAULT_SLOP_MS);
assert_eq!(config.permanent_vote_threshold_ms, ValidationConfig::DEFAULT_PERMANENT_THRESHOLD_MS);
}
}