Skip to content

Commit

Permalink
Change the test so that it's now not a workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Golovanov399 committed Dec 12, 2024
1 parent ace2d77 commit 1dc6023
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 58 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/cli-e2e.yml

This file was deleted.

3 changes: 3 additions & 0 deletions crates/cargo-axiom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ pub fn is_supported_target() -> bool {
pub fn get_target() -> String {
target_lexicon::HOST.to_string()
}

#[cfg(test)]
mod tests;
99 changes: 99 additions & 0 deletions crates/cargo-axiom/src/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
use std::{env, process::Command};

use eyre::Result;
use tempfile::tempdir;

#[test]
fn test_cli_e2e() -> Result<()> {
let temp_dir = tempdir()?;
let package_dir = env::current_dir()?;
let prefix = "[test cli e2e]";
let run_cmd = |program: &str, args: &[&str]| {
println!("{prefix} Running command: {} {} ...", program, args[0]);
let mut cmd = Command::new(program);
cmd.args(args);
cmd.current_dir(&package_dir);
let output = cmd.output().unwrap();
println!("{prefix} Finished!");
println!("{prefix} stdout:");
println!("{}", std::str::from_utf8(&output.stdout).unwrap());
println!("{prefix} stderr:");
println!("{}", std::str::from_utf8(&output.stderr).unwrap());
};
run_cmd("cargo", &["install", "--path", ".", "--force"]);
let temp_exe = temp_dir.path().join("example.axvmexe");
let temp_pk = temp_dir.path().join("example.pk");
let temp_vk = temp_dir.path().join("example.vk");
let temp_proof = temp_dir.path().join("example.apppf");

run_cmd(
"cargo",
&[
"axiom",
"build",
"--manifest-dir",
"../axvm-sdk/example",
"--transpile",
"--transpiler-config",
"example/app_config.toml",
"--transpile-to",
temp_exe.to_str().unwrap(),
],
);

run_cmd(
"cargo",
&[
"axiom",
"keygen",
"--config",
"example/app_config.toml",
"--output",
temp_pk.to_str().unwrap(),
"--vk-output",
temp_vk.to_str().unwrap(),
],
);

run_cmd(
"cargo",
&[
"axiom",
"run",
"--exe",
temp_exe.to_str().unwrap(),
"--config",
"example/app_config.toml",
],
);

run_cmd(
"cargo",
&[
"axiom",
"prove",
"app",
"--app-pk",
temp_pk.to_str().unwrap(),
"--exe",
temp_exe.to_str().unwrap(),
"--output",
temp_proof.to_str().unwrap(),
],
);

run_cmd(
"cargo",
&[
"axiom",
"verify",
"app",
"--app-vk",
temp_vk.to_str().unwrap(),
"--proof",
temp_proof.to_str().unwrap(),
],
);

Ok(())
}

0 comments on commit 1dc6023

Please sign in to comment.