MCPcopy Create free account
hub / github.com/RustCrypto/utils / test_async_read

Function test_async_read

digest-io-async/tests/mod.rs:10–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9#[tokio::test]
10async fn test_async_read() {
11 let data = b"the quick brown fox jumps over the lazy dog".repeat(1000);
12
13 // Feed the stream chunk by chunk with an odd sized buffer.
14 let chunks = stream::iter(
15 data.chunks(37)
16 .map(|c| Ok::<_, std::io::Error>(Bytes::copy_from_slice(c)))
17 .collect::<Vec<_>>(),
18 );
19 let mut reader = HashReader::<Sha256, _>::new(StreamReader::new(chunks));
20 let mut sink = Vec::new();
21 tokio::io::copy(&mut reader, &mut sink).await.unwrap();
22
23 assert_eq!(sink, data);
24 assert_eq!(reader.finalize(), Sha256::digest(&data));
25}
26
27#[tokio::test]
28async fn test_async_write() {

Callers

nothing calls this directly

Calls 2

mapMethod · 0.80
unwrapMethod · 0.45

Tested by

no test coverage detected