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