Trait sc_network_test::TestNetFactory [−][src]
pub trait TestNetFactory: Sized where
<Self::BlockImport as BlockImport<Block>>::Transaction: Send, { type Verifier: 'static + Verifier<Block>; type BlockImport: BlockImport<Block, Error = ConsensusError> + Clone + Send + Sync + 'static; type PeerData: Default;}Show methods
fn from_config(config: &ProtocolConfig) -> Self; fn make_verifier(
&self,
client: PeersClient,
config: &ProtocolConfig,
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 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); fn default_config() -> ProtocolConfig { ... } fn new(n: usize) -> Self { ... } fn add_full_peer(&mut self) { ... } fn add_full_peer_with_config(&mut self, config: FullPeerConfig) { ... } fn add_light_peer(&mut self) { ... } fn spawn_task(&self, f: BoxFuture<'static, ()>) { ... } fn poll_until_sync(&mut self, cx: &mut FutureContext<'_>) -> Poll<()> { ... } fn poll_until_idle(&mut self, cx: &mut FutureContext<'_>) -> Poll<()> { ... } fn poll_until_connected(&mut self, cx: &mut FutureContext<'_>) -> Poll<()> { ... } fn block_until_sync(&mut self) { ... } fn block_until_idle(&mut self) { ... } fn block_until_connected(&mut self) { ... } fn poll(&mut self, cx: &mut FutureContext<'_>) { ... }
Associated Types
type BlockImport: BlockImport<Block, Error = ConsensusError> + Clone + Send + Sync + 'static
Required methods
fn from_config(config: &ProtocolConfig) -> Self
fn from_config(config: &ProtocolConfig) -> Self
These two need to be implemented!
fn make_verifier(
&self,
client: PeersClient,
config: &ProtocolConfig,
peer_data: &Self::PeerData
) -> Self::Verifier
Get reference to peer.
fn 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 default_config() -> ProtocolConfig
fn add_full_peer(&mut self)
fn add_full_peer_with_config(&mut self, config: FullPeerConfig)
fn add_full_peer_with_config(&mut self, config: FullPeerConfig)
Add a full peer.
fn add_light_peer(&mut self)
fn add_light_peer(&mut self)
Add a light peer.
fn 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 poll_until_sync(&mut self, cx: &mut FutureContext<'_>) -> Poll<()>
fn poll_until_sync(&mut self, cx: &mut FutureContext<'_>) -> Poll<()>
Polls the testnet until all nodes are in sync.
Must be executed in a task context.
fn poll_until_idle(&mut self, cx: &mut FutureContext<'_>) -> Poll<()>
fn poll_until_idle(&mut self, cx: &mut FutureContext<'_>) -> Poll<()>
Polls the testnet until theres’ no activiy of any kind.
Must be executed in a task context.
fn poll_until_connected(&mut self, cx: &mut FutureContext<'_>) -> Poll<()>
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.
fn block_until_sync(&mut self)
fn block_until_sync(&mut self)
Blocks the current thread until we are sync’ed.
Calls poll_until_sync
repeatedly.
fn block_until_idle(&mut self)
fn block_until_idle(&mut self)
Blocks the current thread until there are no pending packets.
Calls poll_until_idle
repeatedly with the runtime passed as parameter.
fn block_until_connected(&mut self)
fn block_until_connected(&mut self)
Blocks the current thread until all peers are connected to each other.
Calls poll_until_connected
repeatedly with the runtime passed as parameter.
fn poll(&mut self, cx: &mut FutureContext<'_>)
fn poll(&mut self, cx: &mut FutureContext<'_>)
Polls the testnet. Processes all the pending actions.