unify loading spec && further spec cleanups (#10948)

* bundle_* macros for spec

* fixed failing tests

* renamed bundle.rs to chain.rs

* removed unused derives

* updated spec/chain.rs description
This commit is contained in:
Marek Kotewicz
2019-08-07 16:52:48 +02:00
committed by David
parent c689495826
commit 45978bc2bd
45 changed files with 378 additions and 591 deletions

View File

@@ -636,7 +636,7 @@ fn all_expected<A, B, F>(values: &[A], expected_values: &[B], is_expected: F) ->
mod tests {
use super::*;
use ethcore::client::TestBlockChainClient;
use ethcore::spec::Spec;
use ethcore::spec;
use ethkey::{Generator,Random};
use hash::keccak;
use parking_lot::RwLock;
@@ -681,7 +681,7 @@ mod tests {
fn import_headers_in_chain_head_state() {
::env_logger::try_init().ok();
let spec = Spec::new_test();
let spec = spec::new_test();
let genesis_hash = spec.genesis_header().hash();
let mut downloader = BlockDownloader::new(BlockSet::NewBlocks, &genesis_hash, 0);
@@ -930,7 +930,7 @@ mod tests {
fn reset_after_multiple_sets_of_useless_headers() {
::env_logger::try_init().ok();
let spec = Spec::new_test();
let spec = spec::new_test();
let genesis_hash = spec.genesis_header().hash();
let mut downloader = BlockDownloader::new(BlockSet::NewBlocks, &genesis_hash, 0);
@@ -970,7 +970,7 @@ mod tests {
fn dont_reset_after_multiple_sets_of_useless_headers_for_chain_head() {
::env_logger::try_init().ok();
let spec = Spec::new_test();
let spec = spec::new_test();
let genesis_hash = spec.genesis_header().hash();
let mut downloader = BlockDownloader::new(BlockSet::NewBlocks, &genesis_hash, 0);

View File

@@ -23,7 +23,7 @@ use light_sync::*;
use tests::helpers::{TestNet, Peer as PeerLike, TestPacket};
use ethcore::client::TestBlockChainClient;
use ethcore::spec::Spec;
use ethcore::spec;
use io::IoChannel;
use kvdb_memorydb;
use light::client::fetch::{self, Unavailable};
@@ -229,7 +229,7 @@ impl TestNet<Peer> {
config,
Arc::new(db),
None,
&Spec::new_test(),
&spec::new_test(),
fetch::unavailable(), // TODO: allow fetch from full nodes.
IoChannel::disconnected(),
cache

View File

@@ -19,6 +19,7 @@ use ethcore::client::{TestBlockChainClient, BlockChainClient, BlockId, EachBlock
use chain::{SyncState};
use super::helpers::*;
use {SyncConfig, WarpSync};
use ethcore::spec;
#[test]
fn two_peers() {
@@ -101,7 +102,7 @@ fn forked_with_misbehaving_peer() {
::env_logger::try_init().ok();
let mut net = TestNet::new(3);
let mut alt_spec = ::ethcore::spec::Spec::new_test();
let mut alt_spec = spec::new_test();
alt_spec.extra_data = b"fork".to_vec();
// peer 0 is on a totally different chain with higher total difficulty
net.peer_mut(0).chain = Arc::new(TestBlockChainClient::new_with_spec(alt_spec));

View File

@@ -20,7 +20,7 @@ use ethereum_types::{U256, Address};
use io::{IoHandler, IoChannel};
use ethcore::client::{ChainInfo, ClientIoMessage};
use ethcore::engines;
use ethcore::spec::Spec;
use ethcore::spec;
use ethcore::miner::{self, MinerService};
use ethkey::{KeyPair, Secret};
use types::transaction::{Action, PendingTransaction, Transaction};
@@ -44,8 +44,8 @@ fn authority_round() {
let s0 = KeyPair::from_secret_slice(keccak("1").as_bytes()).unwrap();
let s1 = KeyPair::from_secret_slice(keccak("0").as_bytes()).unwrap();
let chain_id = Spec::new_test_round().chain_id();
let mut net = TestNet::with_spec(2, SyncConfig::default(), Spec::new_test_round);
let chain_id = spec::new_test_round().chain_id();
let mut net = TestNet::with_spec(2, SyncConfig::default(), spec::new_test_round);
let io_handler0: Arc<dyn IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(0).chain.clone()));
let io_handler1: Arc<dyn IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(1).chain.clone()));
// Push transaction to both clients. Only one of them gets lucky to produce a block.

View File

@@ -25,7 +25,7 @@ use tests::snapshot::*;
use ethcore::client::{TestBlockChainClient, BlockChainClient, Client as EthcoreClient,
ClientConfig, ChainNotify, NewBlocks, ChainMessageType, ClientIoMessage};
use ethcore::snapshot::SnapshotService;
use ethcore::spec::Spec;
use ethcore::spec::{self, Spec};
use ethcore::miner::Miner;
use ethcore::test_helpers;
use sync_io::SyncIo;
@@ -351,7 +351,7 @@ impl TestNet<EthPeer<TestBlockChainClient>> {
sync: RwLock::new(sync),
snapshot_service: ss,
chain: Arc::new(chain),
miner: Arc::new(Miner::new_for_tests(&Spec::new_test(), None)),
miner: Arc::new(Miner::new_for_tests(&spec::new_test(), None)),
queue: RwLock::new(VecDeque::new()),
private_tx_handler,
io_queue: RwLock::new(VecDeque::new()),