|
| 1 | +use assert_fs::TempDir; |
| 2 | +use assert_fs::assert::PathAssert; |
| 3 | +use assert_fs::prelude::PathChild; |
| 4 | +use indoc::indoc; |
| 5 | +use scarb_test_support::command::Scarb; |
| 6 | +use scarb_test_support::project_builder::ProjectBuilder; |
| 7 | + |
| 8 | +fn build_executable_project() -> TempDir { |
| 9 | + let t = TempDir::new().unwrap(); |
| 10 | + ProjectBuilder::start() |
| 11 | + .name("hello") |
| 12 | + .version("0.1.0") |
| 13 | + .dep_cairo_execute() |
| 14 | + .manifest_extra(indoc! {r#" |
| 15 | + [executable] |
| 16 | +
|
| 17 | + [cairo] |
| 18 | + enable-gas = false |
| 19 | + "#}) |
| 20 | + .lib_cairo(indoc! {r#" |
| 21 | + #[executable] |
| 22 | + fn main() -> felt252 { |
| 23 | + 42 |
| 24 | + } |
| 25 | + "#}) |
| 26 | + .build(&t); |
| 27 | + t |
| 28 | +} |
| 29 | + |
| 30 | +#[test] |
| 31 | +#[cfg(not(windows))] |
| 32 | +fn prove_with_execute() { |
| 33 | + let t = build_executable_project(); |
| 34 | + |
| 35 | + Scarb::quick_command() |
| 36 | + .arg("prove") |
| 37 | + .arg("--execute") |
| 38 | + .current_dir(&t) |
| 39 | + .assert() |
| 40 | + .success() |
| 41 | + .stdout_eq(indoc! {r#" |
| 42 | + [..]Compiling hello v0.1.0 ([..]) |
| 43 | + [..]Finished `dev` profile target(s) in [..] |
| 44 | + [..]Executing hello |
| 45 | + Saving output to: target/execute/hello/execution1 |
| 46 | + [..]Proving hello |
| 47 | + warn: soundness of proof is not yet guaranteed by Stwo, use at your own risk |
| 48 | + Saving proof to: target/execute/hello/execution1/proof/proof.json |
| 49 | + "#}); |
| 50 | + |
| 51 | + t.child("target/execute/hello/execution1/proof/proof.json") |
| 52 | + .assert(predicates::path::exists()); |
| 53 | +} |
| 54 | + |
| 55 | +#[test] |
| 56 | +#[cfg(not(windows))] |
| 57 | +fn prove_from_execution_output() { |
| 58 | + let t = build_executable_project(); |
| 59 | + |
| 60 | + Scarb::quick_command() |
| 61 | + .arg("execute") |
| 62 | + .arg("--target=bootloader") |
| 63 | + .current_dir(&t) |
| 64 | + .assert() |
| 65 | + .success(); |
| 66 | + |
| 67 | + Scarb::quick_command() |
| 68 | + .arg("prove") |
| 69 | + .arg("--execution-id=1") |
| 70 | + .current_dir(&t) |
| 71 | + .assert() |
| 72 | + .success() |
| 73 | + .stdout_eq(indoc! {r#" |
| 74 | + [..]Proving hello |
| 75 | + warn: soundness of proof is not yet guaranteed by Stwo, use at your own risk |
| 76 | + Saving proof to: target/execute/hello/execution1/proof/proof.json |
| 77 | + "#}); |
| 78 | + |
| 79 | + t.child("target/execute/hello/execution1/proof/proof.json") |
| 80 | + .assert(predicates::path::exists()); |
| 81 | +} |
0 commit comments