Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(libp2p-swarm-test): Add #[track_caller] to SwarmExt methods #5567

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion swarm-test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
## 0.4.1

- Add `#[track_caller]` to `SwarmExt` methods

## 0.4.0

<!-- Update to libp2p-swarm v0.45.0 -->

## 0.3.0


## 0.2.0

- Raise MSRV to 1.65.
Expand Down
5 changes: 5 additions & 0 deletions swarm-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub trait SwarmExt {
/// This will take addresses from the `other` [`Swarm`] via [`Swarm::external_addresses`].
/// By default, this iterator will not yield any addresses.
/// To add listen addresses as external addresses, use [`ListenFuture::with_memory_addr_external`] or [`ListenFuture::with_tcp_addr_external`].
#[track_caller]
async fn connect<T>(&mut self, other: &mut Swarm<T>)
where
T: NetworkBehaviour + Send,
Expand All @@ -63,9 +64,11 @@ pub trait SwarmExt {
/// This function only abstracts away the "dial and wait for `ConnectionEstablished` event" part.
///
/// Because we don't have access to the other [`Swarm`], we can't guarantee that it makes progress.
#[track_caller]
async fn dial_and_wait(&mut self, addr: Multiaddr) -> PeerId;

/// Wait for specified condition to return `Some`.
#[track_caller]
async fn wait<E, P>(&mut self, predicate: P) -> E
where
P: Fn(SwarmEvent<<Self::NB as NetworkBehaviour>::ToSwarm>) -> Option<E>,
Expand All @@ -79,11 +82,13 @@ pub trait SwarmExt {
/// Returns the next [`SwarmEvent`] or times out after 10 seconds.
///
/// If the 10s timeout does not fit your usecase, please fall back to `StreamExt::next`.
#[track_caller]
async fn next_swarm_event(&mut self) -> SwarmEvent<<Self::NB as NetworkBehaviour>::ToSwarm>;

/// Returns the next behaviour event or times out after 10 seconds.
///
/// If the 10s timeout does not fit your usecase, please fall back to `StreamExt::next`.
#[track_caller]
async fn next_behaviour_event(&mut self) -> <Self::NB as NetworkBehaviour>::ToSwarm;

async fn loop_on_next(self);
Expand Down
Loading