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:
Nikolay Volf 2016-08-01 16:32:07 +03:00 committed by Gav Wood
parent f19b00b6ca
commit 4e72608441
12 changed files with 44 additions and 56 deletions

16
Cargo.lock generated
View File

@ -15,6 +15,7 @@ dependencies = [
"ethcore-ipc-codegen 1.3.0",
"ethcore-ipc-hypervisor 1.2.0",
"ethcore-ipc-nano 1.3.0",
"ethcore-ipc-tests 0.1.0",
"ethcore-logger 1.3.0",
"ethcore-rpc 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)",
]
[[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]]
name = "ethcore-logger"
version = "1.3.0"

View File

@ -10,6 +10,7 @@ build = "build.rs"
rustc_version = "0.1"
syntex = "*"
ethcore-ipc-codegen = { path = "ipc/codegen" }
ethcore-ipc-tests = { path = "ipc/tests" }
[dependencies]
log = "0.3"
@ -58,6 +59,7 @@ use-precompiled-js = ["ethcore-dapps/use-precompiled-js", "ethcore-signer/use-pr
dapps = ["ethcore-dapps"]
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev", "ethcore-dapps/dev", "ethcore-signer/dev"]
ipc = ["ethcore/ipc"]
json-tests = ["ethcore/json-tests"]
[[bin]]
path = "parity/main.rs"

View File

@ -62,6 +62,7 @@ impl TestSocket {
impl Read for TestSocket {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
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);
match len {
0 => Ok(0),
@ -69,7 +70,7 @@ impl Read for TestSocket {
for i in self.cursor..end_position {
buf[i-self.cursor] = self.read_buffer[i];
}
self.cursor = self.cursor + buf.len();
self.cursor = end_position;
Ok(len)
}
}

View File

@ -10,10 +10,11 @@ path = "run.rs"
[dependencies]
ethcore-ipc = { path = "../rpc" }
ethcore-devtools = { path = "../../devtools" }
semver = "0.2.0"
semver = "0.2"
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" }
ethcore-ipc-nano = { path = "../nano" }
ethcore-util = { path = "../../util" }
log = "0.3"
[build-dependencies]
syntex = "0.33"

View File

@ -56,3 +56,11 @@ fn opt_two_vec() {
let serialized = ::ipc::binary::serialize(&example).unwrap();
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);
}

View File

@ -42,38 +42,6 @@ mod tests {
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]
fn call_service_client() {
let mut socket = TestSocket::new();
@ -110,9 +78,9 @@ mod tests {
#[test]
fn query_default_version() {
let ver = Arc::<Service>::protocol_version();
let ver = Service::protocol_version();
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());
}
@ -153,16 +121,11 @@ mod tests {
#[test]
fn can_invoke_generic_service() {
let mut socket = TestSocket::new();
socket.read_buffer = vec![
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,
];
socket.read_buffer = vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let db_client = DBClient::<u64, _>::init(socket);
let result = db_client.write(vec![0u8; 100]);
let result = db_client.write(vec![1u8; 1]);
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());
}

View File

@ -15,9 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::sync::RwLock;
use std::ops::*;
use ipc::IpcConfig;
use ipc::BinaryConvertable;
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;
@ -29,11 +27,11 @@ pub struct DB<L: Sized> {
}
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>;
}
impl IpcConfig<DBWriter> for ::std::sync::Arc<DBWriter> {}
impl IpcConfig for DBWriter {}
#[derive(Binary)]
pub enum DBError { Write, Read }
@ -58,4 +56,4 @@ trait DBNotify {
fn notify(&self, a: u64, b: u64) -> bool;
}
impl IpcConfig<DBNotify> for ::std::sync::Arc<DBNotify> { }
impl IpcConfig for DBNotify { }

View File

@ -22,6 +22,7 @@ extern crate semver;
extern crate nanomsg;
extern crate ethcore_ipc_nano as nanoipc;
extern crate ethcore_util as util;
#[macro_use] extern crate log;
pub mod service;
mod examples;

View File

@ -15,7 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::sync::RwLock;
use std::ops::*;
use ipc::IpcConfig;
use std::mem;
use ipc::binary::BinaryConvertError;
@ -70,4 +69,4 @@ impl Service {
}
}
impl ::ipc::IpcConfig<Service> for ::std::sync::Arc<Service> {}
impl ::ipc::IpcConfig for Service {}

View File

@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::sync::RwLock;
use std::ops::*;
use ipc::IpcConfig;
use std::mem;
use ipc::binary::BinaryConvertError;
@ -31,4 +29,4 @@ impl BadlyNamedService {
}
}
impl ::ipc::IpcConfig<BadlyNamedService> for ::std::sync::Arc<BadlyNamedService> {}
impl IpcConfig for BadlyNamedService {}

View File

@ -12,4 +12,5 @@ export TARGETS="
-p ethstore \
-p ethsync \
-p ethcore-ipc \
-p ethcore-ipc-tests \
-p parity"

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Running Parity Full Test Sute
FEATURES="--features ethcore/json-tests"
FEATURES="--features json-tests"
case $1 in
--no-json)