Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
tomaka committed Nov 6, 2019
commit 6b86590a91f975edea832cb71d41c81cba22631c
14 changes: 11 additions & 3 deletions core/network/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,24 @@ mod tests {
// Build swarms whose behaviour is `DiscoveryBehaviour`.
let mut swarms = (0..25).map(|_| {
let keypair = Keypair::generate_ed25519();
let keypair2 = keypair.clone();

let transport = MemoryTransport
.with_upgrade(libp2p::secio::SecioConfig::new(keypair.clone()))
.and_then(move |out, endpoint| {
let peer_id = out.remote_key.into_peer_id();
let secio = libp2p::secio::SecioConfig::new(keypair2);
libp2p::core::upgrade::apply(
out,
secio,
endpoint,
libp2p::core::upgrade::Version::V1
)
})
.and_then(move |(peer_id, stream), endpoint| {
let peer_id2 = peer_id.clone();
let upgrade = libp2p::yamux::Config::default()
.map_inbound(move |muxer| (peer_id, muxer))
.map_outbound(move |muxer| (peer_id2, muxer));
upgrade::apply(out.stream, upgrade, endpoint)
upgrade::apply(stream, upgrade, endpoint, libp2p::core::upgrade::Version::V1)
});

let behaviour = DiscoveryBehaviour::new(keypair.public(), user_defined.clone(), false);
Expand Down
21 changes: 17 additions & 4 deletions core/network/src/legacy_proto/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,27 @@ fn build_nodes()
.collect();

for index in 0 .. 2 {
let keypair = keypairs[index].clone();
let transport = libp2p::core::transport::MemoryTransport
.with_upgrade(libp2p::secio::SecioConfig::new(keypairs[index].clone()))
.and_then(move |out, endpoint| {
let peer_id = out.remote_key.into_peer_id();
libp2p::core::upgrade::apply(out.stream, libp2p::yamux::Config::default(), endpoint)
let secio = libp2p::secio::SecioConfig::new(keypair);
libp2p::core::upgrade::apply(
out,
secio,
endpoint,
libp2p::core::upgrade::Version::V1
)
})
.and_then(move |(peer_id, stream), endpoint| {
libp2p::core::upgrade::apply(
stream,
libp2p::yamux::Config::default(),
endpoint,
libp2p::core::upgrade::Version::V1
)
.map(|muxer| (peer_id, libp2p::core::muxing::StreamMuxerBox::new(muxer)))
})
.with_timeout(Duration::from_secs(20))
.timeout(Duration::from_secs(20))
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))
.boxed();

Expand Down