Struct round_based::dev::AsyncSimulation [−][src]
pub struct AsyncSimulation<SM: StateMachine> { /* fields omitted */ }This is supported on crate feature
dev only.Expand description
Emulates running protocol between local parties using AsyncProtocol
Takes parties (every party is instance of StateMachine) and executes protocol between them.
Compared to Simulation, AsyncSimulation requires tokio runtime and introduces parallelism, so it’s more suitable for writing tests (whereas Simulation is more suitable for writing benchmarks).
Limitations
- Doesn’t log process of protocol execution (except for occurring non critical errors). Limited by ProtocolWatcher API (to be expanded).
Example
let results: Vec<Result<Party::Output, _>> = AsyncSimulation::new()
.add_party(Party::new(1, 3))
.add_party(Party::new(2, 3))
.add_party(Party::new(3, 3))
.run()
.await;Implementations
impl<SM> AsyncSimulation<SM> where
SM: StateMachine + Send + 'static,
SM::MessageBody: Send + Clone + Unpin + 'static,
SM::Err: Send + Debug,
SM::Output: Send,
impl<SM> AsyncSimulation<SM> where
SM: StateMachine + Send + 'static,
SM::MessageBody: Send + Clone + Unpin + 'static,
SM::Err: Send + Debug,
SM::Output: Send,
This is supported on crate feature async-runtime only.
This is supported on crate feature
async-runtime only.Creates new simulation
This is supported on crate feature async-runtime only.
This is supported on crate feature
async-runtime only.Adds protocol participant
This is supported on crate feature async-runtime only.
This is supported on crate feature
async-runtime only.Runs a simulation
Returns
Returns Vec of execution results. Every party is executed independently, simulation will continue until each party finish protocol (either with success or error).
It’s an error to call this method twice. In this case,
vec![Err(AsyncSimulationError::Exhausted); n] is returned