This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Update state tests execution model #9440
Merged
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1b20809
Update & fix JSON state tests.
tomusdrw bfb380e
Update tests to be able to run ethtest at
cheme b8188c5
Switch to same commit for submodule ethereum/test as geth (next inclu…
cheme 83f48e6
Remove trietestnextprev as it would require to parse differently and
cheme 5dbae4f
Support new (shitty) format of transaction tests.
tomusdrw f6aa443
Ignore junk in ethereum/tests repo.
tomusdrw 1d0aecc
Ignore incorrect test.
tomusdrw 8321952
Update to a later commit
cheme 38dc09b
Merge my branch into td-statetests, mostly keep Tomus version and fix
cheme 25c6a42
Move block number to a constant.
tomusdrw 60dceb2
Fix ZK2 test - touched account should also be cleared.
tomusdrw f68476d
Merge branch 'master' into td-statetests
tomusdrw 86ead07
Merge branch 'master' into td-statetests
cheme 712d6d1
Merge branch 'master' into td-statetests
cheme e355c6d
Fix conflict resolution
cheme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Submodule tests
updated
19225 files
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 |
---|---|---|
|
@@ -41,6 +41,7 @@ pub fn run_test_path<H: FnMut(&str, HookType)>( | |
os.push(".json"); | ||
os | ||
}).collect(); | ||
let extension = path.extension().and_then(|s| s.to_str()); | ||
if path.is_dir() { | ||
for p in read_dir(path).unwrap().filter_map(|e| { | ||
let e = e.unwrap(); | ||
|
@@ -51,6 +52,8 @@ pub fn run_test_path<H: FnMut(&str, HookType)>( | |
}}) { | ||
run_test_path(&p, skip, runner, start_stop_hook) | ||
} | ||
} else if extension == Some("swp") || extension == None { | ||
// Ignore junk | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, there are some |
||
} else { | ||
let mut path = p.to_path_buf(); | ||
path.set_extension("json"); | ||
|
@@ -64,7 +67,10 @@ pub fn run_test_file<H: FnMut(&str, HookType)>( | |
start_stop_hook: &mut H | ||
) { | ||
let mut data = Vec::new(); | ||
let mut file = File::open(&path).expect("Error opening test file"); | ||
let mut file = match File::open(&path) { | ||
Ok(file) => file, | ||
Err(_) => panic!("Error opening test file at: {:?}", path), | ||
}; | ||
file.read_to_end(&mut data).expect("Error reading test file"); | ||
let results = runner(&data, start_stop_hook); | ||
let empty: [String; 0] = []; | ||
|
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 |
---|---|---|
|
@@ -16,10 +16,11 @@ | |
|
||
use std::path::Path; | ||
use super::test_common::*; | ||
use evm; | ||
use client::EvmTestClient; | ||
use header::Header; | ||
use ethjson; | ||
use rlp::Rlp; | ||
use transaction::{Action, UnverifiedTransaction, SignedTransaction}; | ||
use transaction::UnverifiedTransaction; | ||
|
||
/// Run transaction jsontests on a given folder. | ||
pub fn run_test_path<H: FnMut(&str, HookType)>(p: &Path, skip: &[&'static str], h: &mut H) { | ||
|
@@ -34,52 +35,54 @@ pub fn run_test_file<H: FnMut(&str, HookType)>(p: &Path, h: &mut H) { | |
fn do_json_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mut H) -> Vec<String> { | ||
let tests = ethjson::transaction::Test::load(json_data).unwrap(); | ||
let mut failed = Vec::new(); | ||
let frontier_schedule = evm::Schedule::new_frontier(); | ||
let homestead_schedule = evm::Schedule::new_homestead(); | ||
let byzantium_schedule = evm::Schedule::new_byzantium(); | ||
for (name, test) in tests.into_iter() { | ||
start_stop_hook(&name, HookType::OnStart); | ||
|
||
let mut fail_unless = |cond: bool, title: &str| if !cond { failed.push(name.clone()); println!("Transaction failed: {:?}: {:?}", name, title); }; | ||
|
||
let number: Option<u64> = test.block_number.map(Into::into); | ||
let schedule = match number { | ||
None => &frontier_schedule, | ||
Some(x) if x < 1_150_000 => &frontier_schedule, | ||
Some(x) if x < 3_000_000 => &homestead_schedule, | ||
Some(_) => &byzantium_schedule | ||
}; | ||
let allow_chain_id_of_one = number.map_or(false, |n| n >= 2_675_000); | ||
let allow_unsigned = number.map_or(false, |n| n >= 3_000_000); | ||
|
||
let rlp: Vec<u8> = test.rlp.into(); | ||
let res = Rlp::new(&rlp) | ||
.as_val() | ||
.map_err(::error::Error::from) | ||
.and_then(|t: UnverifiedTransaction| { | ||
t.validate(schedule, schedule.have_delegate_call, allow_chain_id_of_one, allow_unsigned).map_err(Into::into) | ||
}); | ||
|
||
fail_unless(test.transaction.is_none() == res.is_err(), "Validity different"); | ||
if let (Some(tx), Some(sender)) = (test.transaction, test.sender) { | ||
let t = res.unwrap(); | ||
fail_unless(SignedTransaction::new(t.clone()).unwrap().sender() == sender.into(), "sender mismatch"); | ||
let is_acceptable_chain_id = match t.chain_id() { | ||
None => true, | ||
Some(1) if allow_chain_id_of_one => true, | ||
_ => false, | ||
for (spec_name, result) in test.post_state { | ||
let spec = match EvmTestClient::spec_from_json(&spec_name) { | ||
Some(spec) => spec, | ||
None => { | ||
println!(" - {} | {:?} Ignoring tests because of missing spec", name, spec_name); | ||
continue; | ||
} | ||
}; | ||
fail_unless(is_acceptable_chain_id, "Network ID unacceptable"); | ||
let data: Vec<u8> = tx.data.into(); | ||
fail_unless(t.data == data, "data mismatch"); | ||
fail_unless(t.gas_price == tx.gas_price.into(), "gas_price mismatch"); | ||
fail_unless(t.nonce == tx.nonce.into(), "nonce mismatch"); | ||
fail_unless(t.value == tx.value.into(), "value mismatch"); | ||
let to: Option<ethjson::hash::Address> = tx.to.into(); | ||
let to: Option<Address> = to.map(Into::into); | ||
match t.action { | ||
Action::Call(dest) => fail_unless(Some(dest) == to, "call/destination mismatch"), | ||
Action::Create => fail_unless(None == to, "create mismatch"), | ||
|
||
let mut fail_unless = |cond: bool, title: &str| if !cond { | ||
failed.push(format!("{}-{:?}", name, spec_name)); | ||
println!("Transaction failed: {:?}-{:?}: {:?}", name, spec_name, title); | ||
}; | ||
|
||
let rlp: Vec<u8> = test.rlp.clone().into(); | ||
let res = Rlp::new(&rlp) | ||
.as_val() | ||
.map_err(::error::Error::from) | ||
.and_then(|t: UnverifiedTransaction| { | ||
let mut header: Header = Default::default(); | ||
// Use high enough number to activate all required features. | ||
header.set_number(0x6ffffffffffffe); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps make it this number a named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. |
||
|
||
let minimal = t.gas_required(&spec.engine.schedule(header.number())).into(); | ||
if t.gas < minimal { | ||
return Err(::transaction::Error::InsufficientGas { | ||
minimal, got: t.gas, | ||
}.into()); | ||
} | ||
spec.engine.verify_transaction_basic(&t, &header)?; | ||
Ok(spec.engine.verify_transaction_unordered(t, &header)?) | ||
}); | ||
|
||
match (res, result.hash, result.sender) { | ||
(Ok(t), Some(hash), Some(sender)) => { | ||
fail_unless(t.sender() == sender.into(), "sender mismatch"); | ||
fail_unless(t.hash() == hash.into(), "hash mismatch"); | ||
}, | ||
(Err(_), None, None) => {}, | ||
data => { | ||
fail_unless( | ||
false, | ||
&format!("Validity different: {:?}", data) | ||
); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -92,13 +95,14 @@ fn do_json_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mu | |
failed | ||
} | ||
|
||
declare_test!{TransactionTests_ttEip155VitaliksHomesead, "TransactionTests/ttEip155VitaliksHomesead"} | ||
declare_test!{TransactionTests_ttEip155VitaliksEip158, "TransactionTests/ttEip155VitaliksEip158"} | ||
declare_test!{TransactionTests_ttEip158, "TransactionTests/ttEip158"} | ||
declare_test!{TransactionTests_ttFrontier, "TransactionTests/ttFrontier"} | ||
declare_test!{TransactionTests_ttHomestead, "TransactionTests/ttHomestead"} | ||
declare_test!{TransactionTests_ttVRuleEip158, "TransactionTests/ttVRuleEip158"} | ||
declare_test!{TransactionTests_ttWrongRLPFrontier, "TransactionTests/ttWrongRLPFrontier"} | ||
declare_test!{TransactionTests_ttWrongRLPHomestead, "TransactionTests/ttWrongRLPHomestead"} | ||
declare_test!{TransactionTests_ttConstantinople, "TransactionTests/ttConstantinople"} | ||
declare_test!{TransactionTests_ttSpecConstantinople, "TransactionTests/ttSpecConstantinople"} | ||
declare_test!{TransactionTests_ttAddress, "TransactionTests/ttAddress"} | ||
declare_test!{TransactionTests_ttData, "TransactionTests/ttData"} | ||
declare_test!{TransactionTests_ttGasLimit, "TransactionTests/ttGasLimit"} | ||
declare_test!{TransactionTests_ttGasPrice, "TransactionTests/ttGasPrice"} | ||
declare_test!{TransactionTests_ttNonce, "TransactionTests/ttNonce"} | ||
declare_test!{TransactionTests_ttRSValue, "TransactionTests/ttRSValue"} | ||
declare_test!{TransactionTests_ttSignature, "TransactionTests/ttSignature"} | ||
declare_test!{TransactionTests_ttValue, "TransactionTests/ttValue"} | ||
declare_test!{TransactionTests_ttVValue, "TransactionTests/ttVValue"} | ||
declare_test!{TransactionTests_ttWrongRLP, "TransactionTests/ttWrongRLP"} | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting to
0
enables the feature right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, otherwise some transaction tests for
EIP158
spec (which for us is actaully eip161_test.json) fail, cause they assume that eip155 is enabled as well.