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

[ethcore]: move client test types to test-helpers #11062

Merged
merged 1 commit into from
Sep 17, 2019
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/light/src/net/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use common_types::blockchain_info::BlockChainInfo;
use common_types::encoded;
use common_types::ids::BlockId;
use common_types::transaction::{Action, PendingTransaction};
use ethcore::client::{EachBlockWith, TestBlockChainClient};
use ethcore::test_helpers::{EachBlockWith, TestBlockChainClient};
use ethereum_types::{H256, U256, Address, BigEndianHash};
use net::context::IoContext;
use net::load_timer::MOVING_SAMPLE_SIZE;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/light/src/on_demand/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ mod tests {
use trie::Recorder;
use hash::keccak;

use ethcore::client::{TestBlockChainClient, EachBlockWith};
use ethcore::test_helpers::{TestBlockChainClient, EachBlockWith};
use client_traits::{BlockInfo, BlockChainClient};
use common_types::header::Header;
use common_types::encoded;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/light/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl<L: AsLightClient> AsLightClient for LightProvider<L> {

#[cfg(test)]
mod tests {
use ethcore::client::{EachBlockWith, TestBlockChainClient};
use ethcore::test_helpers::{EachBlockWith, TestBlockChainClient};
use super::Provider;

#[test]
Expand Down
10 changes: 0 additions & 10 deletions ethcore/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,9 @@ mod client;
mod config;
mod traits;

#[cfg(any(test, feature = "test-helpers"))]
mod evm_test_client;
#[cfg(any(test, feature = "test-helpers"))]
mod test_client;

pub use self::client::Client;
pub use self::config::{ClientConfig, DatabaseCompactionProfile, VMType};
pub use self::traits::{
ReopenBlock, PrepareOpenBlock, ImportSealedBlock, BroadcastProposalBlock,
Call, EngineInfo, BlockProducer, SealedBlockImporter,
};

#[cfg(any(test, feature = "test-helpers"))]
pub use self::evm_test_client::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess};
#[cfg(any(test, feature = "test-helpers"))]
pub use self::test_client::{TestBlockChainClient, EachBlockWith, TestState};
4 changes: 2 additions & 2 deletions ethcore/src/json_tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

use std::path::Path;
use std::sync::Arc;
use client::{EvmTestClient, Client, ClientConfig};
use client::{Client, ClientConfig};
use client_traits::{ImportBlock, ChainInfo};
use spec::Genesis;
use ethjson;
use miner::Miner;
use io::IoChannel;
use test_helpers;
use test_helpers::{self, EvmTestClient};
use types::verification::Unverified;
use verification::VerifierType;
use super::SKIP_TEST_STATE;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use std::path::Path;
use super::test_common::*;
use pod::PodState;
use trace;
use client::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess};
use ethjson;
use test_helpers::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess};
use types::transaction::SignedTransaction;
use vm::EnvInfo;
use super::SKIP_TEST_STATE;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use std::path::Path;
use super::test_common::*;
use client::EvmTestClient;
use test_helpers::EvmTestClient;
use ethjson;
use rlp::Rlp;
use types::{
Expand Down
6 changes: 4 additions & 2 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,10 +1491,12 @@ mod tests {
use hash::keccak;
use rustc_hex::FromHex;

use client::{TestBlockChainClient, EachBlockWith, ImportSealedBlock};
use client_traits::ChainInfo;
use client::ImportSealedBlock;
use miner::{MinerService, PendingOrdering};
use test_helpers::{generate_dummy_client, generate_dummy_client_with_spec};
use test_helpers::{
generate_dummy_client, generate_dummy_client_with_spec, TestBlockChainClient, EachBlockWith
};
use types::{
BlockNumber,
transaction::Transaction
Expand Down
16 changes: 12 additions & 4 deletions ethcore/src/test_helpers.rs → ethcore/src/test_helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@

//! Set of different helpers for client tests

mod test_client;
mod evm_test_client;

/// Re-export for tests only
pub use evm::CreateContractAddress;
/// Re-export for tests only
pub use trie::TrieSpec;
/// Re-export for tests only
pub use self::test_client::{TestBlockChainClient, EachBlockWith, TestState};
/// Re-export for tests only
pub use self::evm_test_client::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess};

use std::path::Path;
use std::sync::Arc;
use std::{fs, io};
Expand Down Expand Up @@ -53,10 +65,6 @@ use spec::{Spec, self};
use account_state::*;
use state_db::StateDB;

/// Re-export for tests only
pub use evm::CreateContractAddress;
/// Re-export for tests only
pub use trie::TrieSpec;

/// Creates test block with corresponding header
pub fn create_test_block(header: &Header) -> Bytes {
Expand Down
8 changes: 4 additions & 4 deletions ethcore/sync/src/block_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,15 +636,15 @@ fn all_expected<A, B, F>(values: &[A], expected_values: &[B], is_expected: F) ->
#[cfg(test)]
mod tests {
use super::*;
use ethcore::client::TestBlockChainClient;
use ethcore::test_helpers::TestBlockChainClient;
use spec;
use ethkey::{Generator,Random};
use ethkey::{Generator, Random};
use hash::keccak;
use parking_lot::RwLock;
use rlp::{encode_list,RlpStream};
use rlp::{encode_list, RlpStream};
use tests::helpers::TestIo;
use tests::snapshot::TestSnapshotService;
use types::transaction::{Transaction,SignedTransaction};
use types::transaction::{Transaction, SignedTransaction};
use triehash_ethereum::ordered_trie_root;
use types::header::Header as BlockHeader;

Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ impl BlockCollection {
mod test {
use super::{BlockCollection, SyncHeader};
use client_traits::BlockChainClient;
use ethcore::client::{TestBlockChainClient, EachBlockWith};
use ethcore::test_helpers::{TestBlockChainClient, EachBlockWith};
use types::{
ids::BlockId,
BlockNumber,
Expand Down
6 changes: 3 additions & 3 deletions ethcore/sync/src/chain/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,11 @@ impl SyncHandler {
#[cfg(test)]
mod tests {
use client_traits::ChainInfo;
use ethcore::client::{EachBlockWith, TestBlockChainClient};
use ethcore::test_helpers::{EachBlockWith, TestBlockChainClient};
use parking_lot::RwLock;
use rlp::Rlp;
use std::collections::{VecDeque};
use tests::helpers::{TestIo};
use std::collections::VecDeque;
use tests::helpers::TestIo;
use tests::snapshot::TestSnapshotService;

use super::*;
Expand Down
4 changes: 2 additions & 2 deletions ethcore/sync/src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ pub mod tests {
use std::collections::{VecDeque};
use ethkey;
use network::PeerId;
use tests::helpers::{TestIo};
use tests::helpers::TestIo;
use tests::snapshot::TestSnapshotService;
use ethereum_types::{H256, U256, Address};
use parking_lot::RwLock;
Expand All @@ -1417,7 +1417,7 @@ pub mod tests {
use super::*;
use ::SyncConfig;
use super::{PeerInfo, PeerAsking};
use ethcore::client::{EachBlockWith, TestBlockChainClient};
use ethcore::test_helpers::{EachBlockWith, TestBlockChainClient};
use client_traits::{BlockInfo, BlockChainClient, ChainInfo};
use ethcore::miner::{MinerService, PendingOrdering};
use types::header::Header;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/chain/propagator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl SyncPropagator {
#[cfg(test)]
mod tests {
use client_traits::{BlockInfo, ChainInfo};
use ethcore::client::{EachBlockWith, TestBlockChainClient};
use ethcore::test_helpers::{EachBlockWith, TestBlockChainClient};
use parking_lot::RwLock;
use rlp::Rlp;
use std::collections::VecDeque;
Expand Down
8 changes: 4 additions & 4 deletions ethcore/sync/src/chain/supplier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,17 @@ impl SyncSupplier {

#[cfg(test)]
mod test {
use std::collections::{VecDeque};
use tests::helpers::{TestIo};
use std::collections::VecDeque;
use tests::helpers::TestIo;
use tests::snapshot::TestSnapshotService;
use ethereum_types::{H256};
use ethereum_types::H256;
use parking_lot::RwLock;
use bytes::Bytes;
use rlp::{Rlp, RlpStream};
use super::{*, super::tests::*};
use blocks::SyncHeader;
use client_traits::BlockChainClient;
use ethcore::client::{EachBlockWith, TestBlockChainClient};
use ethcore::test_helpers::{EachBlockWith, TestBlockChainClient};
use std::str::FromStr;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/light_sync/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use tests::helpers::TestNet;

use ethcore::client::EachBlockWith;
use ethcore::test_helpers::EachBlockWith;
use client_traits::BlockInfo;
use types::ids::BlockId;

Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/light_sync/tests/test_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::sync::Arc;
use light_sync::*;
use tests::helpers::{TestNet, Peer as PeerLike, TestPacket};

use ethcore::client::TestBlockChainClient;
use ethcore::test_helpers::TestBlockChainClient;
use spec;
use io::IoChannel;
use kvdb_memorydb;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::sync::Arc;
use types::ids::BlockId;
use client_traits::{BlockChainClient, ChainInfo};
use ethcore::client::{TestBlockChainClient, EachBlockWith};
use ethcore::test_helpers::{TestBlockChainClient, EachBlockWith};
use client_traits::BlockInfo;
use chain::SyncState;
use super::helpers::*;
Expand Down
7 changes: 3 additions & 4 deletions ethcore/sync/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ use types::{
io_message::ClientIoMessage,
};
use client_traits::{BlockChainClient, ChainNotify};
use ethcore::client::{
TestBlockChainClient,
Client as EthcoreClient,
ClientConfig,
use ethcore::{
client::{Client as EthcoreClient, ClientConfig},
test_helpers::TestBlockChainClient
};
use snapshot::SnapshotService;
use spec::{self, Spec};
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use ethereum_types::H256;
use parking_lot::Mutex;
use bytes::Bytes;
use snapshot::SnapshotService;
use ethcore::client::EachBlockWith;
use ethcore::test_helpers::EachBlockWith;
use types::{
BlockNumber,
snapshot::{ManifestData, RestorationStatus},
Expand Down
2 changes: 1 addition & 1 deletion ethcore/verification/benches/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use common_types::verification::Unverified;
use criterion::{Criterion, criterion_group, criterion_main};
use ethash::{EthashParams, Ethash};
use ethereum_types::U256;
use ethcore::client::TestBlockChainClient;
use ethcore::test_helpers::TestBlockChainClient;
use spec::new_constantinople_test_machine;
use tempdir::TempDir;

Expand Down
5 changes: 2 additions & 3 deletions ethcore/verification/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,8 @@ mod tests {
use engine::Engine;
use ethkey::{Random, Generator};
use spec;
use ethcore::{
client::TestBlockChainClient,
test_helpers::{create_test_block_with_data, create_test_block}
use ethcore::test_helpers::{
create_test_block_with_data, create_test_block, TestBlockChainClient
};
use common_types::{
engines::params::CommonParams,
Expand Down
5 changes: 1 addition & 4 deletions evmbin/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
use std::time::{Instant, Duration};

use common_types::transaction;
use ethcore::{
client::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess},
test_helpers::TrieSpec,
};
use ethcore::test_helpers::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess, TrieSpec};
use ethereum_types::{H256, U256};
use ethjson;
use pod::PodState;
Expand Down
2 changes: 1 addition & 1 deletion ipfs/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn get_param<'a>(query: &'a str, name: &str) -> Option<&'a str> {
mod tests {
use std::sync::Arc;
use super::*;
use ethcore::client::TestBlockChainClient;
use ethcore::test_helpers::TestBlockChainClient;

fn get_mocked_handler() -> IpfsHandler {
IpfsHandler::new(None.into(), None.into(), Arc::new(TestBlockChainClient::new()))
Expand Down
3 changes: 2 additions & 1 deletion rpc/src/v1/tests/helpers/miner_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ use bytes::Bytes;
use client_traits::{Nonce, StateClient};
use engine::{Engine, signer::EngineSigner};
use ethcore::block::SealedBlock;
use ethcore::client::{PrepareOpenBlock, EngineInfo, TestState};
use ethcore::client::{PrepareOpenBlock, EngineInfo};
use ethcore::miner::{self, MinerService, AuthoringParams, FilterOptions};
use ethcore::test_helpers::TestState;
use ethereum_types::{H256, U256, Address};
use miner::pool::local_transactions::Status as LocalTransactionStatus;
use miner::pool::{verifier, VerifiedTransaction, QueueStatus};
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/tests/mocked/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use std::sync::Arc;

use ethcore::client::TestBlockChainClient;
use ethcore::test_helpers::TestBlockChainClient;

use jsonrpc_core::IoHandler;
use v1::{Debug, DebugClient};
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/tests/mocked/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::time::{Instant, Duration, SystemTime, UNIX_EPOCH};

use accounts::AccountProvider;
use client_traits::BlockChainClient;
use ethcore::client::{EachBlockWith, TestBlockChainClient};
use ethcore::test_helpers::{EachBlockWith, TestBlockChainClient};
use ethcore::miner::{self, MinerService};
use ethereum_types::{H160, H256, U256, Address, Bloom};
use machine::executed::Executed;
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/tests/mocked/eth_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use jsonrpc_pubsub::Session;
use std::time::Duration;

use v1::{EthPubSub, EthPubSubClient, Metadata};
use ethcore::client::{TestBlockChainClient, EachBlockWith};
use ethcore::test_helpers::{TestBlockChainClient, EachBlockWith};
use parity_runtime::Runtime;
use ethereum_types::{Address, H256};
use client_traits::{BlockInfo, ChainNotify};
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/tests/mocked/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

use std::sync::Arc;
use ethcore::client::TestBlockChainClient;
use ethcore::test_helpers::TestBlockChainClient;
use ethcore_logger::RotatingLogger;
use ethereum_types::{Address, U256, H256, BigEndianHash, Bloom};
use ethstore::ethkey::{Generator, Random};
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/tests/mocked/parity_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc_hex::FromHex;
use ethereum_types::{U256, Address};

use ethcore::miner::MinerService;
use ethcore::client::TestBlockChainClient;
use ethcore::test_helpers::TestBlockChainClient;
use sync::ManageNetwork;

use jsonrpc_core::IoHandler;
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/tests/mocked/personal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::str::FromStr;
use bytes::ToPretty;
use accounts::AccountProvider;
use ethereum_types::{Address, H520, U256};
use ethcore::client::TestBlockChainClient;
use ethcore::test_helpers::TestBlockChainClient;
use jsonrpc_core::IoHandler;
use parking_lot::Mutex;
use types::transaction::{Action, Transaction};
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/tests/mocked/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use ethereum_types::{H520, U256, Address};
use bytes::ToPretty;

use accounts::AccountProvider;
use ethcore::client::TestBlockChainClient;
use ethcore::test_helpers::TestBlockChainClient;
use parity_runtime::Runtime;
use parking_lot::Mutex;
use rlp::encode;
Expand Down
Loading