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.
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.