Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request 0xPolygonZero#42 from topos-protocol/distinction_w…
Browse files Browse the repository at this point in the history
…itness

Distinguish passed tests
  • Loading branch information
Nashtare authored Dec 4, 2023
2 parents f0c3dbd + c4a564d commit 994caa0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
2 changes: 1 addition & 1 deletion evm_test_runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async fn run() -> anyhow::Result<bool> {
let passed_t_names = skip_passed.then(|| {
Arc::new(
persistent_test_state
.get_tests_that_have_passed()
.get_tests_that_have_passed(witness_only)
.map(|t| t.to_string())
.collect(),
)
Expand Down
35 changes: 30 additions & 5 deletions evm_test_runner/src/persistent_run_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,18 @@ impl TestRunEntries {
}
}

pub(crate) fn get_tests_that_have_passed(&self) -> impl Iterator<Item = &str> {
self.0.iter().filter_map(|(name, info)| {
matches!(info.pass_state, PassState::Passed | PassState::Ignored).then(|| name.as_str())
/// Filters previously passed tests if the `skip_passed` argument is used.
/// The filtering will always ignore tests for which proof verification was
/// successful, but may not skip tests for which only witness generation
/// was tested, if we haven't passed the `witness_only` argument.
pub(crate) fn get_tests_that_have_passed(
&self,
witness_only: bool,
) -> impl Iterator<Item = &str> {
self.0.iter().filter_map(move |(name, info)| {
info.pass_state
.get_passed_status(witness_only)
.then_some(name.as_str())
})
}
}
Expand All @@ -90,17 +99,33 @@ impl From<Vec<SerializableRunEntry>> for TestRunEntries {

#[derive(Copy, Clone, Debug, Deserialize, Default, Serialize)]
pub(crate) enum PassState {
Passed,
PassedWitness,
PassedProof,
Ignored,
Failed,
#[default]
NotRun,
}

impl PassState {
// Utility method to filter out passed tests from previous runs.
fn get_passed_status(&self, witness_only: bool) -> bool {
if witness_only {
matches!(
self,
Self::PassedWitness | Self::PassedProof | Self::Ignored
)
} else {
matches!(self, Self::PassedProof | Self::Ignored)
}
}
}

impl From<TestStatus> for PassState {
fn from(v: TestStatus) -> Self {
match v {
TestStatus::Passed => PassState::Passed,
TestStatus::PassedWitness => PassState::PassedWitness,
TestStatus::PassedProof => PassState::PassedProof,
TestStatus::Ignored => PassState::Ignored,
TestStatus::EvmErr(_) | TestStatus::TimedOut => PassState::Failed,
}
Expand Down
13 changes: 8 additions & 5 deletions evm_test_runner/src/plonky2_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ impl TestProgressIndicator for FancyProgressIndicator {

#[derive(Clone, Debug)]
pub(crate) enum TestStatus {
Passed,
#[allow(unused)]
PassedWitness,
PassedProof,
Ignored,
EvmErr(String),
TimedOut,
Expand All @@ -83,7 +83,8 @@ pub(crate) enum TestStatus {
impl Display for TestStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TestStatus::Passed => write!(f, "Passed"),
TestStatus::PassedWitness => write!(f, "Passed witness generation"),
TestStatus::PassedProof => write!(f, "Passed proof verification"),
TestStatus::Ignored => write!(f, "Ignored"),
TestStatus::EvmErr(err) => write!(f, "Evm error: {}", err),
TestStatus::TimedOut => write!(f, "Test timed out"),
Expand All @@ -93,7 +94,7 @@ impl Display for TestStatus {

impl TestStatus {
pub(crate) fn passed(&self) -> bool {
matches!(self, TestStatus::Passed)
matches!(self, Self::PassedProof | Self::PassedWitness)
}
}

Expand Down Expand Up @@ -282,6 +283,8 @@ fn run_test_and_get_test_result(test: TestVariantRunInfo, witness_only: bool) ->
if let Err(evm_err) = res {
return handle_evm_err(evm_err, is_gaslimit_changed, "witness generation");
}

return TestStatus::PassedWitness;
}
false => {
let proof_run_res = prove::<GoldilocksField, KeccakGoldilocksConfig, 2>(
Expand Down Expand Up @@ -310,7 +313,7 @@ fn run_test_and_get_test_result(test: TestVariantRunInfo, witness_only: bool) ->
}
}

TestStatus::Passed
TestStatus::PassedProof
}

fn handle_evm_err(
Expand Down
7 changes: 6 additions & 1 deletion evm_test_runner/src/report_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ impl From<TestSubGroupRunResults> for TemplateSubGroupResultsData {
let tests: Vec<TestRunResult> = v.test_res.into_iter().collect();
let num_passed = tests
.iter()
.filter(|t| matches!(t.status, TestStatus::Passed))
.filter(|t| {
matches!(
t.status,
TestStatus::PassedProof | TestStatus::PassedWitness
)
})
.count();

Self {
Expand Down

0 comments on commit 994caa0

Please sign in to comment.