mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-23 12:09:52 +00:00
4b93dbec4c
Some checks failed
CI / fmt (push) Waiting to run
CI / typo (push) Waiting to run
CI / ci (macos-latest, stable, bash) (push) Waiting to run
CI / ci (ubuntu-latest, stable, bash) (push) Waiting to run
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Waiting to run
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled
* rename all directories and crates * fix all `use` * fix doc link * `dandelion/` -> `dandelion-tower/` * fix epee-encoding test * fix `json-rpc` * fix pruning * crate import fixes * fix leftover merge conflicts * fix `epee-encoding`
37 lines
801 B
Rust
37 lines
801 B
Rust
use futures::{FutureExt, StreamExt};
|
|
|
|
use cuprate_async_buffer::new_buffer;
|
|
|
|
#[tokio::test]
|
|
async fn async_buffer_send_rec() {
|
|
let (mut tx, mut rx) = new_buffer(1000);
|
|
|
|
tx.send(4, 5).await.unwrap();
|
|
tx.send(8, 5).await.unwrap();
|
|
|
|
assert_eq!(rx.next().await.unwrap(), 4);
|
|
assert_eq!(rx.next().await.unwrap(), 8);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn capacity_reached() {
|
|
let (mut tx, mut rx) = new_buffer(1000);
|
|
|
|
tx.send(4, 1000).await.unwrap();
|
|
|
|
assert!(tx.ready(1).now_or_never().is_none());
|
|
|
|
let fut = tx.ready(1);
|
|
|
|
rx.next().await;
|
|
|
|
assert!(fut.now_or_never().is_some());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn single_item_over_capacity() {
|
|
let (mut tx, mut rx) = new_buffer(1000);
|
|
tx.send(4, 1_000_000).await.unwrap();
|
|
|
|
assert_eq!(rx.next().await.unwrap(), 4);
|
|
}
|