Skip to content

Commit

Permalink
test: download file if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ppoliani committed Feb 12, 2024
1 parent cc04249 commit e37ea89
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/snarkjs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub fn verify_proof(
#[cfg(test)]
mod tests {
use super::*;
use crate::zkbitcoin_folder;
use crate::srs::{download_srs, srs_path};

fn full_path_from(path: &Path) -> PathBuf {
PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()).join(path)
Expand All @@ -255,7 +255,12 @@ mod tests {
#[ignore]
async fn prove_stateless() {
let circom_circuit_path = full_path_from(Path::new("examples/circuit/stateless.circom"));
let srs_path = zkbitcoin_folder().join("srs_16.ptau");
let srs_size = 16;

if srs_path(srs_size).exists() {
download_srs(srs_size).await.unwrap();
}

let mut proof_inputs = HashMap::new();
proof_inputs.insert("truncated_txid".to_string(), vec!["0".to_string()]);
proof_inputs.insert(
Expand All @@ -265,7 +270,8 @@ mod tests {
.to_string(),
],
);
let (proof, full_inputs, vk) = prove(&circom_circuit_path, &srs_path, &proof_inputs)

let (proof, full_inputs, vk) = prove(&circom_circuit_path, srs_size, &proof_inputs)
.await
.unwrap();

Expand All @@ -281,7 +287,6 @@ mod tests {
.join("examples")
.join("circuit");
let circom_circuit_path = circuit_dir.join("circuit.circom");
let srs_path = zkbitcoin_folder().join("srs_16.ptau");

// // compile to get VK
// let vk = {
Expand All @@ -296,7 +301,12 @@ mod tests {

// prove
let public_inputs = HashMap::new();
let (proof, full_inputs, vk) = prove(&circom_circuit_path, &srs_path, &public_inputs)
let srs_size = 16;
if srs_path(srs_size).exists() {
download_srs(srs_size).await.unwrap();
}

let (proof, full_inputs, vk) = prove(&circom_circuit_path, srs_size, &public_inputs)
.await
.unwrap();

Expand Down

0 comments on commit e37ea89

Please sign in to comment.