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

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Feb 19, 2019
1 parent fc1b466 commit 5fecdc9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
18 changes: 0 additions & 18 deletions rpc/src/v1/helpers/block_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! Block import analysis functions.

use ethcore::client::BlockQueueInfo;
use sync::SyncState;

/// Check if client is during major sync or during block import and allows defining whether 'waiting for peers' should
/// be considered a syncing state.
Expand All @@ -31,20 +30,3 @@ pub fn is_major_importing_or_waiting(sync_state: Option<SyncState>, queue_info:
is_verifying || is_syncing_state
}

#[cfg(test)]
mod tests {
use ethcore::client::BlockQueueInfo;
use sync::SyncState;

fn queue_info(unverified: usize, verified: usize) -> BlockQueueInfo {
BlockQueueInfo {
unverified_queue_size: unverified,
verified_queue_size: verified,
verifying_queue_size: 0,
max_queue_size: 1000,
max_mem_use: 1000,
mem_used: 500
}
}

}
18 changes: 4 additions & 14 deletions rpc/src/v1/tests/mocked/eth_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,11 @@ use jsonrpc_pubsub::Session;
use std::time::Duration;

use v1::{EthPubSub, EthPubSubClient, Metadata};

use ethcore::client::{TestBlockChainClient, EachBlockWith, ChainNotify, NewBlocks, ChainRoute, ChainRouteType};
use parity_runtime::Runtime;
use v1::tests::helpers::TestSyncProvider;
use v1::tests::helpers::Config;

const DURATION_ZERO: Duration = Duration::from_millis(0);

fn sync_provider() -> Arc<SyncProvider> {
Arc::new(TestSyncProvider::new(Config {
network_id: 3,
num_peers: 120,
}))
}

#[test]
fn should_subscribe_to_new_heads() {
// given
Expand All @@ -49,7 +39,7 @@ fn should_subscribe_to_new_heads() {
let h2 = client.block_hash_delta_minus(2);
let h1 = client.block_hash_delta_minus(3);

let pubsub = EthPubSubClient::new_test(Arc::new(client), sync_provider(), el.executor());
let pubsub = EthPubSubClient::new_test(Arc::new(client), el.executor());
let handler = pubsub.handler().upgrade().unwrap();
let pubsub = pubsub.to_delegate();

Expand Down Expand Up @@ -121,7 +111,7 @@ fn should_subscribe_to_logs() {
}
]);

let pubsub = EthPubSubClient::new_test(Arc::new(client), sync_provider(), el.executor());
let pubsub = EthPubSubClient::new_test(Arc::new(client), el.executor());
let handler = pubsub.handler().upgrade().unwrap();
let pubsub = pubsub.to_delegate();

Expand Down Expand Up @@ -168,7 +158,7 @@ fn should_subscribe_to_pending_transactions() {
let el = Runtime::with_thread_count(1);
let client = TestBlockChainClient::new();

let pubsub = EthPubSubClient::new_test(Arc::new(client), sync_provider(), el.executor());
let pubsub = EthPubSubClient::new_test(Arc::new(client), el.executor());
let handler = pubsub.handler().upgrade().unwrap();
let pubsub = pubsub.to_delegate();

Expand Down Expand Up @@ -214,7 +204,7 @@ fn eth_subscribe_syncing() {
// given
let el = Runtime::with_thread_count(1);
let client = TestBlockChainClient::new();
let pubsub = EthPubSubClient::new_test(Arc::new(client), sync_provider(), el.executor());
let pubsub = EthPubSubClient::new_test(Arc::new(client), el.executor());
let pubsub = pubsub.to_delegate();

let mut io = MetaIoHandler::default();
Expand Down

0 comments on commit 5fecdc9

Please sign in to comment.