Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit a53859c

Browse files
authored
testool update (#1237)
* add curie suite * enable normalize for stEIP1153-transientStorage * fix * fix cond, move comment
1 parent 48594e4 commit a53859c

File tree

6 files changed

+62
-16
lines changed

6 files changed

+62
-16
lines changed

testool/Config.toml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[[suite]]
22
id="default"
3-
path="tests/src/GeneralStateTestsFiller/**/*"
3+
paths = [
4+
"tests/src/GeneralStateTestsFiller/**/*"
5+
]
46
max_gas = 500000
57
max_steps = 1000
68
ignore_tests = [
@@ -11,47 +13,71 @@ ignore_tests = [
1113

1214
[[suite]]
1315
id="EIP1153"
14-
path = "tests/src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/*"
16+
paths = [
17+
"tests/src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/*"
18+
]
1519
max_gas = 500000
1620
max_steps = 1000
1721
ignore_tests = []
1822

1923
[[suite]]
2024
id="EIP2930"
21-
path="tests/src/GeneralStateTestsFiller/stEIP2930/*"
25+
paths = [
26+
"tests/src/GeneralStateTestsFiller/stEIP2930/*"
27+
]
2228
max_gas = 500000
2329
max_steps = 1000
2430
ignore_tests = []
2531

2632
[[suite]]
2733
id="EIP1559"
28-
path="tests/src/GeneralStateTestsFiller/stEIP1559/**/*"
34+
paths = [
35+
"tests/src/GeneralStateTestsFiller/stEIP1559/**/*"
36+
]
2937
max_gas = 500000
3038
max_steps = 1000
3139
ignore_tests = []
3240

3341

3442
[[suite]]
3543
id="precompile"
36-
path="tests/src/GeneralStateTestsFiller/stPreCompiledContracts/*"
44+
paths = [
45+
"tests/src/GeneralStateTestsFiller/stPreCompiledContracts/*"
46+
]
3747
max_gas = 500000
3848
max_steps = 1000
3949
ignore_tests = []
4050

4151
[[suite]]
4252
id="precompile2"
43-
path="tests/src/GeneralStateTestsFiller/stPreCompiledContracts2/*"
53+
paths = [
54+
"tests/src/GeneralStateTestsFiller/stPreCompiledContracts2/*"
55+
]
4456
max_gas = 500000
4557
max_steps = 1000
4658
ignore_tests = []
4759

4860
[[suite]]
4961
id="nightly"
50-
path="tests/src/GeneralStateTestsFiller/**/*"
62+
paths = [
63+
"tests/src/GeneralStateTestsFiller/**/*"
64+
]
5165
max_gas = 0
5266
max_steps = 100000
5367
ignore_tests=[]
5468

69+
[[suite]]
70+
id="curie"
71+
paths = [
72+
"tests/src/GeneralStateTestsFiller/stEIP1559/*",
73+
"tests/src/GeneralStateTestsFiller/stEIP2930/*",
74+
"tests/src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/*",
75+
"tests/src/GeneralStateTestsFiller/Cancun/stEIP5656-MCOPY/*"
76+
]
77+
max_gas = 0
78+
max_steps = 100000
79+
ignore_tests = []
80+
5581
[[set]]
5682
id = "sigkill"
5783
desc = "tests that sigkill"

testool/src/abi.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
use anyhow::Result;
22
use eth_types::{Bytes, U256};
33
use sha3::Digest;
4+
use std::cell::RefCell;
5+
6+
thread_local! {
7+
/// dirty hack to enable normalization
8+
pub static ENABLE_NORMALIZE: RefCell<bool> = RefCell::new(true);
9+
}
410

511
/// encodes an abi call (e.g. "f(uint) 1")
612
pub fn encode_funccall(spec: &str) -> Result<Bytes> {
@@ -74,10 +80,7 @@ pub fn encode_funccall(spec: &str) -> Result<Bytes> {
7480
state_mutability: StateMutability::Payable,
7581
constant: Some(false),
7682
};
77-
// Shoule be false for stEIP1153-transientStorage,
78-
// due to this bughttps://github.com/ethereum/tests/issues/1369
79-
let enable_normalize = true;
80-
let bytes: Vec<u8> = if !enable_normalize {
83+
let bytes: Vec<u8> = if !ENABLE_NORMALIZE.with_borrow(|b| *b) {
8184
let encoded_params = ethers_core::abi::encode(&args);
8285
let short_signature: Vec<u8> = sha3::Keccak256::digest(tokens[0])[0..4].to_vec();
8386
let bytes: Vec<u8> = short_signature.into_iter().chain(encoded_params).collect();

testool/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct Config {
1616
#[derive(Debug, Clone, Deserialize)]
1717
pub struct TestSuite {
1818
pub id: String,
19-
pub path: String,
19+
pub paths: Vec<String>,
2020
pub max_gas: u64,
2121
pub max_steps: u64,
2222

@@ -28,7 +28,7 @@ impl Default for TestSuite {
2828
fn default() -> Self {
2929
Self {
3030
id: "default".to_string(),
31-
path: String::default(),
31+
paths: vec![],
3232
max_gas: u64::MAX,
3333
max_steps: u64::MAX,
3434
ignore_tests: Some(Filter::any()),

testool/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ fn go() -> Result<()> {
173173
let compiler = Compiler::new(true, Some(PathBuf::from(CODEHASH_FILE)))?;
174174
let suite = config.suite(&args.suite)?.clone();
175175
let mut state_tests = load_statetests_suite(&suite, config, compiler)?;
176-
log::info!("{} tests collected in {}", state_tests.len(), suite.path);
176+
log::info!(
177+
"{} tests collected in {}",
178+
state_tests.len(),
179+
suite.paths.join(", ")
180+
);
177181

178182
if args.ls {
179183
let mut list: Vec<_> = state_tests.into_iter().map(|t| t.id).collect();

testool/src/statetest/suite.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ pub fn load_statetests_suite(
2222
let skip_paths: Vec<&String> = config.skip_paths.iter().flat_map(|t| &t.paths).collect();
2323
let skip_tests: Vec<&String> = config.skip_tests.iter().flat_map(|t| &t.tests).collect();
2424

25-
let tcs = glob::glob(&suite.path)
25+
let tcs = suite
26+
.paths
27+
.iter()
28+
.map(|p| glob::glob(p))
29+
.collect::<Result<Vec<glob::Paths>, glob::PatternError>>()
2630
.context("failed to read glob")?
31+
.into_iter()
32+
.flatten()
2733
.filter_map(|v| v.ok())
2834
.filter(|f| {
2935
!skip_paths

testool/src/statetest/yaml.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{
22
parse,
33
spec::{AccountMatch, Env, StateTest, DEFAULT_BASE_FEE},
44
};
5-
use crate::{utils::MainnetFork, Compiler};
5+
use crate::{abi, utils::MainnetFork, Compiler};
66
use anyhow::{anyhow, bail, Context, Result};
77
use eth_types::{geth_types::Account, Address, Bytes, H256, U256};
88
use ethers_core::{k256::ecdsa::SigningKey, utils::secret_key_to_address};
@@ -50,6 +50,13 @@ impl<'a> YamlStateTestBuilder<'a> {
5050

5151
/// generates `StateTest` vectors from a ethereum yaml test specification
5252
pub fn load_yaml(&mut self, path: &str, source: &str) -> Result<Vec<StateTest>> {
53+
// Shoule be false for stEIP1153-transientStorage,
54+
// due to this bug https://github.com/ethereum/tests/issues/1369
55+
if path.contains("stEIP1153-transientStorage") {
56+
abi::ENABLE_NORMALIZE.with_borrow_mut(|b| *b = false)
57+
} else {
58+
abi::ENABLE_NORMALIZE.with_borrow_mut(|b| *b = true)
59+
}
5360
//log::trace!("load_yaml {path}");
5461
// get the yaml root element
5562
let doc = yaml_rust::YamlLoader::load_from_str(source)

0 commit comments

Comments
 (0)