pub struct TestNode { /* private fields */ }Expand description
A simulated ELARA Protocol node for load testing
Implementations§
Source§impl TestNode
impl TestNode
Sourcepub fn spawn(config: NodeConfig) -> Result<Self, String>
pub fn spawn(config: NodeConfig) -> Result<Self, String>
Spawn a new test node with the given configuration
Sourcepub fn spawn_default() -> Result<Self, String>
pub fn spawn_default() -> Result<Self, String>
Spawn a new test node with default configuration
Sourcepub fn join_session(&mut self, session_id: SessionId, session_key: [u8; 32])
pub fn join_session(&mut self, session_id: SessionId, session_key: [u8; 32])
Join a session (required for message exchange)
Sourcepub fn join_session_unsecured(&mut self, session_id: SessionId)
pub fn join_session_unsecured(&mut self, session_id: SessionId)
Join a session without encryption (for testing)
Sourcepub fn connect_to(&mut self, peer: &TestNode) -> Result<(), String>
pub fn connect_to(&mut self, peer: &TestNode) -> Result<(), String>
Connect to another test node
Sourcepub fn send_message(&mut self, payload: Vec<u8>) -> Result<Instant, String>
pub fn send_message(&mut self, payload: Vec<u8>) -> Result<Instant, String>
Generate and send a test message
Returns the time taken to queue the message (for latency measurement)
Sourcepub fn receive_from(&mut self, peer: &mut TestNode) -> usize
pub fn receive_from(&mut self, peer: &mut TestNode) -> usize
Receive and process incoming frames from another node
Sourcepub fn messages_sent(&self) -> u64
pub fn messages_sent(&self) -> u64
Get the number of messages sent by this node
Sourcepub fn messages_received(&self) -> u64
pub fn messages_received(&self) -> u64
Get the number of messages received by this node
Auto Trait Implementations§
impl Freeze for TestNode
impl RefUnwindSafe for TestNode
impl Send for TestNode
impl Sync for TestNode
impl Unpin for TestNode
impl UnsafeUnpin for TestNode
impl UnwindSafe for TestNode
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
Converts
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>
Converts
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request