Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

ethcore test helpers cleanup #8086

Merged
merged 2 commits into from
Mar 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ pub fn enact_verified(

#[cfg(test)]
mod tests {
use tests::helpers::*;
use tests::helpers::get_temp_state_db;
use super::*;
use engines::EthEngine;
use vm::LastHashes;
Expand Down
5 changes: 4 additions & 1 deletion ethcore/src/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,10 @@ mod tests {
use ethereum_types::*;
use receipt::{Receipt, TransactionOutcome};
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::extras::TransactionAddress;
use transaction::{Transaction, Action};
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@ mod tests {
#[test]
fn should_not_cache_details_before_commit() {
use client::{BlockChainClient, ChainInfo};
use tests::helpers::*;
use tests::helpers::{generate_dummy_client, get_good_dummy_block_hash};

use std::thread;
use std::time::Duration;
Expand Down
5 changes: 4 additions & 1 deletion ethcore/src/engines/authority_round/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,10 @@ mod tests {
use header::Header;
use rlp::encode;
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 spec::Spec;
use transaction::{Action, Transaction};
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/engines/basic_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ mod tests {
use hash::keccak;
use ethereum_types::H520;
use block::*;
use tests::helpers::*;
use tests::helpers::get_temp_state_db;
use account_provider::AccountProvider;
use header::Header;
use spec::Spec;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/engines/instant_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<M: Machine> Engine<M> for InstantSeal<M>
mod tests {
use std::sync::Arc;
use ethereum_types::{H520, Address};
use tests::helpers::*;
use tests::helpers::{get_temp_state_db};
use spec::Spec;
use header::Header;
use block::*;
Expand Down
5 changes: 4 additions & 1 deletion ethcore/src/engines/tendermint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,10 @@ mod tests {
use header::Header;
use client::ChainInfo;
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 spec::Spec;
use engines::{EthEngine, EngineError, Seal};
Expand Down
32 changes: 31 additions & 1 deletion ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ mod tests {
use std::sync::Arc;
use ethereum_types::{H64, H256, U256, Address};
use block::*;
use tests::helpers::*;
use tests::helpers::get_temp_state_db;
use error::{BlockError, Error};
use header::Header;
use spec::Spec;
Expand All @@ -500,6 +500,36 @@ mod tests {
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]
fn on_close_block() {
let spec = test_spec();
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ mod tests {
use ethereum_types::U256;
use state::*;
use super::*;
use tests::helpers::*;
use tests::helpers::get_temp_state_db;
use views::BlockView;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ mod tests {
use error::ExecutionError;
use machine::EthereumMachine;
use state::{Substate, CleanupMode};
use tests::helpers::*;
use tests::helpers::{get_temp_state_with_factory, get_temp_state};
use trace::trace;
use trace::{FlatTrace, Tracer, NoopTracer, ExecutiveTracer};
use trace::{VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, VMTracer, NoopVMTracer, ExecutiveVMTracer};
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/externalities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ mod tests {
use ethereum_types::{U256, Address};
use evm::{EnvInfo, Ext, CallType};
use state::{State, Substate};
use tests::helpers::*;
use tests::helpers::get_temp_state;
use super::*;
use trace::{NoopTracer, NoopVMTracer};

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use vm::{
CreateContractAddress, ReturnData,
};
use externalities::*;
use tests::helpers::*;
use tests::helpers::get_temp_state;
use ethjson;
use trace::{Tracer, NoopTracer};
use trace::{VMTracer, NoopVMTracer};
Expand Down
15 changes: 14 additions & 1 deletion ethcore/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,25 @@ fn round_block_gas_limit(gas_limit: U256, lower_limit: U256, upper_limit: U256)
mod tests {
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]
fn ethash_gas_limit_is_multiple_of_determinant() {
use ethereum_types::U256;

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(
spec.params().clone(),
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ impl IoHandler<ClientIoMessage> for ClientIoHandler {
#[cfg(test)]
mod tests {
use std::{time, thread};
use spec::Spec;
use super::*;
use tests::helpers::*;
use client::ClientConfig;
use std::sync::Arc;
use miner::Miner;
Expand All @@ -235,7 +235,7 @@ mod tests {
let client_path = tempdir.path().join("client");
let snapshot_path = tempdir.path().join("snapshot");

let spec = get_test_spec();
let spec = Spec::new_test();
let service = ClientService::start(
ClientConfig::default(),
&spec,
Expand Down
6 changes: 3 additions & 3 deletions ethcore/src/snapshot/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ mod tests {
use std::sync::Arc;
use service::ClientIoMessage;
use io::{IoService};
use tests::helpers::get_test_spec;
use spec::Spec;
use journaldb::Algorithm;
use error::Error;
use snapshot::{ManifestData, RestorationStatus, SnapshotService};
Expand All @@ -650,7 +650,7 @@ mod tests {
#[test]
fn sends_async_messages() {
let service = IoService::<ClientIoMessage>::start().unwrap();
let spec = get_test_spec();
let spec = Spec::new_test();

let tempdir = TempDir::new("").unwrap();
let dir = tempdir.path().join("snapshot");
Expand Down Expand Up @@ -691,7 +691,7 @@ mod tests {
use ethereum_types::H256;
use kvdb_rocksdb::DatabaseConfig;

let spec = get_test_spec();
let spec = Spec::new_test();
let tempdir = TempDir::new("").unwrap();

let state_hashes: Vec<_> = (0..5).map(|_| H256::random()).collect();
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ mod tests {
use super::*;
use ethkey::Secret;
use ethereum_types::{H256, U256, Address};
use tests::helpers::*;
use tests::helpers::{get_temp_state, get_temp_state_db};
use machine::EthereumMachine;
use vm::EnvInfo;
use spec::*;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/state_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ unsafe impl Sync for SyncAccount {}
mod tests {
use ethereum_types::{H256, U256, Address};
use kvdb::DBTransaction;
use tests::helpers::*;
use tests::helpers::{get_temp_state_db};
use state::{Account, Backend};
use ethcore_logger::init_log;

Expand Down
13 changes: 8 additions & 5 deletions ethcore/src/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use state::{self, State, CleanupMode};
use executive::{Executive, TransactOptions};
use ethereum;
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 ethereum_types::{U256, Address};
use kvdb_rocksdb::{Database, DatabaseConfig};
Expand All @@ -38,7 +41,7 @@ use tempdir::TempDir;
#[test]
fn imports_from_empty() {
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 client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());

Expand Down Expand Up @@ -77,7 +80,7 @@ fn should_return_registrar() {
#[test]
fn returns_state_root_basic() {
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();

assert!(client.state_data(genesis_header.state_root()).is_some());
Expand All @@ -86,7 +89,7 @@ fn returns_state_root_basic() {
#[test]
fn imports_good_block() {
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 client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());

Expand All @@ -111,7 +114,7 @@ fn imports_good_block() {
#[test]
fn query_none_block() {
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 client_db = Arc::new(Database::open(&db_config, tempdir.path().to_str().unwrap()).unwrap());

Expand Down
18 changes: 17 additions & 1 deletion ethcore/src/tests/evm.rs
Original file line number Diff line number Diff line change
@@ -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.

use std::sync::Arc;
Expand All @@ -6,7 +22,7 @@ use vm::{EnvInfo, ActionParams, ActionValue, CallType, ParamsType};
use evm::{Factory, VMType};
use executive::Executive;
use state::Substate;
use tests::helpers::*;
use tests::helpers::get_temp_state_with_factory;
use trace::{NoopVMTracer, NoopTracer};
use transaction::SYSTEM_ADDRESS;

Expand Down
Loading