Properly init tracing per test and reverse the filter to be exclusive

Tracing should be initialized by test and the `_guard` kept alive within the test.
Re-using this code in different tests does not really have any additional value.

Instead of specifying what messages we want to include, I went for a filter that excludes noise.
That way we get more useful logging.
pull/54/head
Daniel Karzel 4 years ago
parent 883a913f30
commit 1a2857af29

@ -12,12 +12,16 @@ use tempfile::tempdir;
use testcontainers::clients::Cli;
use uuid::Uuid;
use xmr_btc::{bitcoin, config::Config, cross_curve_dleq};
use tracing_subscriber::util::SubscriberInitExt as _;
/// Run the following tests with RUST_MIN_STACK=10000000
#[tokio::test]
async fn happy_path() {
init_tracing();
let _guard = tracing_subscriber::fmt()
.with_env_filter("trace,hyper=warn")
.set_default();
let cli = Cli::default();
let bitcoind = Bitcoind::new(&cli, "0.19.1").unwrap();
let _ = bitcoind.init(5).await;
@ -105,7 +109,11 @@ async fn happy_path() {
/// the encsig and fail to refund or redeem. Alice punishes.
#[tokio::test]
async fn alice_punishes_if_bob_never_acts_after_fund() {
init_tracing();
let _guard = tracing_subscriber::fmt()
.with_env_filter("trace,hyper=warn")
.set_default();
let cli = Cli::default();
let bitcoind = Bitcoind::new(&cli, "0.19.1").unwrap();
let _ = bitcoind.init(5).await;
@ -306,11 +314,3 @@ async fn init_bob(
(bob_state, bob_swarm, bob_btc_wallet, bob_xmr_wallet, bob_db)
}
fn init_tracing() {
use tracing_subscriber::util::SubscriberInitExt as _;
let _guard = tracing_subscriber::fmt()
.with_env_filter("swap=info,xmr_btc=info")
.with_ansi(false)
.set_default();
}

Loading…
Cancel
Save