fix leo test to run tests in isolation

This commit is contained in:
collin 2020-08-03 19:51:41 -07:00
parent 4565274893
commit ddcf2c0b09
4 changed files with 7 additions and 9 deletions

View File

@ -345,8 +345,8 @@ input_keyword = { "input" }
// Declared in functions/input/input.rs
input = {
input_keyword
| function_input
function_input
| input_keyword
}
input_list = _{ (input ~ ("," ~ NEWLINE* ~ input)*)? }

View File

@ -150,8 +150,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
}
/// Synthesizes the circuit for test functions with program input.
pub fn compile_test_constraints(self, cs: &mut TestConstraintSystem<F>) -> Result<(), CompilerError> {
generate_test_constraints::<F, G>(cs, self.program, self.program_input, &self.imported_programs)
pub fn compile_test_constraints(self) -> Result<(), CompilerError> {
generate_test_constraints::<F, G>(self.program, self.program_input, &self.imported_programs)
}
/// Calls the internal generate_constraints method with arguments

View File

@ -42,7 +42,6 @@ pub fn generate_constraints<F: Field + PrimeField, G: GroupType<F>, CS: Constrai
}
pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
cs: &mut TestConstraintSystem<F>,
program: Program,
input: Input,
imported_programs: &ImportParser,
@ -57,6 +56,7 @@ pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
log::info!("Running {} tests", tests.len());
for (test_name, test_function) in tests.into_iter() {
let cs = &mut TestConstraintSystem::<F>::new();
let full_test_name = format!("{}::{}", program_name.clone(), test_name.to_string());
let result = resolved_program.enforce_main_function(
@ -68,7 +68,7 @@ pub fn generate_test_constraints<F: Field + PrimeField, G: GroupType<F>>(
if result.is_ok() {
log::info!(
"test {} passed. Constraint system satisfied: {}",
"test {} compiled successfully. Constraint system satisfied: {}",
full_test_name,
cs.is_satisfied()
);

View File

@ -12,7 +12,6 @@ use leo_package::{
};
use snarkos_curves::edwards_bls12::Fq;
use snarkos_models::gadgets::r1cs::TestConstraintSystem;
use clap::ArgMatches;
use std::{convert::TryFrom, env::current_dir};
@ -81,9 +80,8 @@ impl CLI for TestCommand {
// Generate the program on the constraint system and verify correctness
{
let mut cs = TestConstraintSystem::<Fq>::new();
let temporary_program = program.clone();
let output = temporary_program.compile_test_constraints(&mut cs)?;
let output = temporary_program.compile_test_constraints()?;
log::debug!("Compiled constraints - {:#?}", output);
}