Skip to content

Commit

Permalink
leave some todos for tackling afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
JereSalo committed Nov 26, 2024
1 parent 2c89323 commit 84671af
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 32 deletions.
16 changes: 1 addition & 15 deletions cmd/ef_tests/levm/deserialize.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::types::{EFTest, EFTestAccessListItem, EFTests};
use bytes::Bytes;
use ethrex_core::{Address, H256, U256};
use revm::primitives::AccessList;
use ethrex_core::{H256, U256};
use serde::Deserialize;
use std::{collections::HashMap, str::FromStr};

Expand Down Expand Up @@ -110,7 +109,6 @@ where

let mut final_access_list: Vec<EFTestAccessListItem> = Vec::new();
for access_list_element in access_list {
// let final_element = parse_access_list_item(access_list_element);
final_access_list.push(access_list_element);
}
final_access_lists.push(final_access_list);
Expand All @@ -120,18 +118,6 @@ where
Ok(Some(final_access_lists))
}

// pub fn parse_access_list_item(access_list_element: (String, Vec<String>)) -> EFTestAccessListItem {
// let address = Address::from_str(access_list_element.0.trim_start_matches("0x")).unwrap();
// let mut storage_keys = Vec::new();
// for storage_key in access_list_element.1 {
// storage_keys.push(H256::from_str(storage_key.trim_start_matches("0x")).unwrap());
// }
// EFTestAccessListItem {
// address,
// storage_keys,
// }
// }

pub fn deserialize_u256_optional_safe<'de, D>(deserializer: D) -> Result<Option<U256>, D::Error>
where
D: serde::Deserializer<'de>,
Expand Down
10 changes: 5 additions & 5 deletions cmd/ef_tests/levm/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ pub fn parse_ef_test_dir(
directory_parsing_spinner: &mut Spinner,
) -> Result<Vec<EFTest>, EFTestParseError> {
directory_parsing_spinner.update_text(format!("Parsing directory {:?}", test_dir.file_name()));
println!("Parsing directory {:?}", test_dir.file_name());
// println!("Parsing directory {:?}", test_dir.file_name());

// Skip directory stTimeConsuming
if test_dir.file_name() == "stTimeConsuming" || test_dir.file_name() == "Pyspecs" {
return Ok(Vec::new());
}
// // Skip directory stTimeConsuming and Pyspecs
// if test_dir.file_name() == "stTimeConsuming" || test_dir.file_name() == "Pyspecs" {
// return Ok(Vec::new());
// }

let mut directory_tests = Vec::new();
for test in std::fs::read_dir(test_dir.path())
Expand Down
11 changes: 5 additions & 6 deletions cmd/ef_tests/levm/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ pub fn run_ef_tests(
_opts: &EFTestRunnerOptions,
) -> Result<(), EFTestRunnerError> {
let mut reports = report::load()?;
// if reports.is_empty() {
// run_with_levm(&mut reports, &ef_tests)?;
// }
// re_run_with_revm(&mut reports, &ef_tests)?;
run_with_revm(&mut reports, &ef_tests)?;
if reports.is_empty() {
run_with_levm(&mut reports, &ef_tests)?;
}
re_run_with_revm(&mut reports, &ef_tests)?;
// run_with_revm(&mut reports, &ef_tests)?;
write_report(&reports)
}

Expand Down Expand Up @@ -118,7 +118,6 @@ fn run_with_revm(
};
reports.push(ef_test_report);
revm_run_spinner.update_text(report::progress(reports, revm_run_time.elapsed()));
// reports[idx] = ef_test_report;
}
revm_run_spinner.success(&format!(
"Ran all tests with REVM in {}",
Expand Down
8 changes: 4 additions & 4 deletions cmd/ef_tests/levm/runner/revm_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ pub fn prepare_revm_for_tx<'state>(
})
.collect();

println!("Access list: {:?}", revm_access_list);

let tx_env = RevmTxEnv {
caller: tx.sender.0.into(),
gas_limit: tx.gas_limit.as_u64(),
Expand Down Expand Up @@ -388,7 +386,7 @@ pub fn ensure_post_state_revm(
revm_state: &mut EvmState,
) -> Result<(), EFTestRunnerError> {
match revm_execution_result {
Ok(execution_result) => {
Ok(_execution_result) => {
match test.post.vector_post_value(vector).expect_exception {
// Execution result was successful but an exception was expected.
Some(expected_exception) => {
Expand All @@ -404,6 +402,7 @@ pub fn ensure_post_state_revm(
new_state: HashMap::new(),
created_address: None,
},
//TODO: This is not a TransactionReport because it is REVM
error_reason,
));
}
Expand All @@ -429,6 +428,7 @@ pub fn ensure_post_state_revm(
new_state: HashMap::new(),
created_address: None,
},
//TODO: This is not a TransactionReport because it is REVM
error_reason,
));
}
Expand All @@ -450,7 +450,7 @@ pub fn ensure_post_state_revm(
None => {
return Err(EFTestRunnerError::ExecutionFailedUnexpectedly(
ethrex_levm::errors::VMError::TestingOnly(error_reason),
//TODO: This is for testing
//TODO: This is for testing. Remove this from VMError afterwards!
));
}
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/ef_tests/levm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ use ethrex_core::{
Address, H256, U256,
};
use ethrex_vm::SpecId;
use revm::primitives::AccessListItem;
use serde::Deserialize;
use std::{collections::HashMap, ops::Add};
use std::collections::HashMap;

#[derive(Debug)]
pub struct EFTests(pub Vec<EFTest>);
Expand Down

0 comments on commit 84671af

Please sign in to comment.