Trait sc_network_test::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§
type Verifier: 'static + Verifier<Block>
type BlockImport: BlockImport<Block, Error = ConsensusError> + Clone + Send + Sync + 'static
type PeerData: Default + Send
Required Methods§
sourcefn make_verifier(
&self,
client: PeersClient,
peer_data: &Self::PeerData,
) -> Self::Verifier
fn make_verifier( &self, client: PeersClient, peer_data: &Self::PeerData, ) -> Self::Verifier
This one needs to be implemented!
sourcefn peer(&mut self, i: usize) -> &mut Peer<Self::PeerData, Self::BlockImport>
fn peer(&mut self, i: usize) -> &mut Peer<Self::PeerData, Self::BlockImport>
Get reference to peer.
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, )
sourcefn make_block_import(
&self,
client: PeersClient,
) -> (BlockImportAdapter<Self::BlockImport>, Option<BoxJustificationImport<Block>>, Self::PeerData)
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§
fn add_full_peer(&mut self)
sourcefn add_full_peer_with_config(&mut self, config: FullPeerConfig)
fn add_full_peer_with_config(&mut self, config: FullPeerConfig)
Add a full peer.
sourcefn spawn_task(&self, f: BoxFuture<'static, ()>)
fn spawn_task(&self, f: BoxFuture<'static, ()>)
Used to spawn background tasks, e.g. the block request protocol handler.
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,
sourcefn 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_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.)
sourcefn 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_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.
sourcefn 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 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.
sourcefn poll(&mut self, cx: &mut FutureContext<'_>)
fn poll(&mut self, cx: &mut FutureContext<'_>)
Polls the testnet. Processes all the pending actions.
Object Safety§
This trait is not object safe.