ethcore test::helpers cleanup (#8086)

This commit is contained in:
Marek Kotewicz 2018-03-12 18:05:52 +01:00 committed by GitHub
parent 58a1671076
commit 373fdb65e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 115 additions and 94 deletions

View File

@ -635,7 +635,7 @@ pub fn enact_verified(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use tests::helpers::*; use tests::helpers::get_temp_state_db;
use super::*; use super::*;
use engines::EthEngine; use engines::EthEngine;
use vm::LastHashes; use vm::LastHashes;

View File

@ -1312,7 +1312,10 @@ mod tests {
use ethereum_types::*; use ethereum_types::*;
use receipt::{Receipt, TransactionOutcome}; use receipt::{Receipt, TransactionOutcome};
use blockchain::{BlockProvider, BlockChain, Config, ImportRoute}; use blockchain::{BlockProvider, BlockChain, Config, ImportRoute};
use tests::helpers::*; use tests::helpers::{
generate_dummy_blockchain, generate_dummy_blockchain_with_extra,
generate_dummy_empty_blockchain
};
use blockchain::generator::{BlockGenerator, BlockBuilder, BlockOptions}; use blockchain::generator::{BlockGenerator, BlockBuilder, BlockOptions};
use blockchain::extras::TransactionAddress; use blockchain::extras::TransactionAddress;
use transaction::{Transaction, Action}; use transaction::{Transaction, Action};

View File

@ -2205,7 +2205,7 @@ mod tests {
#[test] #[test]
fn should_not_cache_details_before_commit() { fn should_not_cache_details_before_commit() {
use client::{BlockChainClient, ChainInfo}; use client::{BlockChainClient, ChainInfo};
use tests::helpers::*; use tests::helpers::{generate_dummy_client, get_good_dummy_block_hash};
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;

View File

@ -1326,7 +1326,10 @@ mod tests {
use header::Header; use header::Header;
use rlp::encode; use rlp::encode;
use block::*; use block::*;
use tests::helpers::*; use tests::helpers::{
generate_dummy_client_with_spec_and_accounts, get_temp_state_db, generate_dummy_client,
TestNotify
};
use account_provider::AccountProvider; use account_provider::AccountProvider;
use spec::Spec; use spec::Spec;
use transaction::{Action, Transaction}; use transaction::{Action, Transaction};

View File

@ -199,7 +199,7 @@ mod tests {
use hash::keccak; use hash::keccak;
use ethereum_types::H520; use ethereum_types::H520;
use block::*; use block::*;
use tests::helpers::*; use tests::helpers::get_temp_state_db;
use account_provider::AccountProvider; use account_provider::AccountProvider;
use header::Header; use header::Header;
use spec::Spec; use spec::Spec;

View File

@ -56,7 +56,7 @@ impl<M: Machine> Engine<M> for InstantSeal<M>
mod tests { mod tests {
use std::sync::Arc; use std::sync::Arc;
use ethereum_types::{H520, Address}; use ethereum_types::{H520, Address};
use tests::helpers::*; use tests::helpers::{get_temp_state_db};
use spec::Spec; use spec::Spec;
use header::Header; use header::Header;
use block::*; use block::*;

View File

@ -783,7 +783,10 @@ mod tests {
use header::Header; use header::Header;
use client::ChainInfo; use client::ChainInfo;
use miner::MinerService; use miner::MinerService;
use tests::helpers::*; use tests::helpers::{
TestNotify, get_temp_state_db, generate_dummy_client,
generate_dummy_client_with_spec_and_accounts
};
use account_provider::AccountProvider; use account_provider::AccountProvider;
use spec::Spec; use spec::Spec;
use engines::{EthEngine, EngineError, Seal}; use engines::{EthEngine, EngineError, Seal};

View File

@ -487,7 +487,7 @@ mod tests {
use std::sync::Arc; use std::sync::Arc;
use ethereum_types::{H64, H256, U256, Address}; use ethereum_types::{H64, H256, U256, Address};
use block::*; use block::*;
use tests::helpers::*; use tests::helpers::get_temp_state_db;
use error::{BlockError, Error}; use error::{BlockError, Error};
use header::Header; use header::Header;
use spec::Spec; use spec::Spec;
@ -500,6 +500,36 @@ mod tests {
new_morden(&::std::env::temp_dir()) new_morden(&::std::env::temp_dir())
} }
fn get_default_ethash_params() -> EthashParams {
EthashParams {
minimum_difficulty: U256::from(131072),
difficulty_bound_divisor: U256::from(2048),
difficulty_increment_divisor: 10,
metropolis_difficulty_increment_divisor: 9,
homestead_transition: 1150000,
duration_limit: 13,
block_reward: 0.into(),
difficulty_hardfork_transition: u64::max_value(),
difficulty_hardfork_bound_divisor: U256::from(0),
bomb_defuse_transition: u64::max_value(),
eip100b_transition: u64::max_value(),
ecip1010_pause_transition: u64::max_value(),
ecip1010_continue_transition: u64::max_value(),
ecip1017_era_rounds: u64::max_value(),
mcip3_transition: u64::max_value(),
mcip3_miner_reward: 0.into(),
mcip3_ubi_reward: 0.into(),
mcip3_ubi_contract: "0000000000000000000000000000000000000001".into(),
mcip3_dev_reward: 0.into(),
mcip3_dev_contract: "0000000000000000000000000000000000000001".into(),
eip649_transition: u64::max_value(),
eip649_delay: 3_000_000,
eip649_reward: None,
expip2_transition: u64::max_value(),
expip2_duration_limit: 30,
}
}
#[test] #[test]
fn on_close_block() { fn on_close_block() {
let spec = test_spec(); let spec = test_spec();

View File

@ -140,7 +140,7 @@ mod tests {
use ethereum_types::U256; use ethereum_types::U256;
use state::*; use state::*;
use super::*; use super::*;
use tests::helpers::*; use tests::helpers::get_temp_state_db;
use views::BlockView; use views::BlockView;
#[test] #[test]

View File

@ -701,7 +701,7 @@ mod tests {
use error::ExecutionError; use error::ExecutionError;
use machine::EthereumMachine; use machine::EthereumMachine;
use state::{Substate, CleanupMode}; use state::{Substate, CleanupMode};
use tests::helpers::*; use tests::helpers::{get_temp_state_with_factory, get_temp_state};
use trace::trace; use trace::trace;
use trace::{FlatTrace, Tracer, NoopTracer, ExecutiveTracer}; use trace::{FlatTrace, Tracer, NoopTracer, ExecutiveTracer};
use trace::{VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, VMTracer, NoopVMTracer, ExecutiveVMTracer}; use trace::{VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, VMTracer, NoopVMTracer, ExecutiveVMTracer};

View File

@ -414,7 +414,7 @@ mod tests {
use ethereum_types::{U256, Address}; use ethereum_types::{U256, Address};
use evm::{EnvInfo, Ext, CallType}; use evm::{EnvInfo, Ext, CallType};
use state::{State, Substate}; use state::{State, Substate};
use tests::helpers::*; use tests::helpers::get_temp_state;
use super::*; use super::*;
use trace::{NoopTracer, NoopVMTracer}; use trace::{NoopTracer, NoopVMTracer};

View File

@ -25,7 +25,7 @@ use vm::{
CreateContractAddress, ReturnData, CreateContractAddress, ReturnData,
}; };
use externalities::*; use externalities::*;
use tests::helpers::*; use tests::helpers::get_temp_state;
use ethjson; use ethjson;
use trace::{Tracer, NoopTracer}; use trace::{Tracer, NoopTracer};
use trace::{VMTracer, NoopVMTracer}; use trace::{VMTracer, NoopVMTracer};

View File

@ -473,12 +473,25 @@ fn round_block_gas_limit(gas_limit: U256, lower_limit: U256, upper_limit: U256)
mod tests { mod tests {
use super::*; use super::*;
fn get_default_ethash_extensions() -> EthashExtensions {
EthashExtensions {
homestead_transition: 1150000,
eip150_transition: u64::max_value(),
eip160_transition: u64::max_value(),
eip161abc_transition: u64::max_value(),
eip161d_transition: u64::max_value(),
dao_hardfork_transition: u64::max_value(),
dao_hardfork_beneficiary: "0000000000000000000000000000000000000001".into(),
dao_hardfork_accounts: Vec::new(),
}
}
#[test] #[test]
fn ethash_gas_limit_is_multiple_of_determinant() { fn ethash_gas_limit_is_multiple_of_determinant() {
use ethereum_types::U256; use ethereum_types::U256;
let spec = ::ethereum::new_homestead_test(); let spec = ::ethereum::new_homestead_test();
let ethparams = ::tests::helpers::get_default_ethash_extensions(); let ethparams = get_default_ethash_extensions();
let machine = EthereumMachine::with_ethash_extensions( let machine = EthereumMachine::with_ethash_extensions(
spec.params().clone(), spec.params().clone(),

View File

@ -222,8 +222,8 @@ impl IoHandler<ClientIoMessage> for ClientIoHandler {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::{time, thread}; use std::{time, thread};
use spec::Spec;
use super::*; use super::*;
use tests::helpers::*;
use client::ClientConfig; use client::ClientConfig;
use std::sync::Arc; use std::sync::Arc;
use miner::Miner; use miner::Miner;
@ -235,7 +235,7 @@ mod tests {
let client_path = tempdir.path().join("client"); let client_path = tempdir.path().join("client");
let snapshot_path = tempdir.path().join("snapshot"); let snapshot_path = tempdir.path().join("snapshot");
let spec = get_test_spec(); let spec = Spec::new_test();
let service = ClientService::start( let service = ClientService::start(
ClientConfig::default(), ClientConfig::default(),
&spec, &spec,

View File

@ -633,7 +633,7 @@ mod tests {
use std::sync::Arc; use std::sync::Arc;
use service::ClientIoMessage; use service::ClientIoMessage;
use io::{IoService}; use io::{IoService};
use tests::helpers::get_test_spec; use spec::Spec;
use journaldb::Algorithm; use journaldb::Algorithm;
use error::Error; use error::Error;
use snapshot::{ManifestData, RestorationStatus, SnapshotService}; use snapshot::{ManifestData, RestorationStatus, SnapshotService};
@ -650,7 +650,7 @@ mod tests {
#[test] #[test]
fn sends_async_messages() { fn sends_async_messages() {
let service = IoService::<ClientIoMessage>::start().unwrap(); let service = IoService::<ClientIoMessage>::start().unwrap();
let spec = get_test_spec(); let spec = Spec::new_test();
let tempdir = TempDir::new("").unwrap(); let tempdir = TempDir::new("").unwrap();
let dir = tempdir.path().join("snapshot"); let dir = tempdir.path().join("snapshot");
@ -691,7 +691,7 @@ mod tests {
use ethereum_types::H256; use ethereum_types::H256;
use kvdb_rocksdb::DatabaseConfig; use kvdb_rocksdb::DatabaseConfig;
let spec = get_test_spec(); let spec = Spec::new_test();
let tempdir = TempDir::new("").unwrap(); let tempdir = TempDir::new("").unwrap();
let state_hashes: Vec<_> = (0..5).map(|_| H256::random()).collect(); let state_hashes: Vec<_> = (0..5).map(|_| H256::random()).collect();

View File

@ -1088,7 +1088,7 @@ mod tests {
use super::*; use super::*;
use ethkey::Secret; use ethkey::Secret;
use ethereum_types::{H256, U256, Address}; use ethereum_types::{H256, U256, Address};
use tests::helpers::*; use tests::helpers::{get_temp_state, get_temp_state_db};
use machine::EthereumMachine; use machine::EthereumMachine;
use vm::EnvInfo; use vm::EnvInfo;
use spec::*; use spec::*;

View File

@ -480,7 +480,7 @@ unsafe impl Sync for SyncAccount {}
mod tests { mod tests {
use ethereum_types::{H256, U256, Address}; use ethereum_types::{H256, U256, Address};
use kvdb::DBTransaction; use kvdb::DBTransaction;
use tests::helpers::*; use tests::helpers::{get_temp_state_db};
use state::{Account, Backend}; use state::{Account, Backend};
use ethcore_logger::init_log; use ethcore_logger::init_log;

View File

@ -23,7 +23,10 @@ use state::{self, State, CleanupMode};
use executive::{Executive, TransactOptions}; use executive::{Executive, TransactOptions};
use ethereum; use ethereum;
use block::IsBlock; use block::IsBlock;
use tests::helpers::*; use tests::helpers::{
generate_dummy_client, push_blocks_to_client, get_test_client_with_blocks, get_good_dummy_block_seq,
generate_dummy_client_with_data, get_good_dummy_block, get_bad_state_dummy_block
};
use types::filter::Filter; use types::filter::Filter;
use ethereum_types::{U256, Address}; use ethereum_types::{U256, Address};
use kvdb_rocksdb::{Database, DatabaseConfig}; use kvdb_rocksdb::{Database, DatabaseConfig};
@ -38,7 +41,7 @@ use tempdir::TempDir;
#[test] #[test]
fn imports_from_empty() { fn imports_from_empty() {
let tempdir = TempDir::new("").unwrap(); let tempdir = TempDir::new("").unwrap();
let spec = get_test_spec(); let spec = Spec::new_test();
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap()); let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());
@ -77,7 +80,7 @@ fn should_return_registrar() {
#[test] #[test]
fn returns_state_root_basic() { fn returns_state_root_basic() {
let client = generate_dummy_client(6); let client = generate_dummy_client(6);
let test_spec = get_test_spec(); let test_spec = Spec::new_test();
let genesis_header = test_spec.genesis_header(); let genesis_header = test_spec.genesis_header();
assert!(client.state_data(genesis_header.state_root()).is_some()); assert!(client.state_data(genesis_header.state_root()).is_some());
@ -86,7 +89,7 @@ fn returns_state_root_basic() {
#[test] #[test]
fn imports_good_block() { fn imports_good_block() {
let tempdir = TempDir::new("").unwrap(); let tempdir = TempDir::new("").unwrap();
let spec = get_test_spec(); let spec = Spec::new_test();
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap()); let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());
@ -111,7 +114,7 @@ fn imports_good_block() {
#[test] #[test]
fn query_none_block() { fn query_none_block() {
let tempdir = TempDir::new("").unwrap(); let tempdir = TempDir::new("").unwrap();
let spec = get_test_spec(); let spec = Spec::new_test();
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap()); let client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());

View File

@ -1,3 +1,19 @@
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Tests of EVM integration with transaction execution. //! Tests of EVM integration with transaction execution.
use std::sync::Arc; use std::sync::Arc;
@ -6,7 +22,7 @@ use vm::{EnvInfo, ActionParams, ActionValue, CallType, ParamsType};
use evm::{Factory, VMType}; use evm::{Factory, VMType};
use executive::Executive; use executive::Executive;
use state::Substate; use state::Substate;
use tests::helpers::*; use tests::helpers::get_temp_state_with_factory;
use trace::{NoopVMTracer, NoopTracer}; use trace::{NoopVMTracer, NoopTracer};
use transaction::SYSTEM_ADDRESS; use transaction::SYSTEM_ADDRESS;

View File

@ -20,29 +20,22 @@ use block::{OpenBlock, Drain};
use blockchain::{BlockChain, Config as BlockChainConfig}; use blockchain::{BlockChain, Config as BlockChainConfig};
use bytes::Bytes; use bytes::Bytes;
use client::{Client, ClientConfig, ChainInfo, ImportBlock, ChainNotify}; use client::{Client, ClientConfig, ChainInfo, ImportBlock, ChainNotify};
use ethereum::ethash::EthashParams;
use ethkey::KeyPair; use ethkey::KeyPair;
use evm::Factory as EvmFactory; use evm::Factory as EvmFactory;
use factory::Factories; use factory::Factories;
use hash::keccak; use hash::keccak;
use header::Header; use header::Header;
use io::*; use io::*;
use machine::EthashExtensions;
use miner::Miner; use miner::Miner;
use parking_lot::RwLock; use parking_lot::RwLock;
use rlp::{self, RlpStream}; use rlp::{self, RlpStream};
use spec::*; use spec::Spec;
use state_db::StateDB; use state_db::StateDB;
use state::*; use state::*;
use std::sync::Arc; use std::sync::Arc;
use transaction::{Action, Transaction, SignedTransaction}; use transaction::{Action, Transaction, SignedTransaction};
use views::BlockView; use views::BlockView;
// TODO: move everything over to get_null_spec.
pub fn get_test_spec() -> Spec {
Spec::new_test()
}
pub fn create_test_block(header: &Header) -> Bytes { pub fn create_test_block(header: &Header) -> Bytes {
let mut rlp = RlpStream::new_list(3); let mut rlp = RlpStream::new_list(3);
rlp.append(header); rlp.append(header);
@ -100,16 +93,16 @@ pub fn generate_dummy_client_with_data(block_number: u32, txs_per_block: usize,
} }
pub fn generate_dummy_client_with_spec_and_data<F>(get_test_spec: F, block_number: u32, txs_per_block: usize, tx_gas_prices: &[U256]) -> Arc<Client> where F: Fn()->Spec { pub fn generate_dummy_client_with_spec_and_data<F>(test_spec: F, block_number: u32, txs_per_block: usize, tx_gas_prices: &[U256]) -> Arc<Client> where F: Fn()->Spec {
generate_dummy_client_with_spec_accounts_and_data(get_test_spec, None, block_number, txs_per_block, tx_gas_prices) generate_dummy_client_with_spec_accounts_and_data(test_spec, None, block_number, txs_per_block, tx_gas_prices)
} }
pub fn generate_dummy_client_with_spec_and_accounts<F>(get_test_spec: F, accounts: Option<Arc<AccountProvider>>) -> Arc<Client> where F: Fn()->Spec { pub fn generate_dummy_client_with_spec_and_accounts<F>(test_spec: F, accounts: Option<Arc<AccountProvider>>) -> Arc<Client> where F: Fn()->Spec {
generate_dummy_client_with_spec_accounts_and_data(get_test_spec, accounts, 0, 0, &[]) generate_dummy_client_with_spec_accounts_and_data(test_spec, accounts, 0, 0, &[])
} }
pub fn generate_dummy_client_with_spec_accounts_and_data<F>(get_test_spec: F, accounts: Option<Arc<AccountProvider>>, block_number: u32, txs_per_block: usize, tx_gas_prices: &[U256]) -> Arc<Client> where F: Fn()->Spec { pub fn generate_dummy_client_with_spec_accounts_and_data<F>(test_spec: F, accounts: Option<Arc<AccountProvider>>, block_number: u32, txs_per_block: usize, tx_gas_prices: &[U256]) -> Arc<Client> where F: Fn()->Spec {
let test_spec = get_test_spec(); let test_spec = test_spec();
let client_db = new_db(); let client_db = new_db();
let client = Client::new( let client = Client::new(
@ -179,7 +172,7 @@ pub fn generate_dummy_client_with_spec_accounts_and_data<F>(get_test_spec: F, ac
} }
pub fn push_blocks_to_client(client: &Arc<Client>, timestamp_salt: u64, starting_number: usize, block_number: usize) { pub fn push_blocks_to_client(client: &Arc<Client>, timestamp_salt: u64, starting_number: usize, block_number: usize) {
let test_spec = get_test_spec(); let test_spec = Spec::new_test();
let state_root = test_spec.genesis_header().state_root().clone(); let state_root = test_spec.genesis_header().state_root().clone();
let genesis_gas = test_spec.genesis_header().gas_limit().clone(); let genesis_gas = test_spec.genesis_header().gas_limit().clone();
@ -208,7 +201,7 @@ pub fn push_blocks_to_client(client: &Arc<Client>, timestamp_salt: u64, starting
} }
pub fn get_test_client_with_blocks(blocks: Vec<Bytes>) -> Arc<Client> { pub fn get_test_client_with_blocks(blocks: Vec<Bytes>) -> Arc<Client> {
let test_spec = get_test_spec(); let test_spec = Spec::new_test();
let client_db = new_db(); let client_db = new_db();
let client = Client::new( let client = Client::new(
@ -285,12 +278,12 @@ pub fn get_temp_state_db() -> StateDB {
} }
pub fn get_good_dummy_block_seq(count: usize) -> Vec<Bytes> { pub fn get_good_dummy_block_seq(count: usize) -> Vec<Bytes> {
let test_spec = get_test_spec(); let test_spec = Spec::new_test();
get_good_dummy_block_fork_seq(1, count, &test_spec.genesis_header().hash()) get_good_dummy_block_fork_seq(1, count, &test_spec.genesis_header().hash())
} }
pub fn get_good_dummy_block_fork_seq(start_number: usize, count: usize, parent_hash: &H256) -> Vec<Bytes> { pub fn get_good_dummy_block_fork_seq(start_number: usize, count: usize, parent_hash: &H256) -> Vec<Bytes> {
let test_spec = get_test_spec(); let test_spec = Spec::new_test();
let genesis_gas = test_spec.genesis_header().gas_limit().clone(); let genesis_gas = test_spec.genesis_header().gas_limit().clone();
let mut rolling_timestamp = start_number as u64 * 10; let mut rolling_timestamp = start_number as u64 * 10;
let mut parent = *parent_hash; let mut parent = *parent_hash;
@ -314,7 +307,7 @@ pub fn get_good_dummy_block_fork_seq(start_number: usize, count: usize, parent_h
pub fn get_good_dummy_block_hash() -> (H256, Bytes) { pub fn get_good_dummy_block_hash() -> (H256, Bytes) {
let mut block_header = Header::new(); let mut block_header = Header::new();
let test_spec = get_test_spec(); let test_spec = Spec::new_test();
let genesis_gas = test_spec.genesis_header().gas_limit().clone(); let genesis_gas = test_spec.genesis_header().gas_limit().clone();
block_header.set_gas_limit(genesis_gas); block_header.set_gas_limit(genesis_gas);
block_header.set_difficulty(U256::from(0x20000)); block_header.set_difficulty(U256::from(0x20000));
@ -333,7 +326,7 @@ pub fn get_good_dummy_block() -> Bytes {
pub fn get_bad_state_dummy_block() -> Bytes { pub fn get_bad_state_dummy_block() -> Bytes {
let mut block_header = Header::new(); let mut block_header = Header::new();
let test_spec = get_test_spec(); let test_spec = Spec::new_test();
let genesis_gas = test_spec.genesis_header().gas_limit().clone(); let genesis_gas = test_spec.genesis_header().gas_limit().clone();
block_header.set_gas_limit(genesis_gas); block_header.set_gas_limit(genesis_gas);
@ -346,49 +339,6 @@ pub fn get_bad_state_dummy_block() -> Bytes {
create_test_block(&block_header) create_test_block(&block_header)
} }
pub fn get_default_ethash_extensions() -> EthashExtensions {
EthashExtensions {
homestead_transition: 1150000,
eip150_transition: u64::max_value(),
eip160_transition: u64::max_value(),
eip161abc_transition: u64::max_value(),
eip161d_transition: u64::max_value(),
dao_hardfork_transition: u64::max_value(),
dao_hardfork_beneficiary: "0000000000000000000000000000000000000001".into(),
dao_hardfork_accounts: Vec::new(),
}
}
pub fn get_default_ethash_params() -> EthashParams {
EthashParams {
minimum_difficulty: U256::from(131072),
difficulty_bound_divisor: U256::from(2048),
difficulty_increment_divisor: 10,
metropolis_difficulty_increment_divisor: 9,
homestead_transition: 1150000,
duration_limit: 13,
block_reward: 0.into(),
difficulty_hardfork_transition: u64::max_value(),
difficulty_hardfork_bound_divisor: U256::from(0),
bomb_defuse_transition: u64::max_value(),
eip100b_transition: u64::max_value(),
ecip1010_pause_transition: u64::max_value(),
ecip1010_continue_transition: u64::max_value(),
ecip1017_era_rounds: u64::max_value(),
mcip3_transition: u64::max_value(),
mcip3_miner_reward: 0.into(),
mcip3_ubi_reward: 0.into(),
mcip3_ubi_contract: "0000000000000000000000000000000000000001".into(),
mcip3_dev_reward: 0.into(),
mcip3_dev_contract: "0000000000000000000000000000000000000001".into(),
eip649_transition: u64::max_value(),
eip649_delay: 3_000_000,
eip649_reward: None,
expip2_transition: u64::max_value(),
expip2_duration_limit: 30,
}
}
#[derive(Default)] #[derive(Default)]
pub struct TestNotify { pub struct TestNotify {
pub messages: RwLock<Vec<Bytes>>, pub messages: RwLock<Vec<Bytes>>,

View File

@ -24,7 +24,7 @@ use ethereum_types::{U256, Address};
use io::*; use io::*;
use spec::*; use spec::*;
use client::*; use client::*;
use tests::helpers::*; use tests::helpers::get_temp_state_db;
use client::{BlockChainClient, Client, ClientConfig}; use client::{BlockChainClient, Client, ClientConfig};
use kvdb_rocksdb::{Database, DatabaseConfig}; use kvdb_rocksdb::{Database, DatabaseConfig};
use std::sync::Arc; use std::sync::Arc;

View File

@ -728,17 +728,17 @@ impl<K: Kind> Drop for VerificationQueue<K> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use io::*; use io::*;
use spec::*; use spec::Spec;
use super::{BlockQueue, Config, State}; use super::{BlockQueue, Config, State};
use super::kind::blocks::Unverified; use super::kind::blocks::Unverified;
use tests::helpers::*; use tests::helpers::{get_good_dummy_block_seq, get_good_dummy_block};
use error::*; use error::*;
use views::*; use views::*;
// create a test block queue. // create a test block queue.
// auto_scaling enables verifier adjustment. // auto_scaling enables verifier adjustment.
fn get_test_queue(auto_scale: bool) -> BlockQueue { fn get_test_queue(auto_scale: bool) -> BlockQueue {
let spec = get_test_spec(); let spec = Spec::new_test();
let engine = spec.engine; let engine = spec.engine;
let mut config = Config::default(); let mut config = Config::default();
@ -827,7 +827,7 @@ mod tests {
#[test] #[test]
fn test_mem_limit() { fn test_mem_limit() {
let spec = get_test_spec(); let spec = Spec::new_test();
let engine = spec.engine; let engine = spec.engine;
let mut config = Config::default(); let mut config = Config::default();
config.max_mem_use = super::MIN_MEM_LIMIT; // empty queue uses about 15000 config.max_mem_use = super::MIN_MEM_LIMIT; // empty queue uses about 15000