diff --git a/ipc/nano/src/lib.rs b/ipc/nano/src/lib.rs index 4362448d5..41f17018e 100644 --- a/ipc/nano/src/lib.rs +++ b/ipc/nano/src/lib.rs @@ -91,6 +91,7 @@ impl Worker where S: IpcInterface { match socket.nb_read_to_end(&mut self.buf) { Ok(method_sign_len) => { if method_sign_len >= 2 { + // method_num let method_num = self.buf[1] as u16 * 256 + self.buf[0] as u16; // payload @@ -186,7 +187,6 @@ mod service_tests { fn dummy_write(addr: &str, buf: &[u8]) -> (Socket, Endpoint) { let mut socket = Socket::new(Protocol::Pair).unwrap(); let endpoint = socket.connect(addr).unwrap(); - //thread::sleep_ms(10); socket.write(buf).unwrap(); (socket, endpoint) } diff --git a/ipc/tests/over_nano.rs b/ipc/tests/over_nano.rs index 944f12c2e..56ea94d61 100644 --- a/ipc/tests/over_nano.rs +++ b/ipc/tests/over_nano.rs @@ -29,25 +29,33 @@ mod tests { #[test] fn can_create_client() { - let client = nanoipc::init_client::>("ipc:///tmp/parity-examples-test10.ipc"); + let client = nanoipc::init_client::>("ipc:///tmp/parity-nano-test10.ipc"); assert!(client.is_ok()); } #[test] fn can_call_handshake() { - let exit = Arc::new(::std::sync::atomic::AtomicBool::new(false)); - let url = "ipc:///tmp/parity-test-examples-20.ipc"; + let worker_should_exit = Arc::new(::std::sync::atomic::AtomicBool::new(false)); + let worker_is_ready = Arc::new(::std::sync::atomic::AtomicBool::new(false)); + let c_worker_should_exit = worker_should_exit.clone(); + let c_worker_is_ready = worker_is_ready.clone(); + + let url = "ipc:///tmp/parity-test-nano-20.ipc"; - let worker_exit = exit.clone(); ::std::thread::spawn(move || { let mut worker = init_worker(url); - while !worker_exit.load(::std::sync::atomic::Ordering::Relaxed) { worker.poll() } + while !c_worker_should_exit.load(::std::sync::atomic::Ordering::Relaxed) { + worker.poll(); + c_worker_is_ready.store(true, ::std::sync::atomic::Ordering::Relaxed); + } }); + + while !worker_is_ready.load(::std::sync::atomic::Ordering::Relaxed) { } let client = nanoipc::init_client::>(url).unwrap(); let hs = client.handshake(); - exit.store(true, ::std::sync::atomic::Ordering::Relaxed); + worker_should_exit.store(true, ::std::sync::atomic::Ordering::Relaxed); assert!(hs.is_ok()); }