1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

update integration tests to check witness generation from stdin

This commit is contained in:
schaeff 2019-02-25 19:19:08 +01:00
parent e672b590a2
commit ba87d8e69f
2 changed files with 39 additions and 7 deletions

View file

@ -10,6 +10,8 @@ use clap::{App, AppSettings, Arg, SubCommand};
use std::collections::HashMap;
use std::env;
use std::fs::File;
#[cfg(feature = "libsnark")]
use std::io::BufRead;
use std::io::{stdin, BufReader, BufWriter, Read, Write};
use std::path::{Path, PathBuf};
use std::string::String;

View file

@ -66,6 +66,7 @@ mod integration {
let test_case_path = tmp_base.join(program_name);
let flattened_path = tmp_base.join(program_name).join("out");
let witness_path = tmp_base.join(program_name).join("witness");
let inline_witness_path = tmp_base.join(program_name).join("inline_witness");
let verification_key_path = tmp_base
.join(program_name)
.join("verification")
@ -123,21 +124,41 @@ mod integration {
})
.collect();
let mut compute = vec![
// WITH `-a <arguments>`
let mut compute_inline = vec![
"../target/release/zokrates",
"compute-witness",
"-i",
flattened_path.to_str().unwrap(),
"-o",
inline_witness_path.to_str().unwrap(),
"-a",
];
for arg in arguments_str_list.iter() {
compute_inline.push(arg);
}
assert_cli::Assert::command(&compute_inline)
.succeeds()
.unwrap();
// WITH stdin ARGUMENTS
let compute = vec![
"../target/release/zokrates",
"compute-witness",
"-i",
flattened_path.to_str().unwrap(),
"-o",
witness_path.to_str().unwrap(),
"-a",
];
for arg in arguments_str_list.iter() {
compute.push(arg);
}
assert_cli::Assert::command(&compute).succeeds().unwrap();
assert_cli::Assert::command(&compute)
.stdin(&arguments_str_list.join(" "))
.succeeds()
.unwrap();
// load the expected witness
let mut expected_witness_file = File::open(&expected_witness_path).unwrap();
@ -151,6 +172,15 @@ mod integration {
let mut witness = String::new();
witness_file.read_to_string(&mut witness).unwrap();
// load the actual inline witness
let mut inline_witness_file = File::open(&inline_witness_path).unwrap();
let mut inline_witness = String::new();
inline_witness_file
.read_to_string(&mut inline_witness)
.unwrap();
assert_eq!(inline_witness, witness);
for line in expected_witness.as_str().split("\n") {
assert!(
witness.contains(line),