Skip to content

Commit

Permalink
Verify output file
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad committed Nov 19, 2024
1 parent 814c33f commit 5833ca7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
22 changes: 19 additions & 3 deletions scripts/prove_rpc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::{
env::set_var,
fmt::Display,
fs::create_dir_all,
fs::{create_dir_all, File},
io::{BufRead, BufReader},
path::{Path, PathBuf},
};

Expand Down Expand Up @@ -171,8 +172,11 @@ pub fn prove_via_rpc(args: ProveRpcArgs) -> Result<()> {
"-f",
proof_filepath.to_str().unwrap(),
])
.pipe(verify_output_filepath)?;
verify_runner.run()
.pipe(&verify_output_filepath)?;
verify_runner.run()?;

// Validate the proof output file.
verify_proof_output(&verify_output_filepath)
}
}
}
Expand Down Expand Up @@ -213,3 +217,15 @@ fn command_args<'a>(leader_args: &'a [&str]) -> Vec<&'a str> {
args.extend_from_slice(leader_args);
args
}

/// Checks that the output file contains the expected success message.
fn verify_proof_output(verify_output_filepath: &Path) -> Result<()> {
let verify_output_file = File::open(verify_output_filepath)?;
let reader = BufReader::new(verify_output_file);
for line in reader.lines() {
if line? == "All proofs verified successfully!" {
return Ok(());
}
}
anyhow::bail!("Proof verification failed!")
}
6 changes: 3 additions & 3 deletions scripts/runner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
fs::File,
path::PathBuf,
path::{Path, PathBuf},

Check failure on line 3 in scripts/runner.rs

View workflow job for this annotation

GitHub Actions / Zero tracer proof generation

unused import: `PathBuf`

Check failure on line 3 in scripts/runner.rs

View workflow job for this annotation

GitHub Actions / Native tracer proof generation

unused import: `PathBuf`

Check failure on line 3 in scripts/runner.rs

View workflow job for this annotation

GitHub Actions / outdated

unused import: `PathBuf`

Check failure on line 3 in scripts/runner.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `PathBuf`

Check failure on line 3 in scripts/runner.rs

View workflow job for this annotation

GitHub Actions / udeps

unused import: `PathBuf`
process::{Command, Stdio},
};

Expand Down Expand Up @@ -33,8 +33,8 @@ impl Runner {

/// Create the file specified by `output_filepath` and set it as the stdout
/// and stderr of the command.
pub fn pipe(mut self, output_filepath: impl Into<PathBuf>) -> Result<Self> {
let out = File::create(output_filepath.into())?;
pub fn pipe(mut self, output_filepath: &Path) -> Result<Self> {
let out = File::create(output_filepath)?;
let err = out.try_clone()?;
self.stdout = Stdio::from(out);
self.stderr = Stdio::from(err);
Expand Down

0 comments on commit 5833ca7

Please sign in to comment.