Skip to main content

Module testing

Module testing 

Source
Expand description

Testing utilities for choreographic protocols

This module provides building blocks for protocol testing, simulation, and integration with external simulators like aura-simulator.

§Overview

The testing module provides:

  • Deterministic execution: Clock and Rng traits for reproducible runs
  • State machines: ProtocolStateMachine for step-by-step execution
  • Transport abstraction: SimulatedTransport for custom message delivery
  • Event observation: ProtocolObserver for monitoring protocol execution
  • Message envelopes: ProtocolEnvelope for structured message passing

§Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Simulator / Test Harness                  │
└─────────────────────────────────────────────────────────────┘
                             │
          ┌──────────────────┼──────────────────┐
          │                  │                  │
          ▼                  ▼                  ▼
   ┌─────────────┐   ┌─────────────┐   ┌─────────────┐
   │   Clock     │   │    Rng      │   │  Observer   │
   │   Trait     │   │    Trait    │   │    Trait    │
   └─────────────┘   └─────────────┘   └─────────────┘
                             │
                             ▼
   ┌─────────────────────────────────────────────────────────┐
   │              ProtocolStateMachine                        │
   │  blocked_on() -> BlockedOn                               │
   │  step(input) -> StepOutput                               │
   │  checkpoint() / restore()                                │
   └─────────────────────────────────────────────────────────┘
                             │
                             ▼
   ┌─────────────────────────────────────────────────────────┐
   │              SimulatedTransport                          │
   │  send(to, envelope) -> Result                           │
   │  recv(from) -> Result<Envelope>                         │
   └─────────────────────────────────────────────────────────┘

Re-exports§

pub use clock::AsyncClock;
pub use envelope::ProtocolEnvelope;
pub use observer::NullObserver;
pub use observer::ProtocolObserver;
pub use observer::RecordingObserver;
pub use state_machine::BlockedOn;
pub use state_machine::Checkpoint;
pub use state_machine::ProtocolStateMachine;
pub use state_machine::StepInput;
pub use state_machine::StepOutput;
pub use transport::AsyncSimulatedTransport;
pub use transport::InMemoryTransport;
pub use transport::SimulatedTransport;
pub use transport::TransportError;

Modules§

clock
Clock and RNG traits for deterministic simulation.
envelope
Protocol message envelope for structured message passing
observer
Protocol observer trait for monitoring execution
state_machine
Protocol state machine for step-by-step simulation
transport
Simulated transport traits for protocol execution

Structs§

MockClock
Mock clock for deterministic testing.
SeededRng
Seeded RNG for reproducible randomness.

Traits§

Clock
Trait for monotonic time in protocol execution.
Rng
Trait for random number generation in protocol execution.
WallClock
Trait for wall-clock timestamps used in metadata.