pharos-server 0.1.0

Listeners, Plugin Chain contract and metrics for the Pharos DNS server
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#![forbid(unsafe_code)]

use pharos_server::{Error, Outcome, contain_panic, panics_total};

#[tokio::test]
async fn panic_is_contained_and_debug_propagates() {
    let before = panics_total();
    let outcome = contain_panic(async { panic!("plugin panic") }, false).await;
    assert_eq!(outcome, Outcome::Error(Error::PluginPanic));
    assert_eq!(panics_total(), before + 1);
    let result = tokio::spawn(contain_panic(async { panic!("debug panic") }, true)).await;
    assert!(result.unwrap_err().is_panic());
    assert_eq!(panics_total(), before + 1);
}