aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-13 14:00:01 +0000
committertv <tv@krebsco.de>2026-11-13 14:00:01 +0000
commitb9401540677cd35e7bc3a24f3d8ecb0aae3e6045 (patch)
treed8bee75f0290791c44f575d093cda59ecfb8104e /src
parent369cfb6a110ed384f18792ccd13a50f7cf27559a (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/transport/libp2p/tests.rs10
1 files changed, 10 insertions, 0 deletions
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<Multiaddr>,
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();