1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

fix integration tests

This commit is contained in:
schaeff 2018-07-31 19:15:19 +02:00
parent b3c0009615
commit ec1b84a6b5
4 changed files with 16 additions and 22 deletions

View file

@ -67,7 +67,7 @@ mod integration {
fs::create_dir(test_case_path).unwrap();
// prepare compile arguments
let mut compile = vec!["./target/debug/zokrates-cli", "compile", "-i", program_path.to_str().unwrap(), "-o", flattened_path.to_str().unwrap()];
let mut compile = vec!["../target/debug/zokrates-cli", "compile", "-i", program_path.to_str().unwrap(), "-o", flattened_path.to_str().unwrap()];
if program_name.contains("sha_libsnark") {
compile.push("--gadgets");
@ -93,7 +93,7 @@ mod integration {
assert_eq!(flattened_code, expected_flattened_code, "Flattening failed for {}\n\nExpected\n\n{}\n\nGot\n\n{}", program_path.to_str().unwrap(), expected_flattened_code.as_str(), flattened_code.as_str());
// SETUP
assert_cli::Assert::command(&["cargo", "run", "--", "setup",
assert_cli::Assert::command(&["../target/debug/zokrates-cli", "setup",
"-i", flattened_path.to_str().unwrap(),
"-p", proving_key_path.to_str().unwrap(),
"-v", verification_key_path.to_str().unwrap(),
@ -102,7 +102,7 @@ mod integration {
.unwrap();
// EXPORT-VERIFIER
assert_cli::Assert::command(&["cargo", "run", "--", "export-verifier",
assert_cli::Assert::command(&["../target/debug/zokrates-cli", "export-verifier",
"-i", verification_key_path.to_str().unwrap(),
"-o", verification_contract_path.to_str().unwrap()])
.succeeds()
@ -116,7 +116,7 @@ mod integration {
_ => panic!(format!("Cannot read arguments. Check {}", arguments_path.to_str().unwrap()))
}).collect();
let mut compute = vec!["cargo", "run", "--", "compute-witness",
let mut compute = vec!["../target/debug/zokrates-cli", "compute-witness",
"-i", flattened_path.to_str().unwrap(),
"-o", witness_path.to_str().unwrap(),
"-a"];
@ -141,13 +141,14 @@ mod integration {
for line in expected_witness.as_str().split("\n") {
assert!(witness.contains(line), "Witness generation failed for {}\n\nLine \"{}\" not found in witness", program_path.to_str().unwrap(), line);
}
}
// GENERATE-PROOF
assert_cli::Assert::command(&["cargo", "run", "--", "generate-proof",
assert_cli::Assert::command(&["../target/debug/zokrates-cli", "generate-proof",
"-w", witness_path.to_str().unwrap(),
"-p", proving_key_path.to_str().unwrap(),
"-i", variable_information_path.to_str().unwrap()])
.succeeds()
.unwrap();
}
}

View file

@ -1,14 +1,11 @@
#[cfg(feature = "libsnark")]
extern crate gcc;
#[cfg(feature = "libsnark")]
extern crate cmake;
use std::path::Path;
use std::env;
fn main() {
#[cfg(feature = "libsnark")]
{
extern crate gcc;
extern crate cmake;
use std::path::Path;
use std::env;
let libsnark_source_path_string = env::var_os("LIBSNARK_SOURCE_PATH").expect("$LIBSNARK_SOURCE_PATH not set");
let libsnark_source_path = Path::new(&libsnark_source_path_string);

View file

@ -15,10 +15,6 @@ use semantics::{self, Checker};
use optimizer::{Optimizer};
use flatten::Flattener;
use std::io::{self};
#[cfg(feature = "libsnark")]
use libsnark::{get_sha256_constraints};
use serde_json;
use standard;
@ -109,6 +105,8 @@ fn compile_aux<T: Field, R: BufRead, S: BufRead, E: Into<imports::Error>>(reader
#[cfg(feature = "libsnark")]
{
use libsnark::{get_sha256_constraints};
if should_include_gadgets {
// inject globals
let r1cs: standard::R1CS = serde_json::from_str(&get_sha256_constraints()).unwrap();

View file

@ -1,9 +1,5 @@
use std::fmt;
use field::{Field};
#[cfg(feature = "libsnark")]
use libsnark::*;
use serde_json;
use standard;
@ -83,6 +79,8 @@ impl<T: Field> Executable<T> for LibsnarkGadgetHelper {
#[cfg(feature = "libsnark")]
{
use libsnark::*;
let witness_result: Result<standard::Witness, serde_json::Error> = serde_json::from_str(&get_sha256_witness(inputs));
if let Err(e) = witness_result {