Skip to content

[TEST-02] network crate critically under-tested for transport-layer code #340

@intendednull

Description

@intendednull

Audit finding from #300 (commit 679f9fe)

Severity: high
Category: test coverage
File: crates/network (esp. iroh.rs with only 2 tests)
Obvious fix: no (requires real or harnessed iroh endpoints; some plumbing needed)

Description

The network crate is 1407 SLOC with only 18 tests, ratio 0.0128 — second-worst in the workspace. The breakdown is topics.rs:5, iroh.rs:2, mem.rs:11, meaning the real iroh-backed transport (the production path) has just 2 tests while the in-memory mock has 11. Most coverage is exercising the mock, not the wire.

Impact / Threat

Regressions in the production iroh path are unlikely to be caught at the crate level.

Suggested fix

Add tests for these named behaviors:

  1. iroh peer dial + handshake: spin up two in-process iroh endpoints, dial, exchange one message both ways, assert both peers see the connection-established event.
  2. Topic subscription fan-out: subscribe N peers to a topic, publish from one, assert all N receive exactly once and non-subscribers receive nothing.
  3. Reconnect / disconnect semantics: drop one side of an established connection, assert the surviving side observes a disconnect within a bounded time and that subsequent sends fail with a typed error rather than block.

Verify

rg -c '#\[(tokio::|wasm_bindgen_)?test\]' crates/network/
find crates/network/src -name '*.rs' | xargs wc -l | tail -1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions