-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat - adds testing scripts for ethereum//tests and execution spec te…
…sts (#37) * regular dependency upgrade * rewards contract call not made to fail if contract not deployed * testing setup * fmt etc * added tests for eels * downloads the folders * new job for spec tests * updated cargo.lock * removed consensus and upgraded to newer * rebase and bugfixes * feature to exclude time consuming tests (but not enabled) * cleanup * regular dependency upgrade * testing setup * updated cargo.lock * removed consensus and upgraded to newer * lock * fmt * debug
- Loading branch information
Showing
16 changed files
with
1,268 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/target | ||
ethereum-tests/ | ||
fixtures/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//! Various assertion helpers. | ||
use crate::testing::Error; | ||
use std::fmt::Debug; | ||
|
||
/// A helper like `assert_eq!` that instead returns `Err(Error::Assertion)` on failure. | ||
pub fn assert_equal<T>(left: T, right: T, msg: &str) -> Result<(), Error> | ||
where | ||
T: PartialEq + Debug, | ||
{ | ||
if left == right { | ||
Ok(()) | ||
} else { | ||
Err(Error::Assertion(format!( | ||
"{msg}\n left `{left:?}`,\n right `{right:?}`" | ||
))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! Test case definitions | ||
use crate::testing::result::{CaseResult, Error}; | ||
use std::{ | ||
fmt::Debug, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
/// A single test case, capable of loading a JSON description of itself and running it. | ||
/// | ||
/// See <https://ethereum-tests.readthedocs.io/> for test specs. | ||
pub trait Case: Debug + Sync + Sized { | ||
/// A description of the test. | ||
fn description(&self) -> String { | ||
"no description".to_string() | ||
} | ||
|
||
/// Load the test from the given file path. | ||
/// | ||
/// The file can be assumed to be a valid EF test case as described on <https://ethereum-tests.readthedocs.io/>. | ||
fn load(path: &Path) -> Result<Self, Error>; | ||
|
||
/// Run the test. | ||
fn run(&self) -> Result<(), Error>; | ||
} | ||
|
||
/// A container for multiple test cases. | ||
#[derive(Debug)] | ||
pub struct Cases<T> { | ||
/// The contained test cases and the path to each test. | ||
pub test_cases: Vec<(PathBuf, T)>, | ||
} | ||
|
||
impl<T: Case> Cases<T> { | ||
/// Run the contained test cases. | ||
pub fn run(&self) -> Vec<CaseResult> { | ||
self.test_cases | ||
.iter() | ||
.map(|(path, case)| CaseResult::new(path, case, case.run())) | ||
.collect() | ||
} | ||
} |
Oops, something went wrong.