Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.cargo: Run clippy on ALL the source files #2949

Merged
merged 9 commits into from
Oct 4, 2022
2 changes: 1 addition & 1 deletion core/benches/peer_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn clone(c: &mut Criterion) {

c.bench_function("clone", |b| {
b.iter(|| {
black_box(peer_id.clone());
black_box(peer_id);
})
});
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/identity/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ mod tests {
use super::*;
use quickcheck::*;

const KEY1: &'static [u8] = include_bytes!("test/rsa-2048.pk8");
const KEY2: &'static [u8] = include_bytes!("test/rsa-3072.pk8");
const KEY3: &'static [u8] = include_bytes!("test/rsa-4096.pk8");
const KEY1: &[u8] = include_bytes!("test/rsa-2048.pk8");
const KEY2: &[u8] = include_bytes!("test/rsa-3072.pk8");
const KEY3: &[u8] = include_bytes!("test/rsa-4096.pk8");

#[derive(Clone, Debug)]
struct SomeKeypair(Keypair);
Expand Down
10 changes: 5 additions & 5 deletions core/src/peer_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ mod tests {

#[test]
fn extract_peer_id_from_multi_address() {
let address =
format!("/memory/1234/p2p/12D3KooWGQmdpzHXCqLno4mMxWXKNFQHASBeF99gTm2JR8Vu5Bdc")
.parse()
.unwrap();
let address = "/memory/1234/p2p/12D3KooWGQmdpzHXCqLno4mMxWXKNFQHASBeF99gTm2JR8Vu5Bdc"
.to_string()
.parse()
.unwrap();

let peer_id = PeerId::try_from_multiaddr(&address).unwrap();

Expand All @@ -303,7 +303,7 @@ mod tests {

#[test]
fn no_panic_on_extract_peer_id_from_multi_address_if_not_present() {
let address = format!("/memory/1234").parse().unwrap();
let address = "/memory/1234".to_string().parse().unwrap();

let maybe_empty = PeerId::try_from_multiaddr(&address);

Expand Down
2 changes: 1 addition & 1 deletion misc/multistream-select/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ mod tests {
fn prop(msg: Message) {
let mut buf = BytesMut::new();
msg.encode(&mut buf)
.expect(&format!("Encoding message failed: {:?}", msg));
.unwrap_or_else(|_| panic!("Encoding message failed: {:?}", msg));
match Message::decode(buf.freeze()) {
Ok(m) => assert_eq!(m, msg),
Err(e) => panic!("Decoding failed: {:?}", e),
Expand Down
2 changes: 1 addition & 1 deletion muxers/mplex/benches/split_send_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const BENCH_SIZES: [usize; 8] = [
fn prepare(c: &mut Criterion) {
let _ = env_logger::try_init();

let payload: Vec<u8> = vec![1; 1024 * 1024 * 1];
let payload: Vec<u8> = vec![1; 1024 * 1024];

let mut tcp = c.benchmark_group("tcp");
let tcp_addr = multiaddr![Ip4(std::net::Ipv4Addr::new(127, 0, 0, 1)), Tcp(0u16)];
Expand Down
2 changes: 1 addition & 1 deletion muxers/mplex/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ mod tests {
w_buf: BytesMut::new(),
eof: false,
};
let mut m = Multiplexed::new(conn, cfg.clone());
let mut m = Multiplexed::new(conn, cfg);

// Run the test.
let mut opened = HashSet::new();
Expand Down
2 changes: 1 addition & 1 deletion protocols/autonat/tests/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ async fn test_confidence() {
}
} else {
let unreachable_addr: Multiaddr = "/ip4/127.0.0.1/tcp/42".parse().unwrap();
client.add_external_address(unreachable_addr.clone(), AddressScore::Infinite);
client.add_external_address(unreachable_addr, AddressScore::Infinite);
}

for i in 0..MAX_CONFIDENCE + 1 {
Expand Down
11 changes: 4 additions & 7 deletions protocols/dcutr/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ fn connect() {
let mut dst = build_client();
let dst_peer_id = *dst.local_peer_id();
let dst_relayed_addr = relay_addr
.clone()
.with(Protocol::P2p(relay_peer_id.into()))
.with(Protocol::P2pCircuit)
.with(Protocol::P2p(dst_peer_id.into()));
Expand Down Expand Up @@ -96,7 +95,7 @@ fn connect() {
fn build_relay() -> Swarm<relay::Relay> {
let local_key = identity::Keypair::generate_ed25519();
let local_public_key = local_key.public();
let local_peer_id = local_public_key.clone().to_peer_id();
let local_peer_id = local_public_key.to_peer_id();

let transport = build_transport(MemoryTransport::default().boxed(), local_public_key);

Expand All @@ -116,7 +115,7 @@ fn build_relay() -> Swarm<relay::Relay> {
fn build_client() -> Swarm<Client> {
let local_key = identity::Keypair::generate_ed25519();
let local_public_key = local_key.public();
let local_peer_id = local_public_key.clone().to_peer_id();
let local_peer_id = local_public_key.to_peer_id();

let (relay_transport, behaviour) = client::Client::new_transport_and_behaviour(local_peer_id);
let transport = build_transport(
Expand All @@ -141,13 +140,11 @@ fn build_transport<StreamSink>(
where
StreamSink: AsyncRead + AsyncWrite + Send + Unpin + 'static,
{
let transport = transport
transport
.upgrade(Version::V1)
.authenticate(PlainText2Config { local_public_key })
.multiplex(libp2p::yamux::YamuxConfig::default())
.boxed();

transport
.boxed()
}

#[derive(NetworkBehaviour)]
Expand Down
Loading