From b9401540677cd35e7bc3a24f3d8ecb0aae3e6045 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 14:00:01 +0000 Subject: libp2p tests log as RUST_LOG says Nothing installs a subscriber in the transport's tests: RUST_LOG gave no output there, where a transient failure needs it. The first node a test run makes installs one, writing into the test's output, which is shown where a test fails. --- src/transport/libp2p/tests.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/transport/libp2p/tests.rs') diff --git a/src/transport/libp2p/tests.rs b/src/transport/libp2p/tests.rs index 5d08190..3ecd67a 100644 --- a/src/transport/libp2p/tests.rs +++ b/src/transport/libp2p/tests.rs @@ -7,6 +7,15 @@ use crate::transport::{HeadsSummary, Status}; /// Memory ports are process-wide. static NEXT_PORT: AtomicU64 = AtomicU64::new(40_000); +/// Logs as `RUST_LOG` says, into the test's output (shown where it fails); the first +/// node of a test run installs it. +fn logs() { + let _ = tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .with_test_writer() + .try_init(); +} + /// A node on the in-memory transport, listening on a port of its own (or nowhere), /// and its address with its peer ID (or just its peer ID). fn memory_node_with( @@ -14,6 +23,7 @@ fn memory_node_with( relays: Vec, relay: bool, ) -> (Libp2pTransport, Multiaddr) { + logs(); let port = NEXT_PORT.fetch_add(1, Ordering::Relaxed); let key = Keypair::generate_ed25519(); let address: Multiaddr = format!("/memory/{port}").parse().unwrap(); -- cgit v1.3.1