fix state test for openethereum-evm (#480)

* fix state test for openethereum-evm
This commit is contained in:
Dusan Stanivukovic 2021-07-10 08:53:53 +02:00 committed by GitHub
parent aa09846200
commit 33908e8361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,6 +46,8 @@ use bytes::Bytes;
use docopt::Docopt; use docopt::Docopt;
use ethcore::{json_tests, spec, TrieSpec}; use ethcore::{json_tests, spec, TrieSpec};
use ethereum_types::{Address, U256}; use ethereum_types::{Address, U256};
use ethjson::spec::ForkSpec;
use evm::EnvInfo;
use rustc_hex::FromHex; use rustc_hex::FromHex;
use std::{fmt, fs, path::PathBuf, sync::Arc}; use std::{fmt, fs, path::PathBuf, sync::Arc};
use vm::{ActionParams, CallType}; use vm::{ActionParams, CallType};
@ -192,10 +194,18 @@ fn run_state_test(args: Args) {
} }
let multitransaction = test.transaction; let multitransaction = test.transaction;
let env_info = test.env.into(); let env_info: EnvInfo = test.env.into();
let pre = test.pre_state.into(); let pre = test.pre_state.into();
for (spec, states) in test.post_states { for (spec, states) in test.post_states {
//hardcode base fee for part of the london tests, that miss base fee field in env
let mut test_env = env_info.clone();
if spec >= ForkSpec::London {
if test_env.base_fee.is_none() {
test_env.base_fee = Some(0x0a.into());
}
}
if let Some(false) = only_chain if let Some(false) = only_chain
.as_ref() .as_ref()
.map(|only_chain| &format!("{:?}", spec).to_lowercase() == only_chain) .map(|only_chain| &format!("{:?}", spec).to_lowercase() == only_chain)
@ -218,7 +228,7 @@ fn run_state_test(args: Args) {
&spec, &spec,
&pre, &pre,
post_root, post_root,
&env_info, &test_env,
transaction, transaction,
display::json::Informant::new(config), display::json::Informant::new(config),
trie_spec, trie_spec,
@ -231,7 +241,7 @@ fn run_state_test(args: Args) {
&spec, &spec,
&pre, &pre,
post_root, post_root,
&env_info, &test_env,
transaction, transaction,
display::std_json::Informant::err_only(config), display::std_json::Informant::err_only(config),
trie_spec, trie_spec,
@ -243,7 +253,7 @@ fn run_state_test(args: Args) {
&spec, &spec,
&pre, &pre,
post_root, post_root,
&env_info, &test_env,
transaction, transaction,
display::std_json::Informant::out_only(config), display::std_json::Informant::out_only(config),
trie_spec, trie_spec,
@ -255,7 +265,7 @@ fn run_state_test(args: Args) {
&spec, &spec,
&pre, &pre,
post_root, post_root,
&env_info, &test_env,
transaction, transaction,
display::std_json::Informant::new_default(config), display::std_json::Informant::new_default(config),
trie_spec, trie_spec,
@ -268,7 +278,7 @@ fn run_state_test(args: Args) {
&spec, &spec,
&pre, &pre,
post_root, post_root,
&env_info, &test_env,
transaction, transaction,
display::simple::Informant::new(config), display::simple::Informant::new(config),
trie_spec, trie_spec,