diff --git a/Cargo.lock b/Cargo.lock index 90312e0..c80322a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -602,9 +602,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "env_logger" -version = "0.7.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" dependencies = [ "log", "regex", @@ -1216,21 +1216,20 @@ dependencies = [ [[package]] name = "quickcheck" -version = "0.9.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f" +checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ "env_logger", "log", - "rand 0.7.3", - "rand_core 0.5.1", + "rand 0.8.3", ] [[package]] name = "quickcheck_macros" -version = "0.9.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608c156fd8e97febc07dc9c2e2c80bf74cfc6ef26893eae3daf8bc2bc94a4b7f" +checksum = "b22a693222d716a9587786f37ac3f6b4faedb5b80c23914e7303ff5a1d8016e9" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 552a2ca..2d2faf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,9 @@ aquatic_ws_protocol = { path = "aquatic_ws_protocol" } debug = true lto = true +[profile.test] +opt-level = 3 + [profile.bench] debug = true opt-level = 3 diff --git a/aquatic_http/Cargo.toml b/aquatic_http/Cargo.toml index 65d4a3b..da71513 100644 --- a/aquatic_http/Cargo.toml +++ b/aquatic_http/Cargo.toml @@ -39,5 +39,5 @@ smartstring = "0.2" socket2 = { version = "0.3", features = ["reuseport"] } [dev-dependencies] -quickcheck = "0.9" -quickcheck_macros = "0.9" +quickcheck = "1.0" +quickcheck_macros = "1.0" diff --git a/aquatic_http_load_test/Cargo.toml b/aquatic_http_load_test/Cargo.toml index 4262dc1..a5b2edb 100644 --- a/aquatic_http_load_test/Cargo.toml +++ b/aquatic_http_load_test/Cargo.toml @@ -21,5 +21,5 @@ rand_distr = "0.4" serde = { version = "1", features = ["derive"] } [dev-dependencies] -quickcheck = "0.9" -quickcheck_macros = "0.9" +quickcheck = "1.0" +quickcheck_macros = "1.0" diff --git a/aquatic_http_protocol/Cargo.toml b/aquatic_http_protocol/Cargo.toml index 6d757a0..fd5cbba 100644 --- a/aquatic_http_protocol/Cargo.toml +++ b/aquatic_http_protocol/Cargo.toml @@ -43,5 +43,5 @@ urlencoding = "1" [dev-dependencies] bendy = { version = "0.3", features = ["std", "serde"] } criterion = "0.3" -quickcheck = "0.9" -quickcheck_macros = "0.9" \ No newline at end of file +quickcheck = "1.0" +quickcheck_macros = "1.0" \ No newline at end of file diff --git a/aquatic_http_protocol/src/common.rs b/aquatic_http_protocol/src/common.rs index a0d5d4a..1ee1c2b 100644 --- a/aquatic_http_protocol/src/common.rs +++ b/aquatic_http_protocol/src/common.rs @@ -60,7 +60,7 @@ impl FromStr for AnnounceEvent { #[cfg(test)] impl quickcheck::Arbitrary for InfoHash { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { let mut arr = [b'0'; 20]; for byte in arr.iter_mut(){ @@ -74,7 +74,7 @@ impl quickcheck::Arbitrary for InfoHash { #[cfg(test)] impl quickcheck::Arbitrary for PeerId { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { let mut arr = [b'0'; 20]; for byte in arr.iter_mut(){ @@ -88,7 +88,7 @@ impl quickcheck::Arbitrary for PeerId { #[cfg(test)] impl quickcheck::Arbitrary for AnnounceEvent { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { match (bool::arbitrary(g), bool::arbitrary(g)){ (false, false) => Self::Started, (true, false) => Self::Started, diff --git a/aquatic_http_protocol/src/request.rs b/aquatic_http_protocol/src/request.rs index 5fde02a..c2af708 100644 --- a/aquatic_http_protocol/src/request.rs +++ b/aquatic_http_protocol/src/request.rs @@ -322,7 +322,7 @@ mod tests { } impl Arbitrary for AnnounceRequest { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { let key: Option = Arbitrary::arbitrary(g); AnnounceRequest { @@ -339,7 +339,7 @@ mod tests { } impl Arbitrary for ScrapeRequest { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { ScrapeRequest { info_hashes: Arbitrary::arbitrary(g), } @@ -347,7 +347,7 @@ mod tests { } impl Arbitrary for Request { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { if Arbitrary::arbitrary(g){ Self::Announce(Arbitrary::arbitrary(g)) } else { diff --git a/aquatic_http_protocol/src/response.rs b/aquatic_http_protocol/src/response.rs index 7d3031e..b301c4a 100644 --- a/aquatic_http_protocol/src/response.rs +++ b/aquatic_http_protocol/src/response.rs @@ -192,7 +192,7 @@ impl Response { #[cfg(test)] impl quickcheck::Arbitrary for ResponsePeer { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { ip_address: Ipv4Addr::arbitrary(g), port: u16::arbitrary(g) @@ -203,7 +203,7 @@ impl quickcheck::Arbitrary for ResponsePeer { #[cfg(test)] impl quickcheck::Arbitrary for ResponsePeer { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { ip_address: Ipv6Addr::arbitrary(g), port: u16::arbitrary(g) @@ -214,7 +214,7 @@ impl quickcheck::Arbitrary for ResponsePeer { #[cfg(test)] impl quickcheck::Arbitrary for ResponsePeerListV4 { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self(Vec::arbitrary(g)) } } @@ -222,7 +222,7 @@ impl quickcheck::Arbitrary for ResponsePeerListV4 { #[cfg(test)] impl quickcheck::Arbitrary for ResponsePeerListV6 { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self(Vec::arbitrary(g)) } } @@ -230,7 +230,7 @@ impl quickcheck::Arbitrary for ResponsePeerListV6 { #[cfg(test)] impl quickcheck::Arbitrary for ScrapeStatistics { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { complete: usize::arbitrary(g), incomplete: usize::arbitrary(g), @@ -242,7 +242,7 @@ impl quickcheck::Arbitrary for ScrapeStatistics { #[cfg(test)] impl quickcheck::Arbitrary for AnnounceResponse { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { announce_interval: usize::arbitrary(g), complete: usize::arbitrary(g), @@ -256,7 +256,7 @@ impl quickcheck::Arbitrary for AnnounceResponse { #[cfg(test)] impl quickcheck::Arbitrary for ScrapeResponse { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { files: BTreeMap::arbitrary(g), } @@ -266,7 +266,7 @@ impl quickcheck::Arbitrary for ScrapeResponse { #[cfg(test)] impl quickcheck::Arbitrary for FailureResponse { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { failure_reason: String::arbitrary(g), } diff --git a/aquatic_udp/Cargo.toml b/aquatic_udp/Cargo.toml index 4196f3c..15c43b3 100644 --- a/aquatic_udp/Cargo.toml +++ b/aquatic_udp/Cargo.toml @@ -33,5 +33,5 @@ serde = { version = "1", features = ["derive"] } socket2 = { version = "0.3", features = ["reuseport"] } [dev-dependencies] -quickcheck = "0.9" -quickcheck_macros = "0.9" +quickcheck = "1.0" +quickcheck_macros = "1.0" diff --git a/aquatic_udp/src/lib/handlers.rs b/aquatic_udp/src/lib/handlers.rs index aae5cdd..33c3041 100644 --- a/aquatic_udp/src/lib/handlers.rs +++ b/aquatic_udp/src/lib/handlers.rs @@ -414,17 +414,19 @@ mod tests { #[test] fn test_extract_response_peers(){ - fn prop(data: (u32, u16)) -> TestResult { - let gen_num_peers = data.0; + fn prop(data: (u16, u16)) -> TestResult { + let gen_num_peers = data.0 as u32; let req_num_peers = data.1 as usize; - let mut peer_map: PeerMap = IndexMap::new(); + let mut peer_map: PeerMap = IndexMap::with_capacity( + gen_num_peers as usize + ); let mut opt_sender_key = None; let mut opt_sender_peer = None; for i in 0..gen_num_peers { - let (key, value) = gen_peer_map_key_and_value(i); + let (key, value) = gen_peer_map_key_and_value((i << 16) + i); if i == 0 { opt_sender_key = Some(key); @@ -456,7 +458,7 @@ mod tests { // Check that returned peers are unique (no overlap) and that sender // isn't returned - let mut ip_addresses = HashSet::new(); + let mut ip_addresses = HashSet::with_capacity(peers.len()); for peer in peers { if peer == opt_sender_peer.clone().unwrap() || ip_addresses.contains(&peer.ip_address){ @@ -471,6 +473,6 @@ mod tests { TestResult::from_bool(success) } - quickcheck(prop as fn((u32, u16)) -> TestResult); + quickcheck(prop as fn((u16, u16)) -> TestResult); } } \ No newline at end of file diff --git a/aquatic_udp_load_test/Cargo.toml b/aquatic_udp_load_test/Cargo.toml index 5e899e8..6f4d2c0 100644 --- a/aquatic_udp_load_test/Cargo.toml +++ b/aquatic_udp_load_test/Cargo.toml @@ -24,5 +24,5 @@ serde = { version = "1", features = ["derive"] } socket2 = { version = "0.3", features = ["reuseport"] } [dev-dependencies] -quickcheck = "0.9" -quickcheck_macros = "0.9" +quickcheck = "1.0" +quickcheck_macros = "1.0" diff --git a/aquatic_udp_protocol/Cargo.toml b/aquatic_udp_protocol/Cargo.toml index 180efaa..e70ad78 100644 --- a/aquatic_udp_protocol/Cargo.toml +++ b/aquatic_udp_protocol/Cargo.toml @@ -11,5 +11,5 @@ repository = "https://github.com/greatest-ape/aquatic" byteorder = "1" [dev-dependencies] -quickcheck = "0.9" -quickcheck_macros = "0.9" \ No newline at end of file +quickcheck = "1.0" +quickcheck_macros = "1.0" \ No newline at end of file diff --git a/aquatic_udp_protocol/src/common.rs b/aquatic_udp_protocol/src/common.rs index 24f1026..1b36990 100644 --- a/aquatic_udp_protocol/src/common.rs +++ b/aquatic_udp_protocol/src/common.rs @@ -52,7 +52,7 @@ pub struct ResponsePeer { #[cfg(test)] impl quickcheck::Arbitrary for IpVersion { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { if bool::arbitrary(g) { IpVersion::IPv4 } else { @@ -64,7 +64,7 @@ impl quickcheck::Arbitrary for IpVersion { #[cfg(test)] impl quickcheck::Arbitrary for InfoHash { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { let mut bytes = [0u8; 20]; for byte in bytes.iter_mut() { @@ -78,7 +78,7 @@ impl quickcheck::Arbitrary for InfoHash { #[cfg(test)] impl quickcheck::Arbitrary for PeerId { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { let mut bytes = [0u8; 20]; for byte in bytes.iter_mut() { @@ -92,7 +92,7 @@ impl quickcheck::Arbitrary for PeerId { #[cfg(test)] impl quickcheck::Arbitrary for ResponsePeer { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { ip_address: ::std::net::IpAddr::arbitrary(g), port: Port(u16::arbitrary(g)), diff --git a/aquatic_udp_protocol/src/request.rs b/aquatic_udp_protocol/src/request.rs index f369d31..729fe46 100644 --- a/aquatic_udp_protocol/src/request.rs +++ b/aquatic_udp_protocol/src/request.rs @@ -292,7 +292,7 @@ mod tests { use super::*; impl quickcheck::Arbitrary for AnnounceEvent { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { match (bool::arbitrary(g), bool::arbitrary(g)){ (false, false) => Self::Started, (true, false) => Self::Started, @@ -303,7 +303,7 @@ mod tests { } impl quickcheck::Arbitrary for ConnectRequest { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { transaction_id: TransactionId(i32::arbitrary(g)), } @@ -311,7 +311,7 @@ mod tests { } impl quickcheck::Arbitrary for AnnounceRequest { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { connection_id: ConnectionId(i64::arbitrary(g)), transaction_id: TransactionId(i32::arbitrary(g)), @@ -330,7 +330,7 @@ mod tests { } impl quickcheck::Arbitrary for ScrapeRequest { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { let info_hashes = (0..u8::arbitrary(g)).map(|_| { InfoHash::arbitrary(g) }).collect(); diff --git a/aquatic_udp_protocol/src/response.rs b/aquatic_udp_protocol/src/response.rs index b17c3b2..e62e8c9 100644 --- a/aquatic_udp_protocol/src/response.rs +++ b/aquatic_udp_protocol/src/response.rs @@ -279,7 +279,7 @@ mod tests { use super::*; impl quickcheck::Arbitrary for TorrentScrapeStatistics { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { seeders: NumberOfPeers(i32::arbitrary(g)), completed: NumberOfDownloads(i32::arbitrary(g)), @@ -289,7 +289,7 @@ mod tests { } impl quickcheck::Arbitrary for ConnectResponse { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { connection_id: ConnectionId(i64::arbitrary(g)), transaction_id: TransactionId(i32::arbitrary(g)), @@ -298,7 +298,7 @@ mod tests { } impl quickcheck::Arbitrary for AnnounceResponse { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { let peers = (0..u8::arbitrary(g)).map(|_| { ResponsePeer::arbitrary(g) }).collect(); @@ -314,7 +314,7 @@ mod tests { } impl quickcheck::Arbitrary for ScrapeResponse { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { let torrent_stats = (0..u8::arbitrary(g)).map(|_| { TorrentScrapeStatistics::arbitrary(g) }).collect(); diff --git a/aquatic_ws/Cargo.toml b/aquatic_ws/Cargo.toml index a7b17a5..e105448 100644 --- a/aquatic_ws/Cargo.toml +++ b/aquatic_ws/Cargo.toml @@ -37,5 +37,5 @@ socket2 = { version = "0.3", features = ["reuseport"] } tungstenite = "0.11" [dev-dependencies] -quickcheck = "0.9" -quickcheck_macros = "0.9" +quickcheck = "1.0" +quickcheck_macros = "1.0" diff --git a/aquatic_ws_load_test/Cargo.toml b/aquatic_ws_load_test/Cargo.toml index 31f567c..8275c0a 100644 --- a/aquatic_ws_load_test/Cargo.toml +++ b/aquatic_ws_load_test/Cargo.toml @@ -24,5 +24,5 @@ slab = "0.4" tungstenite = "0.11" [dev-dependencies] -quickcheck = "0.9" -quickcheck_macros = "0.9" +quickcheck = "1.0" +quickcheck_macros = "1.0" diff --git a/aquatic_ws_protocol/Cargo.toml b/aquatic_ws_protocol/Cargo.toml index 2660a5f..a886b73 100644 --- a/aquatic_ws_protocol/Cargo.toml +++ b/aquatic_ws_protocol/Cargo.toml @@ -26,5 +26,5 @@ tungstenite = "0.11" [dev-dependencies] criterion = "0.3" -quickcheck = "0.9" -quickcheck_macros = "0.9" +quickcheck = "1.0" +quickcheck_macros = "1.0" diff --git a/aquatic_ws_protocol/src/lib.rs b/aquatic_ws_protocol/src/lib.rs index c7da48d..6ee663a 100644 --- a/aquatic_ws_protocol/src/lib.rs +++ b/aquatic_ws_protocol/src/lib.rs @@ -320,7 +320,7 @@ mod tests { use super::*; - fn arbitrary_20_bytes(g: &mut G) -> [u8; 20] { + fn arbitrary_20_bytes(g: &mut quickcheck::Gen) -> [u8; 20] { let mut bytes = [0u8; 20]; for byte in bytes.iter_mut() { @@ -335,25 +335,25 @@ mod tests { } impl Arbitrary for InfoHash { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self(arbitrary_20_bytes(g)) } } impl Arbitrary for PeerId { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self(arbitrary_20_bytes(g)) } } impl Arbitrary for OfferId { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self(arbitrary_20_bytes(g)) } } impl Arbitrary for AnnounceEvent { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { match (bool::arbitrary(g), bool::arbitrary(g)){ (false, false) => Self::Started, (true, false) => Self::Started, @@ -364,7 +364,7 @@ mod tests { } impl Arbitrary for MiddlemanOfferToPeer { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { action: AnnounceAction, peer_id: Arbitrary::arbitrary(g), @@ -376,7 +376,7 @@ mod tests { } impl Arbitrary for MiddlemanAnswerToPeer { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { action: AnnounceAction, peer_id: Arbitrary::arbitrary(g), @@ -388,7 +388,7 @@ mod tests { } impl Arbitrary for AnnounceRequestOffer { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { offer_id: Arbitrary::arbitrary(g), offer: sdp_json_value() @@ -397,7 +397,7 @@ mod tests { } impl Arbitrary for AnnounceRequest { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { let has_offers_or_answer_or_neither: Option = Arbitrary::arbitrary(g); let mut offers: Option> = None; @@ -436,7 +436,7 @@ mod tests { } impl Arbitrary for AnnounceResponse { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { action: AnnounceAction, info_hash: Arbitrary::arbitrary(g), @@ -448,7 +448,7 @@ mod tests { } impl Arbitrary for ScrapeRequest { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { action: ScrapeAction, info_hashes: Arbitrary::arbitrary(g), @@ -458,7 +458,7 @@ mod tests { impl Arbitrary for ScrapeRequestInfoHashes { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { if Arbitrary::arbitrary(g) { ScrapeRequestInfoHashes::Multiple(Arbitrary::arbitrary(g)) } else { @@ -468,7 +468,7 @@ mod tests { } impl Arbitrary for ScrapeStatistics { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { Self { complete: Arbitrary::arbitrary(g), incomplete: Arbitrary::arbitrary(g), @@ -478,7 +478,7 @@ mod tests { } impl Arbitrary for ScrapeResponse { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { let files: Vec<(InfoHash, ScrapeStatistics)> = Arbitrary::arbitrary(g); Self { @@ -489,7 +489,7 @@ mod tests { } impl Arbitrary for InMessage { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { if Arbitrary::arbitrary(g){ Self::AnnounceRequest(Arbitrary::arbitrary(g)) } else { @@ -499,7 +499,7 @@ mod tests { } impl Arbitrary for OutMessage { - fn arbitrary(g: &mut G) -> Self { + fn arbitrary(g: &mut quickcheck::Gen) -> Self { match (Arbitrary::arbitrary(g), Arbitrary::arbitrary(g)){ (false, false) => Self::AnnounceResponse(Arbitrary::arbitrary(g)), (true, false) => Self::ScrapeResponse(Arbitrary::arbitrary(g)),