referrerpolicy=no-referrer-when-downgrade
sc_network_test

Trait TestNetFactory

Source
pub trait TestNetFactory:
    Default
    + Sized
    + Send {
    type Verifier: 'static + Verifier<Block>;
    type BlockImport: BlockImport<Block, Error = ConsensusError> + Clone + Send + Sync + 'static;
    type PeerData: Default + Send;

Show 16 methods // Required methods fn make_verifier( &self, client: PeersClient, peer_data: &Self::PeerData, ) -> Self::Verifier; fn peer(&mut self, i: usize) -> &mut Peer<Self::PeerData, Self::BlockImport>; fn peers(&self) -> &Vec<Peer<Self::PeerData, Self::BlockImport>>; fn peers_mut(&mut self) -> &mut Vec<Peer<Self::PeerData, Self::BlockImport>>; fn mut_peers<F: FnOnce(&mut Vec<Peer<Self::PeerData, Self::BlockImport>>)>( &mut self, closure: F, ); fn make_block_import( &self, client: PeersClient, ) -> (BlockImportAdapter<Self::BlockImport>, Option<BoxJustificationImport<Block>>, Self::PeerData); // Provided methods fn new(n: usize) -> Self { ... } fn add_full_peer(&mut self) { ... } fn add_full_peer_with_config(&mut self, config: FullPeerConfig) { ... } fn spawn_task(&self, f: BoxFuture<'static, ()>) { ... } fn is_in_sync<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn is_idle<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn run_until_sync<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn run_until_idle<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn run_until_connected<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn poll(&mut self, cx: &mut FutureContext<'_>) { ... }
}

Required Associated Types§

Required Methods§

Source

fn make_verifier( &self, client: PeersClient, peer_data: &Self::PeerData, ) -> Self::Verifier

This one needs to be implemented!

Source

fn peer(&mut self, i: usize) -> &mut Peer<Self::PeerData, Self::BlockImport>

Get reference to peer.

Source

fn peers(&self) -> &Vec<Peer<Self::PeerData, Self::BlockImport>>

Source

fn peers_mut(&mut self) -> &mut Vec<Peer<Self::PeerData, Self::BlockImport>>

Source

fn mut_peers<F: FnOnce(&mut Vec<Peer<Self::PeerData, Self::BlockImport>>)>( &mut self, closure: F, )

Source

fn make_block_import( &self, client: PeersClient, ) -> (BlockImportAdapter<Self::BlockImport>, Option<BoxJustificationImport<Block>>, Self::PeerData)

Get custom block import handle for fresh client, along with peer data.

Provided Methods§

Source

fn new(n: usize) -> Self

Create new test network with this many peers.

Source

fn add_full_peer(&mut self)

Source

fn add_full_peer_with_config(&mut self, config: FullPeerConfig)

Add a full peer.

Source

fn spawn_task(&self, f: BoxFuture<'static, ()>)

Used to spawn background tasks, e.g. the block request protocol handler.

Source

fn is_in_sync<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn is_idle<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn run_until_sync<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Blocks the current thread until we are sync’ed. Wait until we are sync’ed.

(If we’ve not synced within 10 mins then panic rather than hang.)

Source

fn run_until_idle<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run the network until there are no pending packets.

Calls poll_until_idle repeatedly with the runtime passed as parameter.

Source

fn run_until_connected<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run the network until all peers are connected to each other.

Source

fn poll(&mut self, cx: &mut FutureContext<'_>)

Polls the testnet. Processes all the pending actions.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§