refactor: remove dead test helpers, fix constant placement

Remove unused get_srtt_ms() and saturated_penalty_cache() left over
from SRTT test rewrite. Move QUAD9_IP/DOH_FALLBACK after use block.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Razvan Dimescu
2026-04-01 14:36:15 +03:00
parent 82c4491690
commit 4f279b5f29
2 changed files with 3 additions and 17 deletions

View File

@@ -14,15 +14,15 @@ use numa::ctx::{handle_query, ServerCtx};
use numa::forward::Upstream; use numa::forward::Upstream;
use numa::override_store::OverrideStore; use numa::override_store::OverrideStore;
use numa::query_log::QueryLog; use numa::query_log::QueryLog;
const QUAD9_IP: &str = "9.9.9.9";
const DOH_FALLBACK: &str = "https://9.9.9.9/dns-query";
use numa::service_store::ServiceStore; use numa::service_store::ServiceStore;
use numa::stats::ServerStats; use numa::stats::ServerStats;
use numa::system_dns::{ use numa::system_dns::{
discover_system_dns, install_service, restart_service, service_status, uninstall_service, discover_system_dns, install_service, restart_service, service_status, uninstall_service,
}; };
const QUAD9_IP: &str = "9.9.9.9";
const DOH_FALLBACK: &str = "https://9.9.9.9/dns-query";
#[tokio::main] #[tokio::main]
async fn main() -> numa::Result<()> { async fn main() -> numa::Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")) env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))

View File

@@ -119,11 +119,6 @@ impl SrttCache {
self.entries.is_empty() self.entries.is_empty()
} }
#[cfg(test)]
fn get_srtt_ms(&self, ip: IpAddr) -> u64 {
self.entries.get(&ip).map(|e| e.srtt_ms).unwrap_or(0)
}
fn maybe_evict(&mut self) { fn maybe_evict(&mut self) {
if self.entries.len() < MAX_ENTRIES { if self.entries.len() < MAX_ENTRIES {
return; return;
@@ -219,15 +214,6 @@ mod tests {
assert_eq!(addrs, original); assert_eq!(addrs, original);
} }
/// Cache with ip(1) saturated at FAILURE_PENALTY_MS
fn saturated_penalty_cache() -> SrttCache {
let mut cache = SrttCache::new(true);
for _ in 0..30 {
cache.record_rtt(ip(1), FAILURE_PENALTY_MS, false);
}
cache
}
#[test] #[test]
fn no_decay_within_threshold() { fn no_decay_within_threshold() {
// At exactly DECAY_AFTER_SECS, no decay applied // At exactly DECAY_AFTER_SECS, no decay applied