From 78e7101f85a0ede8e5e408e897e6dfe1bad2bd96 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Tue, 5 Jul 2016 12:48:32 +0300 Subject: [PATCH] rpc test working --- Cargo.lock | 1 + ethcore/Cargo.toml | 1 + ethcore/src/client/client.rs.in | 2 +- ethcore/src/lib.rs | 1 + ethcore/src/pod_state.rs | 4 ++-- ethcore/src/tests/rpc.rs | 17 +++++++---------- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10a52aabb..deac947dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -257,6 +257,7 @@ dependencies = [ "ethcore-devtools 1.3.0", "ethcore-ipc 1.3.0", "ethcore-ipc-codegen 1.3.0", + "ethcore-ipc-nano 1.3.0", "ethcore-util 1.3.0", "ethjson 0.1.0", "ethstore 0.1.0", diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 6979043e3..03edcb389 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -32,6 +32,7 @@ bloomchain = "0.1" rayon = "0.3.1" ethstore = { path = "../ethstore" } semver = "0.2" +ethcore-ipc-nano = { path = "../ipc/nano" } [dependencies.hyper] git = "https://github.com/ethcore/hyper" diff --git a/ethcore/src/client/client.rs.in b/ethcore/src/client/client.rs.in index 622277f66..6ab4b6cc6 100644 --- a/ethcore/src/client/client.rs.in +++ b/ethcore/src/client/client.rs.in @@ -73,7 +73,7 @@ use evm::Factory as EvmFactory; use miner::{Miner, MinerService, AccountDetails}; use util::TrieFactory; use ipc::IpcConfig; -use ipc::binary::{BinaryConvertable, BinaryConvertError}; +use ipc::binary::{BinaryConvertError}; // re-export pub use types::blockchain_info::BlockChainInfo; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index eb8f9dbc1..218619577 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -95,6 +95,7 @@ extern crate hyper; extern crate ethash; pub extern crate ethstore; extern crate semver; +extern crate ethcore_ipc_nano as nanoipc; #[cfg(test)] extern crate ethcore_devtools as devtools; #[cfg(feature = "jit" )] extern crate evmjit; diff --git a/ethcore/src/pod_state.rs b/ethcore/src/pod_state.rs index c6176914b..9a11fb33f 100644 --- a/ethcore/src/pod_state.rs +++ b/ethcore/src/pod_state.rs @@ -86,14 +86,14 @@ mod test { #[test] fn create_delete() { let a = PodState::from(map![ 1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]) ]); - assert_eq!(super::diff_pod(&a, &PodState::new()), StateDiff(map![ + assert_eq!(super::diff_pod(&a, &PodState::new()), StateDiff { raw: map![ 1.into() => AccountDiff{ balance: Diff::Died(69.into()), nonce: Diff::Died(0.into()), code: Diff::Died(vec![]), storage: map![], } - ])); + ]}); assert_eq!(super::diff_pod(&PodState::new(), &a), StateDiff{ raw: map![ 1.into() => AccountDiff{ balance: Diff::Born(69.into()), diff --git a/ethcore/src/tests/rpc.rs b/ethcore/src/tests/rpc.rs index ce1efd4bb..a25928cf8 100644 --- a/ethcore/src/tests/rpc.rs +++ b/ethcore/src/tests/rpc.rs @@ -18,26 +18,25 @@ use nanoipc; use std::sync::Arc; -use std::io::Write; use std::sync::atomic::{Ordering, AtomicBool}; -use client::{BlockChainClient, MiningBlockChainClient, Client, ClientConfig, BlockID, RemoteClient}; -use block::IsBlock; +use client::{Client, ClientConfig, RemoteClient}; use tests::helpers::*; -use common::*; use devtools::*; use miner::Miner; use crossbeam; +use common::IoChannel; pub fn run_test_worker(scope: &crossbeam::Scope, stop: Arc, socket_path: &str) { let socket_path = socket_path.to_owned(); scope.spawn(move || { + let temp = RandomTempPath::create_dir(); let client = Client::new( ClientConfig::default(), get_test_spec(), - dir.as_path(), + temp.as_path(), Arc::new(Miner::with_spec(get_test_spec())), IoChannel::disconnected()).unwrap(); - let mut worker = nanoipc::Worker::new(&Arc::new(client)); + let mut worker = nanoipc::Worker::new(&client); worker.add_reqrep(&socket_path).unwrap(); while !stop.load(Ordering::Relaxed) { worker.poll(); @@ -46,15 +45,13 @@ pub fn run_test_worker(scope: &crossbeam::Scope, stop: Arc, socket_p } #[test] -fn can_be_created() { +fn can_handshake() { crossbeam::scope(|scope| { let stop_guard = StopGuard::new(); let socket_path = "ipc:///tmp/parity-client-rpc-10.ipc"; run_test_worker(scope, stop_guard.share(), socket_path); let remote_client = nanoipc::init_client::>(socket_path).unwrap(); - let non_existant = remote_client.block_header(BlockID::Number(188)); - - assert!(non_existant.is_none()); + assert!(remote_client.handshake().is_ok()); }) }