pub struct MockPeer {
pub node_id: String,
pub address: String,
pub governance_genesis: [u8; 32],
pub handshake: WeftHandshake,
pub inbox: Arc<Mutex<Vec<Vec<u8>>>>,
/* private fields */
}Expand description
Lightweight simulated mesh node for multi-node tests.
Holds identity, handshake metadata, an optional shared transport, and an inbox of received raw frames / payloads for assertions.
Fields§
§node_id: StringNode identity string.
address: StringListen / dial address (mem://...).
governance_genesis: [u8; 32]Governance genesis for cluster isolation tests.
handshake: WeftHandshakeHandshake payload this peer would present.
inbox: Arc<Mutex<Vec<Vec<u8>>>>Received payloads (raw bytes).
Implementations§
Source§impl MockPeer
impl MockPeer
Sourcepub fn new(node_id: impl Into<String>, genesis: [u8; 32]) -> Self
pub fn new(node_id: impl Into<String>, genesis: [u8; 32]) -> Self
Create a peer with a fresh identity in the given cluster.
Sourcepub fn with_transport(self, transport: InMemoryTransport) -> Self
pub fn with_transport(self, transport: InMemoryTransport) -> Self
Attach a shared transport fabric (required for multi-peer meshes).
Sourcepub fn foreign_cluster(node_id: impl Into<String>) -> Self
pub fn foreign_cluster(node_id: impl Into<String>) -> Self
Peer that rejects foreign clusters (different genesis).
Sourcepub fn as_mesh_peer(&self) -> MeshPeer
pub fn as_mesh_peer(&self) -> MeshPeer
Build a MeshPeer view of this mock.
Sourcepub fn transport(&self) -> &InMemoryTransport
pub fn transport(&self) -> &InMemoryTransport
Shared transport handle.
Sourcepub fn push_inbox(&self, data: Vec<u8>)
pub fn push_inbox(&self, data: Vec<u8>)
Push a payload into the inbox (for tests that inject delivery).
Sourcepub fn inbox_snapshot(&self) -> Vec<Vec<u8>>
pub fn inbox_snapshot(&self) -> Vec<Vec<u8>>
Snapshot of inbox contents.
Sourcepub async fn listen_once(
&self,
) -> Result<(JoinHandle<()>, Receiver<()>), MeshError>
pub async fn listen_once( &self, ) -> Result<(JoinHandle<()>, Receiver<()>), MeshError>
Start accepting one connection and reading frames into the inbox.
Returns a oneshot that fires when the accept loop has bound the listener (so dialers can race-free connect).
Auto Trait Implementations§
impl Freeze for MockPeer
impl RefUnwindSafe for MockPeer
impl Send for MockPeer
impl Sync for MockPeer
impl Unpin for MockPeer
impl UnsafeUnpin for MockPeer
impl UnwindSafe for MockPeer
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more