Skip to content

Commit

Permalink
separate soliidty tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
weijiekoh committed Feb 24, 2023
1 parent 3c12499 commit 6d5f8b7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 49 deletions.
23 changes: 13 additions & 10 deletions src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,21 @@ pub async fn run(cli: Cli) -> Result<(), Box<dyn Error>> {
let (deployment_code, yul_code) = gen_evm_verifier(&params, &vk, num_instance)?;
deployment_code.save(deployment_code_path.as_ref().unwrap())?;

let mut f = File::create(sol_code_path.as_ref().unwrap()).unwrap();
let _ = f.write(yul_code.as_bytes());
if sol_code_path.is_some() {

let cmd = Command::new("python3")
.arg("fix_verifier_sol.py")
.arg(sol_code_path.as_ref().unwrap())
.output()
.unwrap();
let output = cmd.stdout;
let mut f = File::create(sol_code_path.as_ref().unwrap()).unwrap();
let _ = f.write(yul_code.as_bytes());

let mut f = File::create(sol_code_path.as_ref().unwrap()).unwrap();
let _ = f.write(output.as_slice());
let cmd = Command::new("python3")
.arg("fix_verifier_sol.py")
.arg(sol_code_path.as_ref().unwrap())
.output()
.unwrap();
let output = cmd.stdout;

let mut f = File::create(sol_code_path.as_ref().unwrap()).unwrap();
let _ = f.write(output.as_slice());
}
}
}
}
Expand Down
59 changes: 20 additions & 39 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ const TESTS_EVM: [&str; 9] = [
"2l_relu_small",
];

/// Not all models will pass VerifyEVM because their contract size exceeds the limit, so we only
/// specify a few that will
const TESTS_SOLIDITY: [&str; 4] = [
"1l_relu",
"1l_leakyrelu",
"1l_sigmoid",
"1l_reshape",
];

const EXAMPLES: [&str; 2] = ["mlp_4d", "conv2d_mnist"];

macro_rules! test_func_aggr {
Expand Down Expand Up @@ -142,25 +133,6 @@ macro_rules! test_func {
};
}

macro_rules! test_func_solidity {
() => {
#[cfg(test)]
mod tests_solidity {
use seq_macro::seq;
use crate::TESTS_SOLIDITY;
use test_case::test_case;
use crate::kzg_evm_prove_and_verify;
use crate::kzg_evm_aggr_prove_and_verify;
seq!(N in 0..4 {
#(#[test_case(TESTS_SOLIDITY[N])])*
fn kzg_evm_prove_and_verify_(test: &str) {
kzg_evm_prove_and_verify(test.to_string(), true);
}
});
}
};
}

macro_rules! test_func_evm {
() => {
#[cfg(test)]
Expand All @@ -170,18 +142,28 @@ macro_rules! test_func_evm {
use test_case::test_case;
use crate::kzg_evm_prove_and_verify;
use crate::kzg_evm_aggr_prove_and_verify;

/// Not all models will pass VerifyEVM because their contract size exceeds the limit, so we only
/// specify a few that will
const TESTS_SOLIDITY: [&str; 4] = [
"1l_relu",
"1l_leakyrelu",
"1l_sigmoid",
"1l_reshape",
];

seq!(N in 0..=8 {

#(#[test_case(TESTS_EVM[N])])*
fn kzg_evm_prove_and_verify_(test: &str) {
kzg_evm_prove_and_verify(test.to_string(), false);
}
// these take a particularly long time to run
#(#[test_case(TESTS_EVM[N])])*
#[ignore]
fn kzg_evm_aggr_prove_and_verify_(test: &str) {
kzg_evm_aggr_prove_and_verify(test.to_string());
}
#(#[test_case(TESTS_EVM[N])])*
fn kzg_evm_prove_and_verify_(test: &str) {
kzg_evm_prove_and_verify(test.to_string(), TESTS_SOLIDITY.contains(&test));
}
// these take a particularly long time to run
#(#[test_case(TESTS_EVM[N])])*
#[ignore]
fn kzg_evm_aggr_prove_and_verify_(test: &str) {
kzg_evm_aggr_prove_and_verify(test.to_string());
}

});
}
Expand Down Expand Up @@ -229,7 +211,6 @@ test_func_aggr!();
test_func_evm!();
test_func_examples!();
test_neg_examples!();
test_func_solidity!();

// Mock prove (fast, but does not cover some potential issues)
fn neg_mock(example_name: String, counter_example: String) {
Expand Down

0 comments on commit 6d5f8b7

Please sign in to comment.