pub struct MockNetwork { /* private fields */ }Expand description
Simulated network between mock nodes. Routes messages and can inject faults (partitions, latency, drops).
Implementations§
Source§impl MockNetwork
impl MockNetwork
pub fn new() -> Self
Sourcepub fn partition(&self, a: &NodeId, b: &NodeId)
pub fn partition(&self, a: &NodeId, b: &NodeId)
Partition two nodes — block all messages between them.
Sourcepub fn remove_partition(&self, a: &NodeId, b: &NodeId)
pub fn remove_partition(&self, a: &NodeId, b: &NodeId)
Remove a partition between two nodes, restoring connectivity.
Sourcepub fn is_partitioned(&self, a: &NodeId, b: &NodeId) -> bool
pub fn is_partitioned(&self, a: &NodeId, b: &NodeId) -> bool
Check if two nodes are partitioned.
Sourcepub fn delivered_count(&self) -> u64
pub fn delivered_count(&self) -> u64
Total messages delivered.
Sourcepub fn dropped_count(&self) -> u64
pub fn dropped_count(&self) -> u64
Total messages dropped (due to partitions, etc).
Sourcepub fn can_deliver(&self, src: &NodeId, dst: &NodeId) -> bool
pub fn can_deliver(&self, src: &NodeId, dst: &NodeId) -> bool
Check if a message from src to dst should be delivered. Returns false if nodes are partitioned.
Sourcepub fn record_delivered(&self)
pub fn record_delivered(&self)
Record a successful delivery.
Sourcepub fn record_dropped(&self)
pub fn record_dropped(&self)
Record a dropped message.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MockNetwork
impl RefUnwindSafe for MockNetwork
impl Send for MockNetwork
impl Sync for MockNetwork
impl Unpin for MockNetwork
impl UnsafeUnpin for MockNetwork
impl UnwindSafe for MockNetwork
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more