Fix the identify test multiplexer (#952)

This commit is contained in:
Pierre Krieger 2019-02-18 17:22:09 +01:00 committed by GitHub
parent 43e4d1f589
commit e2f99efb30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -221,8 +221,7 @@ pub enum IdentifyEvent {
mod tests { mod tests {
use crate::{Identify, IdentifyEvent}; use crate::{Identify, IdentifyEvent};
use futures::prelude::*; use futures::prelude::*;
use libp2p_core::{upgrade, upgrade::OutboundUpgradeExt, Swarm, Transport}; use libp2p_core::{upgrade, upgrade::OutboundUpgradeExt, upgrade::InboundUpgradeExt, Swarm, Transport};
use libp2p_core::muxing::StreamMuxerBox;
use std::io; use std::io;
#[test] #[test]
@ -238,12 +237,13 @@ mod tests {
let local_peer_id = node1_public_key.clone().into_peer_id(); let local_peer_id = node1_public_key.clone().into_peer_id();
let transport = libp2p_tcp::TcpConfig::new() let transport = libp2p_tcp::TcpConfig::new()
.with_upgrade(libp2p_secio::SecioConfig::new(node1_key)) .with_upgrade(libp2p_secio::SecioConfig::new(node1_key))
.and_then(move |out, _| { .and_then(move |out, endpoint| {
let peer_id = out.remote_key.into_peer_id(); let peer_id = out.remote_key.into_peer_id();
let upgrade = let peer_id2 = peer_id.clone();
libp2p_mplex::MplexConfig::new().map_outbound(move |muxer| (peer_id, muxer)); let upgrade = libp2p_mplex::MplexConfig::default()
upgrade::apply_outbound(out.stream, upgrade) .map_outbound(move |muxer| (peer_id, muxer))
.map(|(id, muxer)| (id, StreamMuxerBox::new(muxer))) .map_inbound(move |muxer| (peer_id2, muxer));
upgrade::apply(out.stream, upgrade, endpoint)
}) })
.map_err(|_| -> io::Error { panic!() }); .map_err(|_| -> io::Error { panic!() });
@ -256,12 +256,13 @@ mod tests {
let local_peer_id = node2_public_key.clone().into_peer_id(); let local_peer_id = node2_public_key.clone().into_peer_id();
let transport = libp2p_tcp::TcpConfig::new() let transport = libp2p_tcp::TcpConfig::new()
.with_upgrade(libp2p_secio::SecioConfig::new(node2_key)) .with_upgrade(libp2p_secio::SecioConfig::new(node2_key))
.and_then(move |out, _| { .and_then(move |out, endpoint| {
let peer_id = out.remote_key.into_peer_id(); let peer_id = out.remote_key.into_peer_id();
let upgrade = let peer_id2 = peer_id.clone();
libp2p_mplex::MplexConfig::new().map_outbound(move |muxer| (peer_id, muxer)); let upgrade = libp2p_mplex::MplexConfig::default()
upgrade::apply_outbound(out.stream, upgrade) .map_outbound(move |muxer| (peer_id, muxer))
.map(|(id, muxer)| (id, StreamMuxerBox::new(muxer))) .map_inbound(move |muxer| (peer_id2, muxer));
upgrade::apply(out.stream, upgrade, endpoint)
}) })
.map_err(|_| -> io::Error { panic!() }); .map_err(|_| -> io::Error { panic!() });