From 56c059588d37e321cca2df46613a362fc813c3e3 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Sat, 16 Jan 2016 21:08:04 +0100 Subject: [PATCH] Changing state tests to support transition --- res/ethereum/frontier_like_test.json | 34 ++++++++++++++++++++++++++++ src/ethereum/mod.rs | 3 +++ src/tests/state.rs | 17 ++------------ 3 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 res/ethereum/frontier_like_test.json diff --git a/res/ethereum/frontier_like_test.json b/res/ethereum/frontier_like_test.json new file mode 100644 index 000000000..b5cbec465 --- /dev/null +++ b/res/ethereum/frontier_like_test.json @@ -0,0 +1,34 @@ +{ + "engineName": "Frontier (Test)", + "engineName": "Ethash", + "params": { + "accountStartNonce": "0x00", + "frontierCompatibilityModeLimit": "0x0dbba0", + "maximumExtraDataSize": "0x20", + "tieBreakingGas": false, + "minGasLimit": "0x1388", + "gasLimitBoundDivisor": "0x0400", + "minimumDifficulty": "0x020000", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "blockReward": "0x4563918244F40000", + "registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b", + "networkID" : "0x1" + }, + "genesis": { + "nonce": "0x0000000000000042", + "difficulty": "0x400000000", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "gasLimit": "0x1388" + }, + "accounts": { + "0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } }, + "0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } }, + "0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } }, + "0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } } + } +} diff --git a/src/ethereum/mod.rs b/src/ethereum/mod.rs index 832afa2ec..603a64e7d 100644 --- a/src/ethereum/mod.rs +++ b/src/ethereum/mod.rs @@ -23,6 +23,9 @@ pub fn new_frontier_test() -> Spec { Spec::from_json_utf8(include_bytes!("../../ /// Create a new Homestead chain spec as though it never changed from Frontier. pub fn new_homestead_test() -> Spec { Spec::from_json_utf8(include_bytes!("../../res/ethereum/homestead_test.json")) } +/// Create a new Frontier main net chain spec without genesis accounts. +pub fn new_frontier_like_test() -> Spec { Spec::from_json_utf8(include_bytes!("../../res/ethereum/frontier_like_test.json")) } + /// Create a new Morden chain spec. pub fn new_morden() -> Spec { Spec::from_json_utf8(include_bytes!("../../res/ethereum/morden.json")) } diff --git a/src/tests/state.rs b/src/tests/state.rs index d0da24128..119e7037a 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -4,26 +4,14 @@ use pod_state::*; use state_diff::*; use ethereum; -const HOMESTEAD_BLOCK : u64 = 0x0dbba0; - fn do_json_test(json_data: &[u8]) -> Vec { let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid"); let mut failed = Vec::new(); - let engine = |block_number: u64| { - if block_number >= HOMESTEAD_BLOCK { - ethereum::new_homestead_test().to_engine().unwrap() - } else { - ethereum::new_frontier_test().to_engine().unwrap() - } - }; - + let engine = ethereum::new_frontier_like_test().to_engine().unwrap(); flush(format!("\n")); for (name, test) in json.as_object().unwrap() { - if name != "createNameRegistratorPerTxsAt" { - continue; - } let mut fail = false; { let mut fail_unless = |cond: bool| if !cond && !fail { @@ -35,9 +23,8 @@ fn do_json_test(json_data: &[u8]) -> Vec { flush(format!(" - {}...", name)); - let env = EnvInfo::from_json(&test["env"]); - let engine = engine(env.number); let t = Transaction::from_json(&test["transaction"]); + let env = EnvInfo::from_json(&test["env"]); let _out = Bytes::from_json(&test["out"]); let post_state_root = xjson!(&test["postStateRoot"]); let pre = PodState::from_json(&test["pre"]);