Skip to main content

Module mesh_test_support

Module mesh_test_support 

Source
Expand description

Multi-node mesh test fixtures (WEFT-112). Available outside cfg(test) so downstream crates and integration tests can construct in-memory meshes. Multi-node mesh test fixtures (WEFT-112).

Provides in-process transport and peer mocks so K6 integration tests do not need real TCP/QUIC sockets.

§Fixtures

TypeRole
InMemoryTransportMeshTransport over tokio channels (mem:// URLs)
FaultyTransportWraps in-memory transport with drop/fail injection
MockPeerLightweight simulated mesh node with inbox
MockClockDeterministic clock (re-export of crate::mesh_clock::MockClock)

§Downstream authors

ⓘ
use clawft_kernel::mesh_test_support::{
    connected_pair, FaultyTransport, InMemoryTransport, MockClock, MockPeer,
};

#[tokio::test]
async fn two_node_exchange() {
    let (mut a, mut b) = connected_pair().await.unwrap();
    a.send(b"hello").await.unwrap();
    assert_eq!(b.recv().await.unwrap(), b"hello");
}

Prefer mem://node-a style addresses. Share one InMemoryTransport (or clone via InMemoryTransport::clone) across peers so listen/connect meet in the same registry.

Re-exports§

pub use crate::mesh_clock::Clock;
pub use crate::mesh_clock::MockClock;
pub use crate::mesh_clock::RealClock;

Structs§

FaultyTransport
Fault-injection wrapper around InMemoryTransport.
InMemoryListener
Listener that yields accepted in-memory streams.
InMemoryStream
Bidirectional in-memory byte stream (tokio channels).
InMemoryTransport
Shared registry for in-memory mem:// endpoints.
MockPeer
Lightweight simulated mesh node for multi-node tests.

Functions§

connected_pair
Create a connected pair of in-memory streams (no peers).
two_node_streams
Two mock peers sharing a fabric, with an established stream pair.