revert moves to Spec

This commit is contained in:
keorn 2016-11-14 10:04:34 +00:00
parent 15d748c2f7
commit 2d4b4cf5c9
11 changed files with 88 additions and 78 deletions

View File

@ -423,13 +423,13 @@ mod tests {
use env_info::EnvInfo;
use error::{BlockError, Error};
use header::Header;
use spec::Spec;
use super::super::{new_morden, new_homestead_test};
use super::{Ethash, EthashParams};
use rlp;
#[test]
fn on_close_block() {
let spec = Spec::new_ethereum_morden();
let spec = new_morden();
let engine = &*spec.engine;
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db();
@ -443,7 +443,7 @@ mod tests {
#[test]
fn on_close_block_with_uncle() {
let spec = Spec::new_ethereum_morden();
let spec = new_morden();
let engine = &*spec.engine;
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db();
@ -463,14 +463,14 @@ mod tests {
#[test]
fn has_valid_metadata() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
assert!(!engine.name().is_empty());
assert!(engine.version().major >= 1);
}
#[test]
fn can_return_schedule() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
let schedule = engine.schedule(&EnvInfo {
number: 10000000,
author: 0.into(),
@ -498,8 +498,8 @@ mod tests {
#[test]
fn can_do_seal_verification_fail() {
let engine = Spec::new_ethereum_morden().engine;
//let engine = Ethash::new_test(Spec::new_ethereum_morden());
let engine = new_morden().engine;
//let engine = Ethash::new_test(new_morden());
let header: Header = Header::default();
let verify_result = engine.verify_block_basic(&header, None);
@ -513,7 +513,7 @@ mod tests {
#[test]
fn can_do_difficulty_verification_fail() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
let mut header: Header = Header::default();
header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]);
@ -528,7 +528,7 @@ mod tests {
#[test]
fn can_do_proof_of_work_verification_fail() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
let mut header: Header = Header::default();
header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]);
header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap());
@ -544,7 +544,7 @@ mod tests {
#[test]
fn can_do_seal_unordered_verification_fail() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
let header: Header = Header::default();
let verify_result = engine.verify_block_unordered(&header, None);
@ -558,7 +558,7 @@ mod tests {
#[test]
fn can_do_seal256_verification_fail() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
let mut header: Header = Header::default();
header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]);
let verify_result = engine.verify_block_unordered(&header, None);
@ -572,7 +572,7 @@ mod tests {
#[test]
fn can_do_proof_of_work_unordered_verification_fail() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
let mut header: Header = Header::default();
header.set_seal(vec![rlp::encode(&H256::from("b251bd2e0283d0658f2cadfdc8ca619b5de94eca5742725e2e757dd13ed7503d")).to_vec(), rlp::encode(&H64::zero()).to_vec()]);
header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap());
@ -588,7 +588,7 @@ mod tests {
#[test]
fn can_verify_block_family_genesis_fail() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
let header: Header = Header::default();
let parent_header: Header = Header::default();
@ -603,7 +603,7 @@ mod tests {
#[test]
fn can_verify_block_family_difficulty_fail() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
let mut header: Header = Header::default();
header.set_number(2);
let mut parent_header: Header = Header::default();
@ -620,7 +620,7 @@ mod tests {
#[test]
fn can_verify_block_family_gas_fail() {
let engine = Spec::new_ethereum_morden().engine;
let engine = new_morden().engine;
let mut header: Header = Header::default();
header.set_number(2);
header.set_difficulty(U256::from_str("0000000000000000000000000000000000000000000000000000000000020000").unwrap());
@ -648,7 +648,7 @@ mod tests {
#[test]
fn difficulty_frontier() {
let spec = Spec::new_ethereum_homestead_test();
let spec = new_homestead_test();
let ethparams = get_default_ethash_params();
let ethash = Ethash::new(spec.params, ethparams, BTreeMap::new());
@ -666,7 +666,7 @@ mod tests {
#[test]
fn difficulty_homestead() {
let spec = Spec::new_ethereum_homestead_test();
let spec = new_homestead_test();
let ethparams = get_default_ethash_params();
let ethash = Ethash::new(spec.params, ethparams, BTreeMap::new());
@ -684,7 +684,7 @@ mod tests {
#[test]
fn difficulty_classic_bomb_delay() {
let spec = Spec::new_ethereum_homestead_test();
let spec = new_homestead_test();
let ethparams = EthashParams {
ecip1010_pause_transition: 3000000,
..get_default_ethash_params()
@ -717,7 +717,7 @@ mod tests {
#[test]
fn test_difficulty_bomb_continue() {
let spec = Spec::new_ethereum_homestead_test();
let spec = new_homestead_test();
let ethparams = EthashParams {
ecip1010_pause_transition: 3000000,
ecip1010_continue_transition: 5000000,

View File

@ -27,17 +27,56 @@ pub mod denominations;
pub use self::ethash::{Ethash};
pub use self::denominations::*;
use super::spec::*;
fn load(b: &[u8]) -> Spec {
Spec::load(b).expect("chain spec is invalid")
}
/// Create a new Olympic chain spec.
pub fn new_olympic() -> Spec { load(include_bytes!("../../res/ethereum/olympic.json")) }
/// Create a new Frontier mainnet chain spec.
pub fn new_frontier() -> Spec { load(include_bytes!("../../res/ethereum/frontier.json")) }
/// Create a new Frontier mainnet chain spec without the DAO hardfork.
pub fn new_classic() -> Spec { load(include_bytes!("../../res/ethereum/classic.json")) }
/// Create a new Frontier mainnet chain spec without the DAO hardfork.
pub fn new_expanse() -> Spec { load(include_bytes!("../../res/ethereum/expanse.json")) }
/// Create a new Frontier chain spec as though it never changes to Homestead.
pub fn new_frontier_test() -> Spec { load(include_bytes!("../../res/ethereum/frontier_test.json")) }
/// Create a new Homestead chain spec as though it never changed from Frontier.
pub fn new_homestead_test() -> Spec { load(include_bytes!("../../res/ethereum/homestead_test.json")) }
/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier.
pub fn new_eip150_test() -> Spec { load(include_bytes!("../../res/ethereum/eip150_test.json")) }
/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier.
pub fn new_eip161_test() -> Spec { load(include_bytes!("../../res/ethereum/eip161_test.json")) }
/// Create a new Frontier/Homestead/DAO chain spec with transition points at #5 and #8.
pub fn new_transition_test() -> Spec { load(include_bytes!("../../res/ethereum/transition_test.json")) }
/// Create a new Frontier main net chain spec without genesis accounts.
pub fn new_mainnet_like() -> Spec { load(include_bytes!("../../res/ethereum/frontier_like_test.json")) }
/// Create a new Morden chain spec.
pub fn new_morden() -> Spec { load(include_bytes!("../../res/ethereum/morden.json")) }
#[cfg(test)]
mod tests {
use util::*;
use state::*;
use super::*;
use tests::helpers::*;
use spec::Spec;
use views::BlockView;
#[test]
fn ensure_db_good() {
let spec = Spec::new_ethereum_morden();
let spec = new_morden();
let engine = &spec.engine;
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db();
@ -54,7 +93,7 @@ mod tests {
#[test]
fn morden() {
let morden = Spec::new_ethereum_morden();
let morden = new_morden();
assert_eq!(morden.state_root(), "f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9".into());
let genesis = morden.genesis_block();
@ -65,7 +104,7 @@ mod tests {
#[test]
fn frontier() {
let frontier = Spec::new_ethereum_frontier();
let frontier = new_frontier();
assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into());
let genesis = frontier.genesis_block();

View File

@ -17,7 +17,7 @@
use super::test_common::*;
use client::{BlockChainClient, Client, ClientConfig};
use block::Block;
use spec::Spec;
use ethereum;
use tests::helpers::*;
use devtools::*;
use spec::Genesis;
@ -46,11 +46,11 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
let genesis = Genesis::from(blockchain.genesis());
let state = From::from(blockchain.pre_state.clone());
let mut spec = match era {
ChainEra::Frontier => Spec::new_ethereum_frontier_test(),
ChainEra::Homestead => Spec::new_ethereum_homestead_test(),
ChainEra::Eip150 => Spec::new_ethereum_eip150_test(),
ChainEra::Eip161 => Spec::new_ethereum_eip161_test(),
ChainEra::TransitionTest => Spec::new_ethereum_transition_test(),
ChainEra::Frontier => ethereum::new_frontier_test(),
ChainEra::Homestead => ethereum::new_homestead_test(),
ChainEra::Eip150 => ethereum::new_eip150_test(),
ChainEra::Eip161 => ethereum::new_eip161_test(),
ChainEra::TransitionTest => ethereum::new_transition_test(),
};
spec.set_genesis_state(state);
spec.overwrite_genesis_params(genesis);

View File

@ -18,7 +18,7 @@ use super::test_common::*;
use tests::helpers::*;
use pod_state::{self, PodState};
use log_entry::LogEntry;
use spec::Spec;
use ethereum;
use ethjson;
pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
@ -26,11 +26,11 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
let tests = ethjson::state::Test::load(json_data).unwrap();
let mut failed = Vec::new();
let engine = match era {
ChainEra::Frontier => Spec::new_ethereum_mainnet_like().engine,
ChainEra::Homestead => Spec::new_ethereum_homestead_test().engine,
ChainEra::Eip150 => Spec::new_ethereum_eip150_test().engine,
ChainEra::Eip161 => Spec::new_ethereum_eip161_test().engine,
ChainEra::TransitionTest => Spec::new_ethereum_transition_test().engine,
ChainEra::Frontier => ethereum::new_mainnet_like().engine,
ChainEra::Homestead => ethereum::new_homestead_test().engine,
ChainEra::Eip150 => ethereum::new_eip150_test().engine,
ChainEra::Eip161 => ethereum::new_eip161_test().engine,
ChainEra::TransitionTest => ethereum::new_transition_test().engine,
};
for (name, test) in tests.into_iter() {

View File

@ -27,12 +27,12 @@
//! extern crate ethcore_util as util;
//! extern crate ethcore;
//! use std::env;
//! use ethcore::spec::Spec;
//! use ethcore::ethereum;
//! use ethcore::client::{Client, ClientConfig};
//! use ethcore::miner::{Miner, MinerService};
//!
//! fn main() {
//! let miner: Miner = Miner::with_spec(&Spec::new_ethereum_frontier());
//! let miner: Miner = Miner::with_spec(&ethereum::new_frontier());
//! // get status
//! assert_eq!(miner.status().transactions_in_pending_queue, 0);
//!

View File

@ -280,39 +280,6 @@ impl Spec {
/// Create a new Spec with InstantSeal consensus which does internal sealing (not requiring work).
pub fn new_instant() -> Spec { load_bundled!("instant_seal") }
/// Create a new Olympic chain spec.
pub fn new_ethereum_olympic() -> Spec { load_bundled!("ethereum/olympic") }
/// Create a new Frontier mainnet chain spec.
pub fn new_ethereum_frontier() -> Spec { load_bundled!("ethereum/frontier") }
/// Create a new Frontier mainnet chain spec without the DAO hardfork.
pub fn new_ethereum_classic() -> Spec { load_bundled!("ethereum/classic") }
/// Create a new Frontier mainnet chain spec without the DAO hardfork.
pub fn new_expanse() -> Spec { load_bundled!("expanse") }
/// Create a new Frontier chain spec as though it never changes to Homestead.
pub fn new_ethereum_frontier_test() -> Spec { load_bundled!("ethereum/frontier_test") }
/// Create a new Homestead chain spec as though it never changed from Frontier.
pub fn new_ethereum_homestead_test() -> Spec { load_bundled!("ethereum/homestead_test") }
/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier.
pub fn new_ethereum_eip150_test() -> Spec { load_bundled!("ethereum/eip150_test") }
/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier.
pub fn new_ethereum_eip161_test() -> Spec { load_bundled!("ethereum/eip161_test") }
/// Create a new Frontier/Homestead/DAO chain spec with transition points at #5 and #8.
pub fn new_ethereum_transition_test() -> Spec { load_bundled!("ethereum/transition_test") }
/// Create a new Frontier main net chain spec without genesis accounts.
pub fn new_ethereum_mainnet_like() -> Spec { load_bundled!("ethereum/frontier_like_test") }
/// Create a new Morden chain spec.
pub fn new_ethereum_morden() -> Spec { load_bundled!("ethereum/morden") }
}
#[cfg(test)]

View File

@ -17,6 +17,7 @@
use io::IoChannel;
use client::{BlockChainClient, MiningBlockChainClient, Client, ClientConfig, BlockID};
use state::CleanupMode;
use ethereum;
use block::IsBlock;
use tests::helpers::*;
use types::filter::Filter;
@ -49,7 +50,7 @@ fn imports_from_empty() {
#[test]
fn should_return_registrar() {
let dir = RandomTempPath::new();
let spec = Spec::new_ethereum_morden();
let spec = ethereum::new_morden();
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let client = Client::new(

View File

@ -27,6 +27,7 @@ use state::*;
use evm::Schedule;
use engines::Engine;
use env_info::EnvInfo;
use ethereum;
use ethereum::ethash::EthashParams;
use devtools::*;
use miner::Miner;
@ -52,7 +53,7 @@ pub struct TestEngine {
impl TestEngine {
pub fn new(max_depth: usize) -> TestEngine {
TestEngine {
engine: Spec::new_ethereum_frontier_test().engine,
engine: ethereum::new_frontier_test().engine,
max_depth: max_depth,
}
}

View File

@ -19,6 +19,7 @@ use std::time::Duration;
use util::{Address, U256, version_data};
use util::journaldb::Algorithm;
use ethcore::spec::Spec;
use ethcore::ethereum;
use ethcore::client::Mode;
use ethcore::miner::{GasPricer, GasPriceCalibratorOptions};
use user_defaults::UserDefaults;
@ -60,11 +61,11 @@ impl str::FromStr for SpecType {
impl SpecType {
pub fn spec(&self) -> Result<Spec, String> {
match *self {
SpecType::Mainnet => Ok(Spec::new_ethereum_frontier()),
SpecType::Testnet => Ok(Spec::new_ethereum_morden()),
SpecType::Olympic => Ok(Spec::new_ethereum_olympic()),
SpecType::Classic => Ok(Spec::new_ethereum_classic()),
SpecType::Expanse => Ok(Spec::new_expanse()),
SpecType::Mainnet => Ok(ethereum::new_frontier()),
SpecType::Testnet => Ok(ethereum::new_morden()),
SpecType::Olympic => Ok(ethereum::new_olympic()),
SpecType::Classic => Ok(ethereum::new_classic()),
SpecType::Expanse => Ok(ethereum::new_expanse()),
SpecType::Dev => Ok(Spec::new_instant()),
SpecType::Custom(ref filename) => {
let file = try!(fs::File::open(filename).map_err(|_| "Could not load specification file."));

View File

@ -23,6 +23,7 @@ use ethcore::ids::BlockID;
use ethcore::spec::{Genesis, Spec};
use ethcore::block::Block;
use ethcore::views::BlockView;
use ethcore::ethereum;
use ethcore::miner::{MinerOptions, Banning, GasPricer, MinerService, ExternalMiner, Miner, PendingSet, PrioritizationStrategy, GasLimit};
use ethcore::account_provider::AccountProvider;
use devtools::RandomTempPath;
@ -78,7 +79,7 @@ fn snapshot_service() -> Arc<TestSnapshotService> {
fn make_spec(chain: &BlockChain) -> Spec {
let genesis = Genesis::from(chain.genesis());
let mut spec = Spec::new_ethereum_frontier_test();
let mut spec = ethereum::new_frontier_test();
let state = chain.pre_state.clone().into();
spec.set_genesis_state(state);
spec.overwrite_genesis_params(genesis);