rpc test working

This commit is contained in:
NikVolf 2016-07-05 12:48:32 +03:00
parent 8052824f3f
commit 78e7101f85
6 changed files with 13 additions and 13 deletions

1
Cargo.lock generated
View File

@ -257,6 +257,7 @@ dependencies = [
"ethcore-devtools 1.3.0", "ethcore-devtools 1.3.0",
"ethcore-ipc 1.3.0", "ethcore-ipc 1.3.0",
"ethcore-ipc-codegen 1.3.0", "ethcore-ipc-codegen 1.3.0",
"ethcore-ipc-nano 1.3.0",
"ethcore-util 1.3.0", "ethcore-util 1.3.0",
"ethjson 0.1.0", "ethjson 0.1.0",
"ethstore 0.1.0", "ethstore 0.1.0",

View File

@ -32,6 +32,7 @@ bloomchain = "0.1"
rayon = "0.3.1" rayon = "0.3.1"
ethstore = { path = "../ethstore" } ethstore = { path = "../ethstore" }
semver = "0.2" semver = "0.2"
ethcore-ipc-nano = { path = "../ipc/nano" }
[dependencies.hyper] [dependencies.hyper]
git = "https://github.com/ethcore/hyper" git = "https://github.com/ethcore/hyper"

View File

@ -73,7 +73,7 @@ use evm::Factory as EvmFactory;
use miner::{Miner, MinerService, AccountDetails}; use miner::{Miner, MinerService, AccountDetails};
use util::TrieFactory; use util::TrieFactory;
use ipc::IpcConfig; use ipc::IpcConfig;
use ipc::binary::{BinaryConvertable, BinaryConvertError}; use ipc::binary::{BinaryConvertError};
// re-export // re-export
pub use types::blockchain_info::BlockChainInfo; pub use types::blockchain_info::BlockChainInfo;

View File

@ -95,6 +95,7 @@ extern crate hyper;
extern crate ethash; extern crate ethash;
pub extern crate ethstore; pub extern crate ethstore;
extern crate semver; extern crate semver;
extern crate ethcore_ipc_nano as nanoipc;
#[cfg(test)] extern crate ethcore_devtools as devtools; #[cfg(test)] extern crate ethcore_devtools as devtools;
#[cfg(feature = "jit" )] extern crate evmjit; #[cfg(feature = "jit" )] extern crate evmjit;

View File

@ -86,14 +86,14 @@ mod test {
#[test] #[test]
fn create_delete() { fn create_delete() {
let a = PodState::from(map![ 1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]) ]); 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{ 1.into() => AccountDiff{
balance: Diff::Died(69.into()), balance: Diff::Died(69.into()),
nonce: Diff::Died(0.into()), nonce: Diff::Died(0.into()),
code: Diff::Died(vec![]), code: Diff::Died(vec![]),
storage: map![], storage: map![],
} }
])); ]});
assert_eq!(super::diff_pod(&PodState::new(), &a), StateDiff{ raw: map![ assert_eq!(super::diff_pod(&PodState::new(), &a), StateDiff{ raw: map![
1.into() => AccountDiff{ 1.into() => AccountDiff{
balance: Diff::Born(69.into()), balance: Diff::Born(69.into()),

View File

@ -18,26 +18,25 @@
use nanoipc; use nanoipc;
use std::sync::Arc; use std::sync::Arc;
use std::io::Write;
use std::sync::atomic::{Ordering, AtomicBool}; use std::sync::atomic::{Ordering, AtomicBool};
use client::{BlockChainClient, MiningBlockChainClient, Client, ClientConfig, BlockID, RemoteClient}; use client::{Client, ClientConfig, RemoteClient};
use block::IsBlock;
use tests::helpers::*; use tests::helpers::*;
use common::*;
use devtools::*; use devtools::*;
use miner::Miner; use miner::Miner;
use crossbeam; use crossbeam;
use common::IoChannel;
pub fn run_test_worker(scope: &crossbeam::Scope, stop: Arc<AtomicBool>, socket_path: &str) { pub fn run_test_worker(scope: &crossbeam::Scope, stop: Arc<AtomicBool>, socket_path: &str) {
let socket_path = socket_path.to_owned(); let socket_path = socket_path.to_owned();
scope.spawn(move || { scope.spawn(move || {
let temp = RandomTempPath::create_dir();
let client = Client::new( let client = Client::new(
ClientConfig::default(), ClientConfig::default(),
get_test_spec(), get_test_spec(),
dir.as_path(), temp.as_path(),
Arc::new(Miner::with_spec(get_test_spec())), Arc::new(Miner::with_spec(get_test_spec())),
IoChannel::disconnected()).unwrap(); 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(); worker.add_reqrep(&socket_path).unwrap();
while !stop.load(Ordering::Relaxed) { while !stop.load(Ordering::Relaxed) {
worker.poll(); worker.poll();
@ -46,15 +45,13 @@ pub fn run_test_worker(scope: &crossbeam::Scope, stop: Arc<AtomicBool>, socket_p
} }
#[test] #[test]
fn can_be_created() { fn can_handshake() {
crossbeam::scope(|scope| { crossbeam::scope(|scope| {
let stop_guard = StopGuard::new(); let stop_guard = StopGuard::new();
let socket_path = "ipc:///tmp/parity-client-rpc-10.ipc"; let socket_path = "ipc:///tmp/parity-client-rpc-10.ipc";
run_test_worker(scope, stop_guard.share(), socket_path); run_test_worker(scope, stop_guard.share(), socket_path);
let remote_client = nanoipc::init_client::<RemoteClient<_>>(socket_path).unwrap(); let remote_client = nanoipc::init_client::<RemoteClient<_>>(socket_path).unwrap();
let non_existant = remote_client.block_header(BlockID::Number(188)); assert!(remote_client.handshake().is_ok());
assert!(non_existant.is_none());
}) })
} }