Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
minor: rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-markin committed Aug 24, 2023
1 parent cfb1912 commit 5879f61
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions client/network/sync/src/futures_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,50 +202,50 @@ mod tests {
.await;
}

#[test]
fn futures_stream_len_is_zsro_for_empty_stream() {
let (_tx, stream) = futures_stream::<BoxFuture<()>>("test", 100);
assert_eq!(stream.len_lower_bound(), 0);
}
#[test]
fn futures_stream_len_is_zero_for_empty_stream() {
let (_tx, stream) = futures_stream::<BoxFuture<()>>("test", 100);
assert_eq!(stream.len_lower_bound(), 0);
}

#[tokio::test]
#[tokio::test]
async fn futures_stream_len_counts_and_discounts_resolved_futures() {
let (tx, mut stream) = futures_stream("test", 100);
assert_eq!(stream.len_lower_bound(), 0);
assert_eq!(stream.len_lower_bound(), 0);

tx.push(futures::future::ready(17)).unwrap();
assert_eq!(stream.len_lower_bound(), 1);
tx.push(futures::future::ready(17)).unwrap();
assert_eq!(stream.len_lower_bound(), 1);

futures::future::poll_fn(|cx| {
assert_eq!(stream.poll_next_unpin(cx), Poll::Ready(Some(17)));
assert_eq!(stream.len_lower_bound(), 0);
assert_eq!(stream.len_lower_bound(), 0);

assert_eq!(stream.poll_next_unpin(cx), Poll::Pending);
assert_eq!(stream.len_lower_bound(), 0);
assert_eq!(stream.len_lower_bound(), 0);

Poll::Ready(())
})
.await;
}

#[tokio::test]
#[tokio::test]
async fn futures_stream_len_counts_taken_pending_futures() {
let (tx, mut stream) = futures_stream("test", 100);
assert_eq!(stream.len_lower_bound(), 0);
assert_eq!(stream.len_lower_bound(), 0);

tx.push(futures::future::pending::<()>()).unwrap();
tx.push(futures::future::pending::<()>()).unwrap();

// The future in the unbounded stream is counted.
assert_eq!(stream.len_lower_bound(), 1);
// The future in the unbounded stream is counted.
assert_eq!(stream.len_lower_bound(), 1);

// Poll once to move the future from unbounded stream into [`FuturesUnordered`].
// Poll once to move the future from unbounded stream into [`FuturesUnordered`].
futures::future::poll_fn(|cx| {
assert_eq!(stream.poll_next_unpin(cx), Poll::Pending);
Poll::Ready(())
})
.await;

// The future is still counted in [`FuturesUnordered`].
assert_eq!(stream.len_lower_bound(), 1);
// The future is still counted in [`FuturesUnordered`].
assert_eq!(stream.len_lower_bound(), 1);
}
}

0 comments on commit 5879f61

Please sign in to comment.