Fix intermittent errors in the groth16 verifier tests (#2412)

This commit is contained in:
teor 2021-06-29 12:48:50 +10:00 committed by GitHub
parent 9cb7ee4d0e
commit 9d2d8c8215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 7 deletions

View File

@ -61,9 +61,31 @@ where
#[tokio::test]
async fn verify_sapling_groth16() {
// Since we expect these to pass, we can use the communal verifiers.
let mut spend_verifier = groth16::SPEND_VERIFIER.clone();
let mut output_verifier = groth16::OUTPUT_VERIFIER.clone();
// Use separate verifiers so shared batch tasks aren't killed when the test ends (#2390)
let mut spend_verifier = Fallback::new(
Batch::new(
Verifier::new(&PARAMS.sapling.spend.vk),
crate::primitives::MAX_BATCH_SIZE,
crate::primitives::MAX_BATCH_LATENCY,
),
tower::service_fn(
(|item: Item| {
ready(item.verify_single(&prepare_verifying_key(&PARAMS.sapling.spend.vk)))
}) as fn(_) -> _,
),
);
let mut output_verifier = Fallback::new(
Batch::new(
Verifier::new(&PARAMS.sapling.output.vk),
crate::primitives::MAX_BATCH_SIZE,
crate::primitives::MAX_BATCH_LATENCY,
),
tower::service_fn(
(|item: Item| {
ready(item.verify_single(&prepare_verifying_key(&PARAMS.sapling.output.vk)))
}) as fn(_) -> _,
),
);
let transactions = zebra_test::vectors::MAINNET_BLOCKS
.clone()
@ -125,10 +147,9 @@ where
}
#[tokio::test]
#[should_panic]
async fn correctly_err_on_invalid_output_proof() {
// Since we expect these to fail, we don't want to poison the communal
// verifiers.
// Use separate verifiers so shared batch tasks aren't killed when the test ends (#2390).
// Also, since we expect these to fail, we don't want to slow down the communal verifiers.
let mut output_verifier = Fallback::new(
Batch::new(
Verifier::new(&PARAMS.sapling.output.vk),
@ -149,5 +170,5 @@ async fn correctly_err_on_invalid_output_proof() {
verify_invalid_groth16_output_description(&mut output_verifier, block.transactions)
.await
.unwrap()
.expect_err("unexpected success checking invalid groth16 inputs");
}