mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-12 01:21:21 +00:00
test: introduce libp2p-swarm-test
This patch-set introduces `libp2p-swarm-test`. It provides utilities for quick and safe bootstrapping of tests for `NetworkBehaviour`s. The main design features are: - Everything has timeouts - APIs don't get in your way - Minimal boilerplate Closes #2884. Pull-Request: #2888.
This commit is contained in:
@ -296,6 +296,17 @@ pub enum SwarmEvent<TBehaviourOutEvent, THandlerErr> {
|
||||
Dialing(PeerId),
|
||||
}
|
||||
|
||||
impl<TBehaviourOutEvent, THandlerErr> SwarmEvent<TBehaviourOutEvent, THandlerErr> {
|
||||
/// Extract the `TBehaviourOutEvent` from this [`SwarmEvent`] in case it is the `Behaviour` variant, otherwise fail.
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn try_into_behaviour_event(self) -> Result<TBehaviourOutEvent, Self> {
|
||||
match self {
|
||||
SwarmEvent::Behaviour(inner) => Ok(inner),
|
||||
other => Err(other),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Contains the state of the network, plus the way it should behave.
|
||||
///
|
||||
/// Note: Needs to be polled via `<Swarm as Stream>` in order to make
|
||||
|
Reference in New Issue
Block a user