omnimesh 1.0.0

Zero-allocation mesh networking middleware for autonomous robot fleets, edge-AI swarms, and multi-agent systems
Documentation
//! Unit tests for MockTransport

#![allow(unused_imports)]

use crate::runtime::transport::mock::MockTransport;
use crate::runtime::transport::interface::Transport;
use crate::runtime::transport::common::TransportUtils;

#[test]
fn mock_transport_returns_sample_envelope() {
    use crate::envelope::Did;
    let routing = std::sync::Arc::new(crate::runtime::RoutingTable::new());
    let local_did = Did([0x42u8; 32]);
    let transport = MockTransport::new(routing).with_did(local_did);

    // Must send to the DID first so it appears in the inbox
    let mut sample = TransportUtils::sample_envelope();
    // Patch recipient to match local_did so it lands in the right inbox
    sample.header.recipient_did = local_did;
    transport.send(&sample).expect("send must succeed");

    let envelope = transport.receive().expect("should return envelope");
    assert_eq!(envelope.header.recipient_did, local_did);
}

#[test]
fn mock_transport_send_succeeds() {
    let transport = MockTransport::new(std::sync::Arc::new(crate::runtime::RoutingTable::new()));
    let envelope = TransportUtils::sample_envelope();

    let result = transport.send(&envelope);
    assert!(result.is_ok());
}

#[test]
fn mock_transport_kind_is_correct() {
    let transport = MockTransport::new(std::sync::Arc::new(crate::runtime::RoutingTable::new()));
    assert_eq!(transport.kind(), "mock transport");
}