Refs #50
File: crates/charon-metrics/tests/ (new)
Problem
Existing tests verify exporter binds an HTTP listener and that typed helpers don't panic. No test:
- Records a counter/histogram observation
- Scrapes /metrics
- Asserts response contains expected # HELP, # TYPE, and metric lines per Prometheus text format
Without this, breakages in metrics crate version upgrade, label key changes, or histogram bucket ordering will only surface in production.
Fix
Add integration test in crates/charon-metrics/tests/scrape.rs:
#[tokio::test]
async fn scrape_returns_valid_prometheus_text() {
let cfg = MetricsConfig { enabled: true, bind: "127.0.0.1:0".to_string(), .. };
init(&cfg).await.unwrap();
record_block_observed("bnb");
let body = reqwest::get("http://127.0.0.1:<port>/metrics").await.unwrap().text().await.unwrap();
assert!(body.contains("# HELP charon_scanner_blocks_total"));
assert!(body.contains("charon_scanner_blocks_total{chain=\"bnb\"} 1"));
}
Refs #50
File: crates/charon-metrics/tests/ (new)
Problem
Existing tests verify exporter binds an HTTP listener and that typed helpers don't panic. No test:
Without this, breakages in metrics crate version upgrade, label key changes, or histogram bucket ordering will only surface in production.
Fix
Add integration test in crates/charon-metrics/tests/scrape.rs: