[test-only] More genericity in tests (#171)

* refactor: make circuit tests generic wrt curves

- Improve modularity by introducing generic `test_recursive_circuit_with` function in `src/circuit.rs`
- Refactor `test_recursive_circuit` to utilize the new function
- Implement type constraints for `test_recursive_circuit_with` function

* refactor: make bellperson tests generic in type of group

- Introduce `test_alloc_bit_with` function utilizing generic types
- Adapt existing `test_alloc_bit` function to use the new `test_alloc_bit_with` function with correct types

* refactor: make the nifs test generic in the type of group

* refactor: make the ivc tests generic in the type of curve

* refactor: simplify generics in tests

* make the keccak tests generic

* make the poseidon tests generic

* make the spartan tests generic
This commit is contained in:
François Garillot
2023-05-26 22:43:35 +02:00
committed by GitHub
parent 58fc746c0b
commit 54f758eef3
8 changed files with 227 additions and 96 deletions

View File

@@ -8,10 +8,13 @@ pub mod solver;
#[cfg(test)]
mod tests {
use crate::bellperson::{
r1cs::{NovaShape, NovaWitness},
shape_cs::ShapeCS,
solver::SatisfyingAssignment,
use crate::{
bellperson::{
r1cs::{NovaShape, NovaWitness},
shape_cs::ShapeCS,
solver::SatisfyingAssignment,
},
traits::Group,
};
use bellperson::{gadgets::num::AllocatedNum, ConstraintSystem, SynthesisError};
use ff::PrimeField;
@@ -39,10 +42,10 @@ mod tests {
Ok(())
}
#[test]
fn test_alloc_bit() {
type G = pasta_curves::pallas::Point;
fn test_alloc_bit_with<G>()
where
G: Group,
{
// First create the shape
let mut cs: ShapeCS<G> = ShapeCS::new();
let _ = synthesize_alloc_bit(&mut cs);
@@ -56,4 +59,10 @@ mod tests {
// Make sure that this is satisfiable
assert!(shape.is_sat(&ck, &inst, &witness).is_ok());
}
#[test]
fn test_alloc_bit() {
type G = pasta_curves::pallas::Point;
test_alloc_bit_with::<G>();
}
}