Skip to content

Commit

Permalink
core/tests: Remove unnecessary Arc (#2763)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger authored Jul 22, 2022
1 parent f15a3dc commit 2e2c117
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
3 changes: 1 addition & 2 deletions muxers/mplex/tests/async_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use futures::future::poll_fn;
use futures::{channel::oneshot, prelude::*};
use libp2p_core::{upgrade, StreamMuxer, Transport};
use libp2p_tcp::TcpTransport;
use std::sync::Arc;

#[test]
fn async_write() {
Expand Down Expand Up @@ -72,7 +71,7 @@ fn async_write() {
let mut transport = TcpTransport::default()
.and_then(move |c, e| upgrade::apply(c, mplex, e, upgrade::Version::V1));

let client = Arc::new(transport.dial(rx.await.unwrap()).unwrap().await.unwrap());
let client = transport.dial(rx.await.unwrap()).unwrap().await.unwrap();
let mut inbound = poll_fn(|cx| client.poll_inbound(cx)).await.unwrap();
inbound.write_all(b"hello world").await.unwrap();

Expand Down
23 changes: 10 additions & 13 deletions muxers/mplex/tests/two_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use futures::future::poll_fn;
use futures::{channel::oneshot, prelude::*};
use libp2p_core::{upgrade, StreamMuxer, Transport};
use libp2p_tcp::TcpTransport;
use std::sync::Arc;

#[test]
fn client_to_server_outbound() {
Expand Down Expand Up @@ -73,7 +72,7 @@ fn client_to_server_outbound() {
.and_then(move |c, e| upgrade::apply(c, mplex, e, upgrade::Version::V1))
.boxed();

let client = Arc::new(transport.dial(rx.await.unwrap()).unwrap().await.unwrap());
let client = transport.dial(rx.await.unwrap()).unwrap().await.unwrap();
let mut inbound = poll_fn(|cx| client.poll_inbound(cx)).await.unwrap();
inbound.write_all(b"hello world").await.unwrap();
inbound.close().await.unwrap();
Expand Down Expand Up @@ -108,17 +107,15 @@ fn client_to_server_inbound() {

tx.send(addr).unwrap();

let client = Arc::new(
transport
.next()
.await
.expect("some event")
.into_incoming()
.unwrap()
.0
.await
.unwrap(),
);
let client = transport
.next()
.await
.expect("some event")
.into_incoming()
.unwrap()
.0
.await
.unwrap();

let mut inbound = poll_fn(|cx| client.poll_inbound(cx)).await.unwrap();

Expand Down

0 comments on commit 2e2c117

Please sign in to comment.