Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: refactore CLI tool and CI, tests cleanup #43

Merged
merged 44 commits into from
Jun 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7cde94a
Extend tests output and refactore tests runner
mrLSD Apr 10, 2024
ad6d037
Merge branch 'hard-fork/cancun' into feat/evm-tests
mrLSD Apr 10, 2024
740c4aa
Refactored CLI for recursive tests and extended information
mrLSD Apr 11, 2024
753ba4d
Set Shanghai spec as default
mrLSD Apr 11, 2024
d282946
Extend output for tests
mrLSD Apr 11, 2024
1392a36
evm-tests: extend state statistics for failed results
mrLSD Apr 11, 2024
be9e967
evm-tests: extended debug info
mrLSD Apr 12, 2024
1b68719
Extend gas cost analyzer
mrLSD Apr 25, 2024
34a808f
Extend tests and fixes for Cancun hard fork
mrLSD Apr 30, 2024
6bb0afd
Fix: Apply CREATE storage reset - changed logic. GAS cost for MCOPY -…
mrLSD May 2, 2024
788a436
EIP-3607 implementation. DeepCall bug fixes. KZG-boilerplate
mrLSD May 7, 2024
b977800
KZG precompile
mrLSD May 15, 2024
665b847
EIP-3860 test flow fixes
mrLSD May 15, 2024
0e2e2c5
Fix Shanghai tests
mrLSD May 16, 2024
3bd18ad
Removev debug info
mrLSD May 15, 2024
fda0b97
Separate check_exit_reason func
mrLSD May 20, 2024
d815d28
Remove printing
mrLSD May 20, 2024
74b6b16
Added `as_deref` to check_create_exit_reason
mrLSD May 20, 2024
6ea09a0
Fix: tests for EIP-3860 (#41)
mrLSD May 20, 2024
b1dcd90
ForkSpec string error. Refactored usage as constantn USIZE_MAX
mrLSD May 20, 2024
f31744a
Remove already fixed tests from skipping list
mrLSD May 20, 2024
608c6cb
Refactore blob-hash logic and tests
mrLSD May 24, 2024
9deee5f
Added KzgInput
mrLSD May 24, 2024
2a1b62d
Gas price fix and investigations for blob-transactions
mrLSD May 27, 2024
0f39236
Refactored skipped-match and clippy
mrLSD May 27, 2024
a8685da
Refactored gas price and should-skip logic
mrLSD May 28, 2024
f89acd6
Fix tests for KZG-precompiles and SSTORE gas cost
mrLSD May 30, 2024
16e67c5
Added print-debug feature
mrLSD May 30, 2024
7191bd5
Merge branch 'hard-fork/cancun' of github.com:aurora-is-near/sputnikv…
mrLSD May 30, 2024
d473fdb
Fix randomness validation
mrLSD May 31, 2024
82a7bcd
Refactore transactions validation
mrLSD May 31, 2024
bc21670
Extend expected check for call-transaction and empty-create assertion
mrLSD Jun 3, 2024
23c1c4f
Merge branch 'feat/evm-tests' into fix/eip-4844
mrLSD Jun 3, 2024
581370a
Edit doc comments
mrLSD Jun 3, 2024
2d92ce0
Refactore CLI tool for test run
mrLSD Jun 4, 2024
ea712e1
remove vm-tests
mrLSD Jun 4, 2024
b8897b0
update vm-tests validations
mrLSD Jun 4, 2024
c299d08
remove state tests
mrLSD Jun 4, 2024
f395fac
Remove submodule: ethtests
mrLSD Jun 4, 2024
24dc137
Update CI rules
mrLSD Jun 4, 2024
4bcc4f9
Update CI rules
mrLSD Jun 4, 2024
d85496f
Update Cargo metadata
mrLSD Jun 5, 2024
5291fd6
Update cargo features
mrLSD Jun 5, 2024
192a6b5
Merge branch 'hard-fork/cancun' of github.com:aurora-is-near/sputnikv…
mrLSD Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactore CLI tool for test run
mrLSD committed Jun 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2d92ce048da9ff0efa9b352c93c0a9c875cc43d0
5 changes: 4 additions & 1 deletion evm-tests/jsontests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ primitive-types = "0.12"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
hex = "0.4"
clap = { version = "4.0", features = ["cargo"] }
clap = { version = "4.5", features = ["cargo"] }
ethjson = { path = "../ethjson", features = ["test-helpers"] }
libsecp256k1 = "0.7"
ethcore-builtin = { path = "../ethcore-builtin" }
@@ -24,3 +24,6 @@ sha3 = "0.10"
parity-bytes = "0.1"
env_logger = "0.11"
lazy_static = "1.4.0"

[features]
enable-slow-tests = []
147 changes: 126 additions & 21 deletions evm-tests/jsontests/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::{arg, command, value_parser, Arg, ArgAction, Command};
use clap::{arg, command, value_parser, ArgAction, Command};
use ethjson::spec::ForkSpec;
use evm_jsontests::state as statetests;
use evm_jsontests::state::{TestExecutionResult, VerboseOutput};
@@ -10,22 +10,36 @@ use std::io::BufReader;
use std::path::{Path, PathBuf};

#[allow(clippy::cognitive_complexity)]
fn main() {
fn main() -> Result<(), String> {
let matches = command!()
.version(env!("CARGO_PKG_VERSION"))
.subcommand_required(true)
.subcommand(
Command::new("vm").about("vm tests runner").arg(
Arg::new("PATH")
.help("json file or directory for tests run")
.required(true),
),
Command::new("vm")
.about("vm tests runner")
.arg(
arg!([PATH] "json file or directory for tests run")
.action(ArgAction::Append)
.required(true)
.value_parser(value_parser!(PathBuf)),
)
.arg(
arg!(-v --verbose "Verbose output")
.default_value("false")
.action(ArgAction::SetTrue),
)
.arg(
arg!(-f --verbose_failed "Verbose failed only output")
.default_value("false")
.action(ArgAction::SetTrue),
),
)
.subcommand(
Command::new("state")
.about("state tests runner")
.arg(
arg!([PATH] "json file or directory for tests run")
.action(ArgAction::Append)
.required(true)
.value_parser(value_parser!(PathBuf)),
)
@@ -54,15 +68,25 @@ fn main() {
.get_matches();

if let Some(matches) = matches.subcommand_matches("vm") {
for file_name in matches.get_many::<PathBuf>("PATH").unwrap() {
let file = File::open(file_name).expect("Open failed");

let reader = BufReader::new(file);
let test_suite = serde_json::from_reader::<_, HashMap<String, vmtests::Test>>(reader)
.expect("Parse test cases failed");

for (name, test) in test_suite {
vmtests::test(&name, test);
let verbose_output = VerboseOutput {
verbose: matches.get_flag("verbose"),
verbose_failed: matches.get_flag("verbose_failed"),
very_verbose: false,
print_state: false,
};
let mut tests_result = TestExecutionResult::new();
for src_name in matches.get_many::<PathBuf>("PATH").unwrap() {
let path = Path::new(src_name);
assert!(path.exists(), "data source is not exist");
if path.is_file() {
run_vm_test_for_file(&verbose_output, path, &mut tests_result);
} else if path.is_dir() {
run_vm_test_for_dir(&verbose_output, path, &mut tests_result);
}
println!("\nTOTAL: {}", tests_result.total);
println!("FAILED: {}\n", tests_result.failed);
if tests_result.failed != 0 {
return Err(format!("tests failed: {}", tests_result.failed));
}
}
}
@@ -90,6 +114,79 @@ fn main() {
}
println!("\nTOTAL: {}", tests_result.total);
println!("FAILED: {}\n", tests_result.failed);
if tests_result.failed != 0 {
return Err(format!("tests failed: {}", tests_result.failed));
}
}
Ok(())
}

fn run_vm_test_for_dir(
verbose_output: &VerboseOutput,
dir_name: &Path,
tests_result: &mut TestExecutionResult,
) {
for entry in fs::read_dir(dir_name).unwrap() {
let entry = entry.unwrap();
if let Some(s) = entry.file_name().to_str() {
if s.starts_with('.') {
continue;
}
}
let path = entry.path();
if path.is_dir() {
run_vm_test_for_dir(verbose_output, path.as_path(), tests_result);
} else {
run_vm_test_for_file(verbose_output, path.as_path(), tests_result);
}
}
}

fn run_vm_test_for_file(
verbose_output: &VerboseOutput,
file_name: &Path,
tests_result: &mut TestExecutionResult,
) {
if verbose_output.verbose {
println!(
"RUN for: {}",
short_test_file_name(file_name.to_str().unwrap())
);
}
let file = File::open(file_name).expect("Open file failed");

let reader = BufReader::new(file);
let test_suite = serde_json::from_reader::<_, HashMap<String, vmtests::Test>>(reader)
.expect("Parse test cases failed");

for (name, test) in test_suite {
let test_res = vmtests::test(verbose_output, &name, test);

if test_res.failed > 0 {
if verbose_output.verbose {
println!("Tests count:\t{}", test_res.total);
println!(
"Failed:\t\t{} - {}\n",
test_res.failed,
short_test_file_name(file_name.to_str().unwrap())
);
} else if verbose_output.verbose_failed {
println!(
"RUN for: {}",
short_test_file_name(file_name.to_str().unwrap())
);
println!("Tests count:\t{}", test_res.total);
println!(
"Failed:\t\t{} - {}\n",
test_res.failed,
short_test_file_name(file_name.to_str().unwrap())
);
}
} else if verbose_output.verbose {
println!("Tests count: {}\n", test_res.total);
}

tests_result.merge(test_res);
}
}

@@ -183,21 +280,29 @@ fn short_test_file_name(name: &str) -> String {
}
}

#[cfg(feature = "enable-slow-tests")]
const SKIPPED_CASES: &[&str] = &[
// funky test with `bigint 0x00` value in json :) not possible to happen on mainnet and require
// custom json parser. https://github.com/ethereum/tests/issues/971
"stTransactionTest/ValueOverflow",
"stTransactionTest/ValueOverflowParis",
];

#[cfg(not(feature = "enable-slow-tests"))]
const SKIPPED_CASES: &[&str] = &[
// funky test with `bigint 0x00` value in json :) not possible to happen on mainnet and require
// custom json parser. https://github.com/ethereum/tests/issues/971
"stTransactionTest/ValueOverflow",
"stTransactionTest/ValueOverflowParis",
// These tests are passing, but they take a lot of time to execute so can going to skip them.
// NOTE: do not remove it to know slowest tests. It's useful for development.
// "stTimeConsuming/static_Call50000_sha256",
// "vmPerformance/loopMul",
// "stTimeConsuming/CALLBlake2f_MaxRounds",
"stTimeConsuming/static_Call50000_sha256",
"vmPerformance/loopMul",
"stTimeConsuming/CALLBlake2f_MaxRounds",
];

/// Check is path should be skip.
/// It checks:
/// - path/and_file_stam - check path and file name (without extention)
/// - path/and_file_stem - check path and file name (without extention)
/// - path/with/sub/path - recursively check path
fn should_skip(path: &Path) -> bool {
let matches = |case: &str| {
5 changes: 4 additions & 1 deletion evm-tests/jsontests/src/vm.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::state::{TestExecutionResult, VerboseOutput};
use crate::utils::*;
use evm::backend::{ApplyBackend, MemoryAccount, MemoryBackend, MemoryVicinity};
use evm::executor::stack::{MemoryStackState, StackExecutor, StackSubstateMetadata};
@@ -76,7 +77,8 @@ impl Test {
}
}

pub fn test(name: &str, test: Test) {
pub fn test(_verbose_output: &VerboseOutput, name: &str, test: Test) -> TestExecutionResult {
let result = TestExecutionResult::new();
print!("Running test {} ... ", name);
flush();

@@ -118,4 +120,5 @@ pub fn test(name: &str, test: Test) {
}

println!("succeed");
result
}
8 changes: 4 additions & 4 deletions evm-tests/jsontests/tests/vm.rs
Original file line number Diff line number Diff line change
@@ -17,12 +17,12 @@ pub fn run(dir: &str) {
let file = File::open(path).expect("Open file failed");

let reader = BufReader::new(file);
let coll = serde_json::from_reader::<_, HashMap<String, vmtests::Test>>(reader)
let _coll = serde_json::from_reader::<_, HashMap<String, vmtests::Test>>(reader)
.expect("Parse test cases failed");

for (name, test) in coll {
vmtests::test(&name, test);
}
// for (name, test) in coll {
// vmtests::test( &name, test);
// }
}
}