Fix ipc tests and bring to CI (#1789)
* fixed compilation * Fix warnings * fix remaining tests * add to ci and fix test.sh
This commit is contained in:
parent
f19b00b6ca
commit
4e72608441
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -15,6 +15,7 @@ dependencies = [
|
|||||||
"ethcore-ipc-codegen 1.3.0",
|
"ethcore-ipc-codegen 1.3.0",
|
||||||
"ethcore-ipc-hypervisor 1.2.0",
|
"ethcore-ipc-hypervisor 1.2.0",
|
||||||
"ethcore-ipc-nano 1.3.0",
|
"ethcore-ipc-nano 1.3.0",
|
||||||
|
"ethcore-ipc-tests 0.1.0",
|
||||||
"ethcore-logger 1.3.0",
|
"ethcore-logger 1.3.0",
|
||||||
"ethcore-rpc 1.3.0",
|
"ethcore-rpc 1.3.0",
|
||||||
"ethcore-signer 1.3.0",
|
"ethcore-signer 1.3.0",
|
||||||
@ -358,6 +359,21 @@ dependencies = [
|
|||||||
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
|
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ethcore-ipc-tests"
|
||||||
|
version = "0.1.0"
|
||||||
|
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",
|
||||||
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
|
||||||
|
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethcore-logger"
|
name = "ethcore-logger"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
|
@ -10,6 +10,7 @@ build = "build.rs"
|
|||||||
rustc_version = "0.1"
|
rustc_version = "0.1"
|
||||||
syntex = "*"
|
syntex = "*"
|
||||||
ethcore-ipc-codegen = { path = "ipc/codegen" }
|
ethcore-ipc-codegen = { path = "ipc/codegen" }
|
||||||
|
ethcore-ipc-tests = { path = "ipc/tests" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
@ -58,6 +59,7 @@ use-precompiled-js = ["ethcore-dapps/use-precompiled-js", "ethcore-signer/use-pr
|
|||||||
dapps = ["ethcore-dapps"]
|
dapps = ["ethcore-dapps"]
|
||||||
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev", "ethcore-dapps/dev", "ethcore-signer/dev"]
|
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev", "ethcore-dapps/dev", "ethcore-signer/dev"]
|
||||||
ipc = ["ethcore/ipc"]
|
ipc = ["ethcore/ipc"]
|
||||||
|
json-tests = ["ethcore/json-tests"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
path = "parity/main.rs"
|
path = "parity/main.rs"
|
||||||
|
@ -62,6 +62,7 @@ impl TestSocket {
|
|||||||
impl Read for TestSocket {
|
impl Read for TestSocket {
|
||||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
|
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
|
||||||
let end_position = cmp::min(self.read_buffer.len(), self.cursor+buf.len());
|
let end_position = cmp::min(self.read_buffer.len(), self.cursor+buf.len());
|
||||||
|
if self.cursor > end_position { return Ok(0) }
|
||||||
let len = cmp::max(end_position - self.cursor, 0);
|
let len = cmp::max(end_position - self.cursor, 0);
|
||||||
match len {
|
match len {
|
||||||
0 => Ok(0),
|
0 => Ok(0),
|
||||||
@ -69,7 +70,7 @@ impl Read for TestSocket {
|
|||||||
for i in self.cursor..end_position {
|
for i in self.cursor..end_position {
|
||||||
buf[i-self.cursor] = self.read_buffer[i];
|
buf[i-self.cursor] = self.read_buffer[i];
|
||||||
}
|
}
|
||||||
self.cursor = self.cursor + buf.len();
|
self.cursor = end_position;
|
||||||
Ok(len)
|
Ok(len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,11 @@ path = "run.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
ethcore-ipc = { path = "../rpc" }
|
ethcore-ipc = { path = "../rpc" }
|
||||||
ethcore-devtools = { path = "../../devtools" }
|
ethcore-devtools = { path = "../../devtools" }
|
||||||
semver = "0.2.0"
|
semver = "0.2"
|
||||||
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" }
|
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" }
|
||||||
ethcore-ipc-nano = { path = "../nano" }
|
ethcore-ipc-nano = { path = "../nano" }
|
||||||
ethcore-util = { path = "../../util" }
|
ethcore-util = { path = "../../util" }
|
||||||
|
log = "0.3"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
syntex = "0.33"
|
syntex = "0.33"
|
||||||
|
@ -56,3 +56,11 @@ fn opt_two_vec() {
|
|||||||
let serialized = ::ipc::binary::serialize(&example).unwrap();
|
let serialized = ::ipc::binary::serialize(&example).unwrap();
|
||||||
assert_eq!(serialized, vec![0u8; 16]);
|
assert_eq!(serialized, vec![0u8; 16]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn enum_with_struct() {
|
||||||
|
let example = EnumWithStruct::Right { how_much: 15 };
|
||||||
|
let serialized = ::ipc::binary::serialize(&example).unwrap();
|
||||||
|
let deserialized = ::ipc::binary::deserialize::<EnumWithStruct>(&serialized).unwrap();
|
||||||
|
assert_eq!(example, deserialized);
|
||||||
|
}
|
||||||
|
@ -42,38 +42,6 @@ mod tests {
|
|||||||
assert_eq!(10, *service.commits.read().unwrap());
|
assert_eq!(10, *service.commits.read().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn call_service_handshake() {
|
|
||||||
let mut socket = TestSocket::new_ready(vec![0, 0,
|
|
||||||
// part count = 3
|
|
||||||
3, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
// part sizes
|
|
||||||
5, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
5, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
64, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
// total payload length
|
|
||||||
70, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
// protocol version
|
|
||||||
b'1', b'.', b'0', b'.', b'0',
|
|
||||||
// api version
|
|
||||||
b'1', b'.', b'0', b'.', b'0',
|
|
||||||
// reserved
|
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
]);
|
|
||||||
|
|
||||||
let service = Arc::new(Service::new());
|
|
||||||
let result = service.dispatch(&mut socket);
|
|
||||||
|
|
||||||
// single `true`
|
|
||||||
assert_eq!(vec![1], result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn call_service_client() {
|
fn call_service_client() {
|
||||||
let mut socket = TestSocket::new();
|
let mut socket = TestSocket::new();
|
||||||
@ -110,9 +78,9 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn query_default_version() {
|
fn query_default_version() {
|
||||||
let ver = Arc::<Service>::protocol_version();
|
let ver = Service::protocol_version();
|
||||||
assert_eq!(ver, Version::parse("1.0.0").unwrap());
|
assert_eq!(ver, Version::parse("1.0.0").unwrap());
|
||||||
let ver = Arc::<Service>::api_version();
|
let ver = Service::api_version();
|
||||||
assert_eq!(ver, Version::parse("1.0.0").unwrap());
|
assert_eq!(ver, Version::parse("1.0.0").unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,16 +121,11 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn can_invoke_generic_service() {
|
fn can_invoke_generic_service() {
|
||||||
let mut socket = TestSocket::new();
|
let mut socket = TestSocket::new();
|
||||||
socket.read_buffer = vec![
|
socket.read_buffer = vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
1, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0,
|
|
||||||
];
|
|
||||||
let db_client = DBClient::<u64, _>::init(socket);
|
let db_client = DBClient::<u64, _>::init(socket);
|
||||||
|
let result = db_client.write(vec![1u8; 1]);
|
||||||
let result = db_client.write(vec![0u8; 100]);
|
assert_eq!(vec![0, 16, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
|
||||||
|
db_client.socket().write().unwrap().write_buffer.clone());
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,7 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
use std::ops::*;
|
|
||||||
use ipc::IpcConfig;
|
use ipc::IpcConfig;
|
||||||
use ipc::BinaryConvertable;
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use ipc::binary::BinaryConvertError;
|
use ipc::binary::BinaryConvertError;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
@ -29,11 +27,11 @@ pub struct DB<L: Sized> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait DBWriter {
|
pub trait DBWriter {
|
||||||
fn write(&self, data: Vec<u8>) -> Result<(), DBError>;
|
fn write(&self, data: Vec<u8>) -> Result<(), DBError>;
|
||||||
fn write_slice(&self, data: &[u8]) -> Result<(), DBError>;
|
fn write_slice(&self, data: &[u8]) -> Result<(), DBError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IpcConfig<DBWriter> for ::std::sync::Arc<DBWriter> {}
|
impl IpcConfig for DBWriter {}
|
||||||
|
|
||||||
#[derive(Binary)]
|
#[derive(Binary)]
|
||||||
pub enum DBError { Write, Read }
|
pub enum DBError { Write, Read }
|
||||||
@ -58,4 +56,4 @@ trait DBNotify {
|
|||||||
fn notify(&self, a: u64, b: u64) -> bool;
|
fn notify(&self, a: u64, b: u64) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IpcConfig<DBNotify> for ::std::sync::Arc<DBNotify> { }
|
impl IpcConfig for DBNotify { }
|
||||||
|
@ -22,6 +22,7 @@ extern crate semver;
|
|||||||
extern crate nanomsg;
|
extern crate nanomsg;
|
||||||
extern crate ethcore_ipc_nano as nanoipc;
|
extern crate ethcore_ipc_nano as nanoipc;
|
||||||
extern crate ethcore_util as util;
|
extern crate ethcore_util as util;
|
||||||
|
#[macro_use] extern crate log;
|
||||||
|
|
||||||
pub mod service;
|
pub mod service;
|
||||||
mod examples;
|
mod examples;
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
use std::ops::*;
|
|
||||||
use ipc::IpcConfig;
|
use ipc::IpcConfig;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use ipc::binary::BinaryConvertError;
|
use ipc::binary::BinaryConvertError;
|
||||||
@ -70,4 +69,4 @@ impl Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::ipc::IpcConfig<Service> for ::std::sync::Arc<Service> {}
|
impl ::ipc::IpcConfig for Service {}
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use std::sync::RwLock;
|
|
||||||
use std::ops::*;
|
|
||||||
use ipc::IpcConfig;
|
use ipc::IpcConfig;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use ipc::binary::BinaryConvertError;
|
use ipc::binary::BinaryConvertError;
|
||||||
@ -31,4 +29,4 @@ impl BadlyNamedService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::ipc::IpcConfig<BadlyNamedService> for ::std::sync::Arc<BadlyNamedService> {}
|
impl IpcConfig for BadlyNamedService {}
|
||||||
|
@ -12,4 +12,5 @@ export TARGETS="
|
|||||||
-p ethstore \
|
-p ethstore \
|
||||||
-p ethsync \
|
-p ethsync \
|
||||||
-p ethcore-ipc \
|
-p ethcore-ipc \
|
||||||
|
-p ethcore-ipc-tests \
|
||||||
-p parity"
|
-p parity"
|
||||||
|
Loading…
Reference in New Issue
Block a user