diff --git a/ipc/tests/build.rs b/ipc/tests/build.rs index e498e3405..6538f56e1 100644 --- a/ipc/tests/build.rs +++ b/ipc/tests/build.rs @@ -58,6 +58,23 @@ pub fn main() { registry.expand("", &src, &dst).unwrap(); } + // rpc pass + if { + let src = Path::new("with_attrs.rs.in"); + let dst = Path::new(&out_dir).join("with_attrs_ipc.rs"); + let mut registry = syntex::Registry::new(); + codegen::register(&mut registry); + registry.expand("", &src, &dst).is_ok() + } + // serialization pass + { + let src = Path::new(&out_dir).join("with_attrs_ipc.rs"); + let dst = Path::new(&out_dir).join("with_attrs_cg.rs"); + let mut registry = syntex::Registry::new(); + codegen::register(&mut registry); + registry.expand("", &src, &dst).unwrap(); + } + // rpc pass { let src = Path::new("binary.rs.in"); diff --git a/ipc/tests/examples.rs b/ipc/tests/examples.rs index 99cf385fa..b4159f196 100644 --- a/ipc/tests/examples.rs +++ b/ipc/tests/examples.rs @@ -86,7 +86,7 @@ mod tests { 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0], - service_client.socket().borrow().write_buffer.clone()); + service_client.socket().write().unwrap().write_buffer.clone()); assert_eq!(10, result); } @@ -103,7 +103,7 @@ mod tests { 1, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, - 5, 0, 0, 0, 10, 0, 0, 0], service_client.socket().borrow().write_buffer.clone()); + 5, 0, 0, 0, 10, 0, 0, 0], service_client.socket().write().unwrap().write_buffer.clone()); assert_eq!(10, result); } @@ -145,7 +145,7 @@ mod tests { // items 3, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0], - service_client.socket().borrow().write_buffer.clone()); + service_client.socket().write().unwrap().write_buffer.clone()); assert_eq!(true, result); } diff --git a/ipc/tests/over_nano.rs b/ipc/tests/over_nano.rs index 36ad17f2a..bdeaec3d5 100644 --- a/ipc/tests/over_nano.rs +++ b/ipc/tests/over_nano.rs @@ -18,6 +18,7 @@ mod tests { use super::super::service::*; + use super::super::with_attrs::PrettyNamedClient; use nanoipc; use std::sync::Arc; use std::io::Write; @@ -43,6 +44,12 @@ mod tests { assert!(client.is_ok()); } + #[test] + fn can_create_renamed_client() { + let client = nanoipc::init_duplex_client::>("ipc:///tmp/parity-nano-test10.ipc"); + assert!(client.is_ok()); + } + #[test] fn can_call_handshake() { let url = "ipc:///tmp/parity-test-nano-20.ipc"; diff --git a/ipc/tests/run.rs b/ipc/tests/run.rs index cdda5275b..ab0041899 100644 --- a/ipc/tests/run.rs +++ b/ipc/tests/run.rs @@ -28,3 +28,4 @@ mod examples; mod over_nano; mod nested; mod binary; +mod with_attrs; diff --git a/ipc/tests/with_attrs.rs b/ipc/tests/with_attrs.rs new file mode 100644 index 000000000..e9b3e0d76 --- /dev/null +++ b/ipc/tests/with_attrs.rs @@ -0,0 +1,18 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +#![allow(dead_code, unused_assignments, unused_variables)] // codegen issues +include!(concat!(env!("OUT_DIR"), "/with_attrs_cg.rs")); diff --git a/ipc/tests/with_attrs.rs.in b/ipc/tests/with_attrs.rs.in new file mode 100644 index 000000000..bca1b0bfe --- /dev/null +++ b/ipc/tests/with_attrs.rs.in @@ -0,0 +1,39 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +use std::sync::RwLock; +use std::ops::*; +use ipc::IpcConfig; +use std::mem; +use ipc::binary::BinaryConvertError; +use std::collections::VecDeque; + +pub struct BadlyNamedService; + +#[derive(Ipc)] +#[ipc(client_ident="PrettyNamedClient")] +impl BadlyNamedService { + fn is_zero(&self, x: u64) -> bool { + x == 0 + } +} + +impl ::ipc::IpcConfig for BadlyNamedService {} + +#[test] +fn invoke() { + +}