Skip to content

Commit 6735018

Browse files
committed
Merge #1520: Remove integration tests from torrent-repository package
1472c8e refactor: [#1504] remove unneded trait implementationis for Swarm (Jose Celano) c2dabb2 chore: [#1504] remove uneeded fn attribute (Jose Celano) 8d3b948 tests: [#1504] remove integration tests from torrent-repository pacakge (Jose Celano) Pull request description: All features are now covered by unit tests. I have also removed unused trait implementations for the `Swarm` type. If we need them in the future, we should extract a private type to use derived implementations: From: ```rust #[derive(Clone)] pub struct Swarm { info_hash: InfoHash, peers: BTreeMap<SocketAddr, Arc<PeerAnnouncement>>, metadata: SwarmMetadata, event_sender: Sender, } ``` To: ```rust #[derive(Clone)] pub struct Swarm { data: SwarmData, event_sender: Sender, } #[derive(Clone, Debug, Display, Hash, PartialEq, Eq)] pub struct SwarmData { info_hash: InfoHash, peers: BTreeMap<SocketAddr, Arc<PeerAnnouncement>>, metadata: SwarmMetadata, } ``` ACKs for top commit: josecelano: ACK 1472c8e Tree-SHA512: f350957ed47f234e41762e523bef66e337176e91011c3fbed4219a10bae44cca11a29e7736392f759d1d67f298553ec0c4a2960bed6817f3035cea8acc0beccf
2 parents 66bf0cc + 1472c8e commit 6735018

File tree

7 files changed

+0
-1088
lines changed

7 files changed

+0
-1088
lines changed

packages/torrent-repository/src/swarm.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! A swarm is a collection of peers that are all trying to download the same
22
//! torrent.
33
use std::collections::BTreeMap;
4-
use std::fmt::Debug;
5-
use std::hash::{Hash, Hasher};
64
use std::net::SocketAddr;
75
use std::sync::Arc;
86

@@ -24,31 +22,6 @@ pub struct Swarm {
2422
event_sender: Sender,
2523
}
2624

27-
#[allow(clippy::missing_fields_in_debug)]
28-
impl Debug for Swarm {
29-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30-
f.debug_struct("Swarm")
31-
.field("peers", &self.peers)
32-
.field("metadata", &self.metadata)
33-
.finish()
34-
}
35-
}
36-
37-
impl Hash for Swarm {
38-
fn hash<H: Hasher>(&self, state: &mut H) {
39-
self.peers.hash(state);
40-
self.metadata.hash(state);
41-
}
42-
}
43-
44-
impl PartialEq for Swarm {
45-
fn eq(&self, other: &Self) -> bool {
46-
self.peers == other.peers && self.metadata == other.metadata
47-
}
48-
}
49-
50-
impl Eq for Swarm {}
51-
5225
impl Swarm {
5326
#[must_use]
5427
pub fn new(info_hash: &InfoHash, downloaded: u32, event_sender: Sender) -> Self {
@@ -329,16 +302,6 @@ mod tests {
329302
use crate::swarm::Swarm;
330303
use crate::tests::sample_info_hash;
331304

332-
#[test]
333-
fn it_should_allow_debugging() {
334-
let swarm = Swarm::new(&sample_info_hash(), 0, None);
335-
336-
assert_eq!(
337-
format!("{swarm:?}"),
338-
"Swarm { peers: {}, metadata: SwarmMetadata { downloaded: 0, complete: 0, incomplete: 0 } }"
339-
);
340-
}
341-
342305
#[test]
343306
fn it_should_be_empty_when_no_peers_have_been_inserted() {
344307
let swarm = Swarm::new(&sample_info_hash(), 0, None);

packages/torrent-repository/src/swarms.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ impl Swarms {
4949
/// # Errors
5050
///
5151
/// This function panics if the lock for the swarm handle cannot be acquired.
52-
#[allow(clippy::await_holding_lock)]
5352
pub async fn handle_announcement(
5453
&self,
5554
info_hash: &InfoHash,

packages/torrent-repository/tests/common/mod.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/torrent-repository/tests/common/torrent_peer_builder.rs

Lines changed: 0 additions & 106 deletions
This file was deleted.

packages/torrent-repository/tests/integration.rs

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)