Struct round_based::dev::Simulation [−][src]
pub struct Simulation<P> {
pub parties: Vec<P>,
// some fields omitted
}This is supported on crate feature
dev only.Expand description
Emulates running protocol between local parties
Takes parties (every party is instance of StateMachine) and executes protocol between them. It logs whole process (changing state of party, receiving messages, etc.) in stdout.
Compared to AsyncSimulation, it’s lightweight (doesn’t require async runtime), and, more importantly, executes everything in straight order (sequently, without any parallelism). It makes this sumaltion more useful for writing benchmarks that detect performance regression.
Limitations
- No proper error handling. It should attach a context to returning error (like current round, what we was doing when error occurred, etc.). The only way to determine error context is to look at stdout and find out what happened from logs.
- Logs everything to stdout. No choice.
Example
let results = Simulation::new() .add_party(Party::new(1, 3)) .add_party(Party::new(2, 3)) .add_party(Party::new(3, 3)) .run()?; assert!(results.into_iter().all(|r| is_valid(&r)));
Fields
parties: Vec<P>Parties running a protocol
Field is exposed mainly to allow examining parties state after simulation is completed.
Implementations
Enables benchmarks so they can be retrieved after simulation is completed
impl<P> Simulation<P> where
P: StateMachine,
P: Debug,
P::Err: Debug,
P::MessageBody: Debug + Clone,
impl<P> Simulation<P> where
P: StateMachine,
P: Debug,
P::Err: Debug,
P::MessageBody: Debug + Clone, Auto Trait Implementations
impl<P> RefUnwindSafe for Simulation<P> where
P: RefUnwindSafe, impl<P> Send for Simulation<P> where
P: Send, impl<P> Sync for Simulation<P> where
P: Sync, impl<P> Unpin for Simulation<P> where
P: Unpin, impl<P> UnwindSafe for Simulation<P> where
P: UnwindSafe,