Add an Error associated type to transports (#835)

* Add an Error associated type to transports

* Improve raw swarm a bit

* Rename map_other to map

* Use source() instead of cause()

* RawSwarmIncErr -> IncomingError
This commit is contained in:
Pierre Krieger
2019-01-10 11:27:06 +01:00
committed by GitHub
parent f55a8bc2f3
commit dbff125df2
30 changed files with 798 additions and 682 deletions

View File

@ -260,8 +260,7 @@ mod tests {
use self::libp2p_tcp::TcpConfig;
use futures::{Future, Stream};
use libp2p_core::{PublicKey, Transport, upgrade::{apply_outbound, apply_inbound}};
use std::sync::mpsc;
use std::thread;
use std::{io, sync::mpsc, thread};
#[test]
fn correct_transfer() {
@ -284,7 +283,8 @@ mod tests {
.map_err(|(err, _)| err)
.and_then(|(client, _)| client.unwrap().0)
.and_then(|socket| {
apply_inbound(socket, IdentifyProtocolConfig).map_err(|e| e.into_io_error())
apply_inbound(socket, IdentifyProtocolConfig)
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
})
.and_then(|sender| {
sender.send(
@ -308,9 +308,10 @@ mod tests {
let transport = TcpConfig::new();
let future = transport.dial(rx.recv().unwrap())
.unwrap_or_else(|_| panic!())
.unwrap()
.and_then(|socket| {
apply_outbound(socket, IdentifyProtocolConfig).map_err(|e| e.into_io_error())
apply_outbound(socket, IdentifyProtocolConfig)
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
})
.and_then(|RemoteInfo { info, observed_addr, .. }| {
assert_eq!(observed_addr, "/ip4/100.101.102.103/tcp/5000".parse().unwrap());