test: add p2p end-to-end tests#464
Conversation
|
@claude review |
|
Claude finished @therustmonk's task in 4m 4s —— View job Claude PR Review
Overall: Solid additions. Both tests drive the full production Findings1.
Suggest adding an 2. Helper duplication between the two test files
3. Spawned relay task is fire-and-forget
4.
5. Test seeds 1/2 reused across both files
6.
7. Direct TCP test is asymmetric in setup but symmetric in assertion — that's good, but worth a note
8. Nit — comment accuracy
Things checked and look correct
|
emlautarom1
left a comment
There was a problem hiding this comment.
I would remove the tracing setup and logging: in tests we should avoid all logs to not clutter the output. If a test fails better to do so with a clear panic/assert that will actually fail the test suite. It's hard to know what to do with a warning (should it fail? does it need attention? is this expected?)
| /// Returns true if `addr` is a relayed (`/p2p-circuit`) address. | ||
| fn is_circuit_addr(addr: &Multiaddr) -> bool { | ||
| addr.iter() | ||
| .any(|proto| matches!(proto, Protocol::P2pCircuit)) | ||
| } |
| fn init_logs() { | ||
| let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn")); | ||
| let _ = tracing_subscriber::fmt() | ||
| .with_env_filter(filter) | ||
| .with_test_writer() | ||
| .try_init(); | ||
| } |
There was a problem hiding this comment.
I'm not sure we want to enable tracing in tests. It will generate a lot of noise that provides no value 99% of the time. If there is a regression then the test should fail loudly with an error so we can review it.
| /// Logs swarm events instead of silently dropping them: failures at `warn`, the | ||
| /// rest at `trace`. A rejected reservation or failed circuit dial then shows up | ||
| /// in the logs rather than as a bare timeout. | ||
| fn note_swarm_event<E: Debug>(label: &str, event: &SwarmEvent<E>) { |
There was a problem hiding this comment.
In this case, are any of these errors expected in any way? If they're not (they are all actual errors) then it should panic so we can get a better trace when debugging tests.
|
|
||
| use std::{fmt::Debug, time::Duration}; | ||
|
|
||
| use anyhow::{Context as _, ensure}; |
There was a problem hiding this comment.
nit: I think we can drop anyhow here and use expect/assert! instead for all scenarios
The networking layer had almost no automated coverage. The existing
frostp2p_integ_testuses a different path (Node::new_server+ custom behaviour for FROST); the normal client path and the relay circuit hop were untested.Two real-socket integration tests for the p2p layer:
direct_tcp_connection.rs— two real Pluto nodes connect directly over TCP and run the full productionPlutoBehaviour: connect both ways, exchangeidentify(Received), andping.relay_circuit.rs— two clients connect only through an in-process relay (reservation + relayed dial), never directly.Both log swarm errors at
warninstead of swallowing them, so failures show the real cause, not a bare timeout.