Trait network::testutils::test_node::TestNode [−][src]
pub trait TestNode: ApplicationNode + Sync {
fn peer_network_id(&self, network_id: NetworkId) -> PeerNetworkId { ... }
fn network_ids(&self) -> Vec<NetworkId> { ... }
fn connect(&self, network_id: NetworkId, metadata: ConnectionMetadata) { ... }
fn connect_self(&self, network_id: NetworkId, metadata: ConnectionMetadata) { ... }
fn disconnect(&self, network_id: NetworkId, metadata: ConnectionMetadata) { ... }
fn disconnect_self(
&self,
network_id: NetworkId,
metadata: ConnectionMetadata
) { ... }
fn find_common_network(&self, other: &Self) -> Option<NetworkId> { ... }
fn conn_metadata(
&self,
network_id: NetworkId,
origin: ConnectionOrigin,
protocol_ids: &[ProtocolId]
) -> ConnectionMetadata { ... }
fn get_next_network_msg<'life0, 'async_trait>(
&'life0 mut self,
network_id: NetworkId
) -> Pin<Box<dyn Future<Output = PeerManagerRequest> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: Send + 'async_trait,
{ ... }
fn wait_for_no_msg<'life0, 'async_trait>(
&'life0 mut self,
network_id: NetworkId,
timeout: Duration
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: Send + 'async_trait,
{ ... }
fn drop_next_network_msg<'life0, 'async_trait>(
&'life0 mut self,
network_id: NetworkId
) -> Pin<Box<dyn Future<Output = (PeerId, ProtocolId, Bytes)> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: Send + 'async_trait,
{ ... }
fn send_next_network_msg<'life0, 'async_trait>(
&'life0 mut self,
network_id: NetworkId
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: Send + 'async_trait,
{ ... }
}Expand description
An extension trait for an ApplicationNode to run tests on.
Handles common implementation and helper functions
Provided methods
fn peer_network_id(&self, network_id: NetworkId) -> PeerNetworkId
fn peer_network_id(&self, network_id: NetworkId) -> PeerNetworkId
Retrieve the PeerNetworkId for a specific NetworkId.
There can only be one per network.
fn network_ids(&self) -> Vec<NetworkId>
fn network_ids(&self) -> Vec<NetworkId>
Retrieve all NetworkId for the node
fn connect(&self, network_id: NetworkId, metadata: ConnectionMetadata)
fn connect(&self, network_id: NetworkId, metadata: ConnectionMetadata)
Connects a node to another node. The other’s inbound handle must already be added.
fn connect_self(&self, network_id: NetworkId, metadata: ConnectionMetadata)
fn connect_self(&self, network_id: NetworkId, metadata: ConnectionMetadata)
Connects only the local side, useful for mocking the other node
fn disconnect(&self, network_id: NetworkId, metadata: ConnectionMetadata)
fn disconnect(&self, network_id: NetworkId, metadata: ConnectionMetadata)
Disconnects a node from another node
fn disconnect_self(&self, network_id: NetworkId, metadata: ConnectionMetadata)
fn disconnect_self(&self, network_id: NetworkId, metadata: ConnectionMetadata)
Disconnects only the local side, useful for mocking the other node
fn find_common_network(&self, other: &Self) -> Option<NetworkId>
fn find_common_network(&self, other: &Self) -> Option<NetworkId>
fn conn_metadata(
&self,
network_id: NetworkId,
origin: ConnectionOrigin,
protocol_ids: &[ProtocolId]
) -> ConnectionMetadata
fn conn_metadata(
&self,
network_id: NetworkId,
origin: ConnectionOrigin,
protocol_ids: &[ProtocolId]
) -> ConnectionMetadata
Build ConnectionMetadata for a connection on another node
fn get_next_network_msg<'life0, 'async_trait>(
&'life0 mut self,
network_id: NetworkId
) -> Pin<Box<dyn Future<Output = PeerManagerRequest> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Send + 'async_trait,
fn get_next_network_msg<'life0, 'async_trait>(
&'life0 mut self,
network_id: NetworkId
) -> Pin<Box<dyn Future<Output = PeerManagerRequest> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Send + 'async_trait,
Gets the next queued network message on Node’s network NetworkId. Doesn’t propagate
to downstream node. If dropping a message use TestNode::drop_next_network_msg
Confirms no message is sent in the period of time
Drop a network message. This is required over [TestNode::get_network_msg] because the
oneshot channel must be dropped.