Skip to content

Commit

Permalink
Serialized some intensive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanieleDiBenedetto committed Sep 27, 2021
1 parent dc56cd0 commit e00a772
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 16 deletions.
1 change: 1 addition & 0 deletions proof-systems/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ blake2 = { version = "0.8.1", default-features = false }

algebra = { git = "https://github.com/HorizenOfficial/ginger-lib", branch = "rc/audit_chain", features = ["full", "parallel", "fft"] }
r1cs-crypto = { path = "../r1cs/gadgets/crypto", features = ["nizk"] }
serial_test = "*"

[features]
print-trace = [ "bench-utils/print-trace" ]
Expand Down
3 changes: 3 additions & 0 deletions proof-systems/src/darlin/accumulators/dlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,13 +918,16 @@ mod test {
dum::Affine as TweedleDum,
};
use poly_commit::rng::FiatShamirChaChaRng;
use serial_test::serial;

#[serial]
#[test]
fn test_tweedle_accumulate_verify() {
accumulation_test::<TweedleDee, Blake2s>().unwrap();
accumulation_test::<TweedleDum, Blake2s>().unwrap();
}

#[serial]
#[test]
fn test_tweedle_batch_verify() {
batch_verification_test::<TweedleDee, Blake2s>().unwrap();
Expand Down
4 changes: 4 additions & 0 deletions proof-systems/src/darlin/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ mod test {
use std::fs::File;
use std::collections::HashSet;
use crate::darlin::data_structures::FinalDarlinProof;
use serial_test::serial;

fn get_unique_random_proof_indices<R: RngCore>(pcds_len: usize, rng: &mut R) -> Vec<usize> {
let num_proofs_to_randomize: usize = rng.gen_range(1..pcds_len/2);
Expand Down Expand Up @@ -313,6 +314,7 @@ mod test {
type TestIPAPCDee = InnerProductArgPC<DeeAffine, Blake2s>;
type TestIPAPCDum = InnerProductArgPC<DumAffine, Blake2s>;

#[serial]
#[test]
fn test_simple_marlin_proof_aggregator() {
let rng = &mut XorShiftRng::seed_from_u64(1234567890u64);
Expand Down Expand Up @@ -419,6 +421,7 @@ mod test {
);
}

#[serial]
#[test]
fn test_final_darlin_proof_aggregator() {
let rng = &mut XorShiftRng::seed_from_u64(1234567890u64);
Expand Down Expand Up @@ -529,6 +532,7 @@ mod test {
);
}

#[serial]
#[test]
fn test_mixed_proof_aggregator() {
let rng = &mut XorShiftRng::seed_from_u64(1234567890u64);
Expand Down
2 changes: 2 additions & 0 deletions proof-systems/src/gm17/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ mod test{
};
use rand::thread_rng;
use std::ops::MulAssign;
use serial_test::serial;

fn test_prove_and_verify<E: PairingEngine>() {
let rng = &mut thread_rng();
Expand Down Expand Up @@ -72,6 +73,7 @@ mod test{
}
}

#[serial]
#[test]
fn prove_verify() {
test_prove_and_verify::<Bls12_377>();
Expand Down
6 changes: 6 additions & 0 deletions proof-systems/src/groth16/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod test {
use algebra::{UniformRand, ToBytes, FromBytes, to_bytes, PairingEngine};
use rand::thread_rng;
use std::ops::MulAssign;
use serial_test::serial;

fn prove_and_verify<E: PairingEngine>(zk: bool) {
let rng = &mut thread_rng();
Expand Down Expand Up @@ -124,34 +125,39 @@ mod test {
assert!(verify_proof(&pvk_deserialized, &proof_deserialized, &[c]).unwrap())
}

#[serial]
#[test]
fn bls12_377_groth16_test() {
prove_and_verify::<algebra::curves::bls12_377::Bls12_377>(true);
prove_and_verify::<algebra::curves::bls12_377::Bls12_377>(false);
serialize_deserialize::<algebra::curves::bls12_377::Bls12_377>();
}

#[serial]
#[test]
fn sw6_groth16_test() {
prove_and_verify::<algebra::curves::sw6::SW6>(true);
prove_and_verify::<algebra::curves::sw6::SW6>(false);
serialize_deserialize::<algebra::curves::sw6::SW6>();
}

#[serial]
#[test]
fn mnt4753_groth16_test() {
prove_and_verify::<algebra::curves::mnt4753::MNT4>(true);
prove_and_verify::<algebra::curves::mnt4753::MNT4>(false);
serialize_deserialize::<algebra::curves::mnt4753::MNT4>();
}

#[serial]
#[test]
fn mnt6753_groth16_test() {
prove_and_verify::<algebra::curves::mnt6753::MNT6>(true);
prove_and_verify::<algebra::curves::mnt6753::MNT6>(false);
serialize_deserialize::<algebra::curves::mnt6753::MNT6>();
}

#[serial]
#[test]
fn bn_382_groth16_test() {
prove_and_verify::<algebra::curves::bn_382::Bn382>(true);
Expand Down
3 changes: 2 additions & 1 deletion r1cs/gadgets/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ llvm_asm = ["algebra/llvm_asm"]
rand_xorshift = { version = "0.3.0" }
algebra = { git = "https://github.com/HorizenOfficial/ginger-lib", branch = "rc/audit_chain", features = ["bls12_377", "bls12_381", "sw6", "bn_382"] }
r1cs-std = { path = "../std", features = ["jubjub", "edwards_sw6", "bls12_377", "mnt4_753", "mnt6_753", "bn_382", "tweedle"] }
r1cs-crypto = { path = "../crypto", features = ["mnt4_753", "mnt6_753", "bn_382", "tweedle"] }
r1cs-crypto = { path = "../crypto", features = ["mnt4_753", "mnt6_753", "bn_382", "tweedle"] }
serial_test = "*"
2 changes: 2 additions & 0 deletions r1cs/gadgets/crypto/src/nizk/gm17/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ mod test {
};
use super::*;
use rand::{thread_rng, Rng};
use serial_test::serial;

type TestProofSystem = Gm17<Bls12_377, Bench<Fr>, Fr>;
type TestVerifierGadget = Gm17VerifierGadget<Bls12_377, Fq, Bls12_377PairingGadget>;
Expand Down Expand Up @@ -522,6 +523,7 @@ mod test {
}
}

#[serial]
#[test]
fn gm17_verifier_test() {
let num_inputs = 2;
Expand Down
6 changes: 5 additions & 1 deletion r1cs/gadgets/crypto/src/nizk/groth16/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ mod test {
boolean::Boolean, test_constraint_system::TestConstraintSystem
};
use rand::thread_rng;
use serial_test::serial;


struct Bench<F: Field> {
Expand Down Expand Up @@ -699,6 +700,7 @@ mod test {
}
}

#[serial]
#[test]
fn bls12_377_groth16_verifier_test() {
use algebra::curves::bls12_377::Bls12_377;
Expand All @@ -707,6 +709,7 @@ mod test {
groth16_verifier_test::<Bls12_377, PairingGadget>();
}

#[serial]
#[test]
fn mnt4_753_groth16_verifier_test() {
use algebra::curves::mnt4753::MNT4;
Expand All @@ -715,7 +718,7 @@ mod test {
groth16_verifier_test::<MNT4, PairingGadget>();
}

#[ignore]
#[serial]
#[test]
fn mnt6_753_groth16_verifier_test() {
use algebra::curves::mnt6753::MNT6;
Expand All @@ -724,6 +727,7 @@ mod test {
groth16_verifier_test::<MNT6, PairingGadget>();
}

#[serial]
#[test]
fn bn_382_groth16_verifier_test() {
use algebra::curves::bn_382::Bn382;
Expand Down
3 changes: 2 additions & 1 deletion r1cs/gadgets/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ density-optimized = []
paste = "1.0"
rand = { version = "0.8.4" }
rand_xorshift = { version = "0.3.0" }
r1cs-std = { path = "../std", features = ["bls12_381", "jubjub", "tweedle", "secp256k1", "bn_382", "nonnative", "density-optimized"] }
r1cs-std = { path = "../std", features = ["bls12_381", "jubjub", "tweedle", "secp256k1", "bn_382", "nonnative", "density-optimized"] }
serial_test = "*"
3 changes: 2 additions & 1 deletion r1cs/gadgets/std/src/groups/nonnative/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{
test_constraint_system::TestConstraintSystem,
};
use rand::thread_rng;

use serial_test::serial;

#[allow(dead_code)]
pub(crate) fn mul_bits_test<
Expand Down Expand Up @@ -69,6 +69,7 @@ pub(crate) fn mul_bits_test<
macro_rules! nonnative_test_individual {
($test_method:ident, $test_name:ident, $num_samples:expr, $group_params:ty, $test_constraint_field:ty, $test_simulation_field:ty) => {
paste::item! {
#[serial]
#[test]
fn [<$test_method _ $test_name:lower>]() {
for _ in 0..$num_samples {
Expand Down
14 changes: 11 additions & 3 deletions r1cs/gadgets/std/src/instantiated/bls12_377/pairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ use algebra::curves::bls12_377::Bls12_377Parameters as Parameters;

pub type PairingGadget = crate::pairing::bls12::PairingGadget<Parameters>;

#[test]
fn test() {
crate::pairing::tests::bilinearity_test::<algebra::curves::bls12_377::Bls12_377, _, PairingGadget>()
#[cfg(test)]
mod test {
use super::*;
use serial_test::serial;

#[serial]
#[test]
fn test() {
crate::pairing::tests::bilinearity_test::<algebra::curves::bls12_377::Bls12_377, _, PairingGadget>()
}
}

13 changes: 10 additions & 3 deletions r1cs/gadgets/std/src/instantiated/bn_382/pairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ use algebra::curves::bn_382::Bn382Parameters;

pub type PairingGadget = crate::pairing::bn::PairingGadget<Bn382Parameters>;

#[test]
fn test() {
crate::pairing::tests::bilinearity_test::<algebra::curves::bn_382::Bn382, _, PairingGadget>()
#[cfg(test)]
mod test {
use super::*;
use serial_test::serial;

#[serial]
#[test]
fn test() {
crate::pairing::tests::bilinearity_test::<algebra::curves::bn_382::Bn382, _, PairingGadget>()
}
}
13 changes: 10 additions & 3 deletions r1cs/gadgets/std/src/instantiated/mnt4_753/pairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ use algebra::curves::mnt4753::MNT4_753Parameters as Parameters;

pub type PairingGadget = crate::pairing::mnt4::MNT4PairingGadget<Parameters>;

#[test]
fn test() {
crate::pairing::tests::bilinearity_test::<algebra::curves::mnt4753::MNT4, _, PairingGadget>()
#[cfg(test)]
mod test {
use super::*;
use serial_test::serial;

#[serial]
#[test]
fn test() {
crate::pairing::tests::bilinearity_test::<algebra::curves::mnt4753::MNT4, _, PairingGadget>()
}
}
13 changes: 10 additions & 3 deletions r1cs/gadgets/std/src/instantiated/mnt6_753/pairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ use algebra::curves::mnt6753::MNT6_753Parameters as Parameters;

pub type PairingGadget = crate::pairing::mnt6::MNT6PairingGadget<Parameters>;

#[test]
fn test() {
crate::pairing::tests::bilinearity_test::<algebra::curves::mnt6753::MNT6, _, PairingGadget>()
#[cfg(test)]
mod test {
use super::*;
use serial_test::serial;

#[serial]
#[test]
fn test() {
crate::pairing::tests::bilinearity_test::<algebra::curves::mnt6753::MNT6, _, PairingGadget>()
}
}

0 comments on commit e00a772

Please sign in to comment.