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 17 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 poll_until_connected(&mut self, cx: &mut FutureContext<'_>) -> Poll<()> { ... } 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 poll_until_connected(&mut self, cx: &mut FutureContext<'_>) -> Poll<()>

Polls the testnet until all peers are connected to each other.

Must be executed in a task context.

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.

Calls poll_until_connected repeatedly with the runtime passed as parameter.

source

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

Polls the testnet. Processes all the pending actions.

Implementors§