Changing state tests to support transition

This commit is contained in:
Tomusdrw 2016-01-16 21:08:04 +01:00
parent 9849ce08e0
commit 56c059588d
3 changed files with 39 additions and 15 deletions

View File

@ -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 } } }
}
}

View File

@ -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. /// 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")) } 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. /// Create a new Morden chain spec.
pub fn new_morden() -> Spec { Spec::from_json_utf8(include_bytes!("../../res/ethereum/morden.json")) } pub fn new_morden() -> Spec { Spec::from_json_utf8(include_bytes!("../../res/ethereum/morden.json")) }

View File

@ -4,26 +4,14 @@ use pod_state::*;
use state_diff::*; use state_diff::*;
use ethereum; use ethereum;
const HOMESTEAD_BLOCK : u64 = 0x0dbba0;
fn do_json_test(json_data: &[u8]) -> Vec<String> { fn do_json_test(json_data: &[u8]) -> Vec<String> {
let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid"); let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid");
let mut failed = Vec::new(); let mut failed = Vec::new();
let engine = |block_number: u64| { let engine = ethereum::new_frontier_like_test().to_engine().unwrap();
if block_number >= HOMESTEAD_BLOCK {
ethereum::new_homestead_test().to_engine().unwrap()
} else {
ethereum::new_frontier_test().to_engine().unwrap()
}
};
flush(format!("\n")); flush(format!("\n"));
for (name, test) in json.as_object().unwrap() { for (name, test) in json.as_object().unwrap() {
if name != "createNameRegistratorPerTxsAt" {
continue;
}
let mut fail = false; let mut fail = false;
{ {
let mut fail_unless = |cond: bool| if !cond && !fail { let mut fail_unless = |cond: bool| if !cond && !fail {
@ -35,9 +23,8 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
flush(format!(" - {}...", name)); flush(format!(" - {}...", name));
let env = EnvInfo::from_json(&test["env"]);
let engine = engine(env.number);
let t = Transaction::from_json(&test["transaction"]); let t = Transaction::from_json(&test["transaction"]);
let env = EnvInfo::from_json(&test["env"]);
let _out = Bytes::from_json(&test["out"]); let _out = Bytes::from_json(&test["out"]);
let post_state_root = xjson!(&test["postStateRoot"]); let post_state_root = xjson!(&test["postStateRoot"]);
let pre = PodState::from_json(&test["pre"]); let pre = PodState::from_json(&test["pre"]);