use type inference
This commit is contained in:
parent
63ae085945
commit
9db936923b
|
|
@ -106,10 +106,9 @@ fn install_tracing() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn sign_and_verify<V>(mut verifier: V, n: usize)
|
async fn sign_and_verify<V>(mut verifier: V, n: usize) -> Result<(), V::Error>
|
||||||
where
|
where
|
||||||
V: Service<Ed25519Item, Response = ()>,
|
V: Service<Ed25519Item, Response = ()>,
|
||||||
<V as Service<Ed25519Item>>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
|
|
||||||
{
|
{
|
||||||
let mut results = FuturesUnordered::new();
|
let mut results = FuturesUnordered::new();
|
||||||
for i in 0..n {
|
for i in 0..n {
|
||||||
|
|
@ -119,15 +118,15 @@ where
|
||||||
let msg = b"BatchVerifyTest";
|
let msg = b"BatchVerifyTest";
|
||||||
let sig = sk.sign(&msg[..]);
|
let sig = sk.sign(&msg[..]);
|
||||||
|
|
||||||
verifier.ready_and().await.map_err(|e| e.into()).unwrap();
|
verifier.ready_and().await?;
|
||||||
results.push(span.in_scope(|| verifier.call((vk_bytes, sig, msg).into())))
|
results.push(span.in_scope(|| verifier.call((vk_bytes, sig, msg).into())))
|
||||||
}
|
}
|
||||||
|
|
||||||
while let Some(result) = results.next().await {
|
while let Some(result) = results.next().await {
|
||||||
let result = result.map_err(|e| e.into());
|
result?;
|
||||||
tracing::trace!(?result);
|
|
||||||
assert!(result.is_ok());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|
@ -137,12 +136,8 @@ async fn batch_flushes_on_max_items() -> color_eyre::Result<()> {
|
||||||
|
|
||||||
// Use a very long max_latency and a short timeout to check that
|
// Use a very long max_latency and a short timeout to check that
|
||||||
// flushing is happening based on hitting max_items.
|
// flushing is happening based on hitting max_items.
|
||||||
let verifier = Batch::<_, _, color_eyre::Report>::new(
|
let verifier = Batch::new(Ed25519Verifier::new(), 10, Duration::from_secs(1000));
|
||||||
Ed25519Verifier::new(),
|
timeout(Duration::from_secs(1), sign_and_verify(verifier, 100)).await?
|
||||||
10,
|
|
||||||
Duration::from_secs(1000),
|
|
||||||
);
|
|
||||||
Ok(timeout(Duration::from_secs(1), sign_and_verify(verifier, 100)).await?)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|
@ -152,10 +147,6 @@ async fn batch_flushes_on_max_latency() -> color_eyre::Result<()> {
|
||||||
|
|
||||||
// Use a very high max_items and a short timeout to check that
|
// Use a very high max_items and a short timeout to check that
|
||||||
// flushing is happening based on hitting max_latency.
|
// flushing is happening based on hitting max_latency.
|
||||||
let verifier = Batch::<_, _, color_eyre::Report>::new(
|
let verifier = Batch::new(Ed25519Verifier::new(), 100, Duration::from_millis(500));
|
||||||
Ed25519Verifier::new(),
|
timeout(Duration::from_secs(1), sign_and_verify(verifier, 10)).await?
|
||||||
100,
|
|
||||||
Duration::from_millis(500),
|
|
||||||
);
|
|
||||||
Ok(timeout(Duration::from_secs(1), sign_and_verify(verifier, 10)).await?)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue