client handshake tests, errors

This commit is contained in:
NikVolf
2016-04-12 07:13:31 +03:00
parent fa47f1c28b
commit 0c42126b8f
3 changed files with 23 additions and 6 deletions

View File

@@ -512,7 +512,7 @@ fn push_client_implementation(
}
}
pub fn handshake(&self) -> bool {
pub fn handshake(&self) -> Result<(), ::ipc::Error> {
let payload = BinHandshake {
protocol_version: $item_ident::protocol_version().to_string(),
api_version: $item_ident::api_version().to_string(),
@@ -527,10 +527,13 @@ fn push_client_implementation(
&mut socket);
let mut result = vec![0u8; 1];
if socket.read(&mut result).unwrap() == 1 {
result[0] == 1
if try!(socket.read(&mut result).map_err(|_| ::ipc::Error::HandshakeFailed)) == 1 {
match result[0] {
1 => Ok(()),
_ => Err(::ipc::Error::RemoteServiceUnsupported),
}
}
else { false }
else { Err(::ipc::Error::HandshakeFailed) }
}
#[cfg(test)]