Skip to content

Commit

Permalink
build(deps): Bump rand to 0.8 and quickcheck to 1 (#2857)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Max Inden <mail@max-inden.de>
  • Loading branch information
3 people committed Sep 22, 2022
1 parent a4d1e58 commit e530118
Show file tree
Hide file tree
Showing 49 changed files with 344 additions and 199 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
# 0.49.0 - [unreleased]

- Update to [`libp2p-tcp` `v0.37.0`](transports/tcp/CHANGELOG.md#0370).
- Update individual crates.
- Update to [`libp2p-ping` `v0.39.1`](protocols/ping/CHANGELOG.md#0391).
- Update to [`libp2p-floodsub` `v0.39.1`](protocols/floodsub/CHANGELOG.md#0391).
- Update to [`libp2p-gossipsub` `v0.41.1`](protocols/gossipsub/CHANGELOG.md#0411).
- Update to [`libp2p-request-response` `v0.21.1`](protocols/request-response/CHANGELOG.md#0211).
- Update to [`libp2p-pnet` `v0.22.1`](transports/pnet/CHANGELOG.md#0221).
- Update to [`libp2p-mplex` `v0.36.1`](muxers/mplex/CHANGELOG.md#0361).
- Update to [`libp2p-swarm` `v0.39.1`](swarm/CHANGELOG.md#0391).
-
- Update to [`libp2p-noise` `v0.39.1`](transports/noise/CHANGELOG.md#0391).

Expand Down
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ rendezvous = ["dep:libp2p-rendezvous"]
tcp-async-io = ["dep:libp2p-tcp", "libp2p-tcp?/async-io"]
tcp-tokio = ["dep:libp2p-tcp", "libp2p-tcp?/tokio"]
uds = ["dep:libp2p-uds"]
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "rand/wasm-bindgen"]
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js"]
wasm-ext = ["dep:libp2p-wasm-ext"]
wasm-ext-websocket = ["wasm-ext", "libp2p-wasm-ext?/websocket"]
websocket = ["dep:libp2p-websocket"]
Expand All @@ -83,27 +83,26 @@ lazy_static = "1.2"
libp2p-autonat = { version = "0.7.0", path = "protocols/autonat", optional = true }
libp2p-core = { version = "0.36.0", path = "core", default-features = false }
libp2p-dcutr = { version = "0.6.0", path = "protocols/dcutr", optional = true }
libp2p-floodsub = { version = "0.39.0", path = "protocols/floodsub", optional = true }
libp2p-floodsub = { version = "0.39.1", path = "protocols/floodsub", optional = true }
libp2p-identify = { version = "0.39.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.41.0", path = "protocols/kad", optional = true }
libp2p-metrics = { version = "0.10.0", path = "misc/metrics", optional = true }
libp2p-mplex = { version = "0.36.0", path = "muxers/mplex", optional = true }
libp2p-mplex = { version = "0.36.1", path = "muxers/mplex", optional = true }
libp2p-noise = { version = "0.39.1", path = "transports/noise", optional = true }
libp2p-ping = { version = "0.39.0", path = "protocols/ping", optional = true }
libp2p-ping = { version = "0.39.1", path = "protocols/ping", optional = true }
libp2p-plaintext = { version = "0.36.0", path = "transports/plaintext", optional = true }
libp2p-pnet = { version = "0.22.0", path = "transports/pnet", optional = true }
libp2p-pnet = { version = "0.22.1", path = "transports/pnet", optional = true }
libp2p-relay = { version = "0.12.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.9.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.21.0", path = "protocols/request-response", optional = true }
libp2p-swarm = { version = "0.39.0", path = "swarm" }
libp2p-request-response = { version = "0.21.1", path = "protocols/request-response", optional = true }
libp2p-swarm = { version = "0.39.1", path = "swarm" }
libp2p-swarm-derive = { version = "0.30.1", path = "swarm-derive" }
libp2p-uds = { version = "0.35.0", path = "transports/uds", optional = true }
libp2p-wasm-ext = { version = "0.36.0", path = "transports/wasm-ext", default-features = false, optional = true }
libp2p-yamux = { version = "0.40.0", path = "muxers/yamux", optional = true }
multiaddr = { version = "0.14.0" }
parking_lot = "0.12.0"
pin-project = "1.0.0"
rand = "0.7.3" # Explicit dependency to be used in `wasm-bindgen` feature
smallvec = "1.6.1"

[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies]
Expand All @@ -114,7 +113,7 @@ libp2p-tcp = { version = "0.37.0", path = "transports/tcp", default-features = f
libp2p-websocket = { version = "0.38.0", path = "transports/websocket", optional = true }

[target.'cfg(not(target_os = "unknown"))'.dependencies]
libp2p-gossipsub = { version = "0.41.0", path = "protocols/gossipsub", optional = true }
libp2p-gossipsub = { version = "0.41.1", path = "protocols/gossipsub", optional = true }

[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
Expand All @@ -131,6 +130,7 @@ members = [
"misc/rw-stream-sink",
"misc/keygen",
"misc/prost-codec",
"misc/quickcheck-ext",
"muxers/mplex",
"muxers/yamux",
"protocols/dcutr",
Expand Down
3 changes: 1 addition & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ base64 = "0.13.0"
criterion = "0.4"
libp2p = { path = "../", default-features = false, features = ["mplex", "noise"] }
multihash = { version = "0.16", default-features = false, features = ["arb"] }
quickcheck = "0.9.0"
rand07 = { package = "rand", version = "0.7" }
quickcheck = { package = "quickcheck-ext", path = "../misc/quickcheck-ext" }
rmp-serde = "1.0"
serde_json = "1.0"

Expand Down
5 changes: 2 additions & 3 deletions core/src/identity/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ impl DerDecodable<'_> for Asn1SubjectPublicKeyInfo {
mod tests {
use super::*;
use quickcheck::*;
use rand07::seq::SliceRandom;
use std::fmt;

const KEY1: &'static [u8] = include_bytes!("test/rsa-2048.pk8");
Expand All @@ -323,8 +322,8 @@ mod tests {
}

impl Arbitrary for SomeKeypair {
fn arbitrary<G: Gen>(g: &mut G) -> SomeKeypair {
let mut key = [KEY1, KEY2, KEY3].choose(g).unwrap().to_vec();
fn arbitrary(g: &mut Gen) -> SomeKeypair {
let mut key = g.choose(&[KEY1, KEY2, KEY3]).unwrap().to_vec();
SomeKeypair(Keypair::from_pkcs8(&mut key).unwrap())
}
}
Expand Down
4 changes: 2 additions & 2 deletions misc/multistream-select/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ unsigned-varint = "0.7"
async-std = "1.6.2"
env_logger = "0.9"
libp2p = { path = "../../", default-features = false, features = ["mplex", "plaintext"] }
quickcheck = "0.9.0"
rand = "0.7.2"
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
rand = "0.8"
rw-stream-sink = { version = "0.3.0", path = "../../misc/rw-stream-sink" }
13 changes: 6 additions & 7 deletions misc/multistream-select/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,24 +455,23 @@ impl fmt::Display for ProtocolError {
mod tests {
use super::*;
use quickcheck::*;
use rand::distributions::Alphanumeric;
use rand::Rng;
use std::iter;

impl Arbitrary for Protocol {
fn arbitrary<G: Gen>(g: &mut G) -> Protocol {
let n = g.gen_range(1, g.size());
fn arbitrary(g: &mut Gen) -> Protocol {
let n = g.gen_range(1..g.size());
let p: String = iter::repeat(())
.map(|()| g.sample(Alphanumeric))
.map(|()| char::arbitrary(g))
.filter(|&c| c.is_ascii_alphanumeric())
.take(n)
.collect();
Protocol(Bytes::from(format!("/{}", p)))
}
}

impl Arbitrary for Message {
fn arbitrary<G: Gen>(g: &mut G) -> Message {
match g.gen_range(0, 5) {
fn arbitrary(g: &mut Gen) -> Message {
match g.gen_range(0..5u8) {
0 => Message::Header(HeaderLine::V1),
1 => Message::NotAvailable,
2 => Message::ListProtocols,
Expand Down
10 changes: 10 additions & 0 deletions misc/quickcheck-ext/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "quickcheck-ext"
version = "0.1.0"
edition = "2021"
publish = false
license = "Unlicense/MIT"

[dependencies]
quickcheck = "1"
num-traits = "0.2"
44 changes: 44 additions & 0 deletions misc/quickcheck-ext/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
pub use quickcheck::*;

use core::ops::Range;
use num_traits::sign::Unsigned;

pub trait GenRange {
fn gen_range<T: Unsigned + Arbitrary + Copy>(&mut self, _range: Range<T>) -> T;

fn gen_index(&mut self, ubound: usize) -> usize {
if ubound <= (core::u32::MAX as usize) {
self.gen_range(0..ubound as u32) as usize
} else {
self.gen_range(0..ubound)
}
}
}

impl GenRange for Gen {
fn gen_range<T: Unsigned + Arbitrary + Copy>(&mut self, range: Range<T>) -> T {
<T as Arbitrary>::arbitrary(self) % (range.end - range.start) + range.start
}
}

pub trait SliceRandom {
fn shuffle<T>(&mut self, arr: &mut [T]);
fn choose_multiple<'a, T>(
&mut self,
arr: &'a [T],
amount: usize,
) -> std::iter::Take<std::vec::IntoIter<&'a T>> {
let mut v: Vec<&T> = arr.iter().collect();
self.shuffle(&mut v);
v.into_iter().take(amount)
}
}

impl SliceRandom for Gen {
fn shuffle<T>(&mut self, arr: &mut [T]) {
for i in (1..arr.len()).rev() {
// invariant: elements with index > i have been locked in place.
arr.swap(i, self.gen_index(i + 1));
}
}
}
6 changes: 6 additions & 0 deletions muxers/mplex/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.36.1 [unreleased]

- Bump rand to 0.8 and quickcheck to 1. See [PR 2857].

[PR 2857]: https://github.com/libp2p/rust-libp2p/pull/2857

# 0.36.0

- Update to `libp2p-core` `v0.36.0`
Expand Down
7 changes: 3 additions & 4 deletions muxers/mplex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-mplex"
edition = "2021"
rust-version = "1.56.1"
description = "Mplex multiplexing protocol for libp2p"
version = "0.36.0"
version = "0.36.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -18,7 +18,7 @@ libp2p-core = { version = "0.36.0", path = "../../core", default-features = fals
log = "0.4"
nohash-hasher = "0.2"
parking_lot = "0.12"
rand = "0.7"
rand = "0.8"
smallvec = "1.6.1"
unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }

Expand All @@ -28,8 +28,7 @@ criterion = "0.4"
env_logger = "0.9"
futures = "0.3"
libp2p = { path = "../../", default-features = false, features = ["tcp-async-io", "plaintext", "mplex"] }
quickcheck = "0.9"
rand = "0.7"
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }

[[bench]]
name = "split_send_size"
Expand Down
14 changes: 6 additions & 8 deletions muxers/mplex/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,27 +1105,25 @@ mod tests {
use asynchronous_codec::{Decoder, Encoder};
use bytes::BytesMut;
use quickcheck::*;
use rand::prelude::*;
use std::collections::HashSet;
use std::num::NonZeroU8;
use std::ops::DerefMut;
use std::pin::Pin;

impl Arbitrary for MaxBufferBehaviour {
fn arbitrary<G: Gen>(g: &mut G) -> MaxBufferBehaviour {
*[MaxBufferBehaviour::Block, MaxBufferBehaviour::ResetStream]
.choose(g)
fn arbitrary(g: &mut Gen) -> MaxBufferBehaviour {
*g.choose(&[MaxBufferBehaviour::Block, MaxBufferBehaviour::ResetStream])
.unwrap()
}
}

impl Arbitrary for MplexConfig {
fn arbitrary<G: Gen>(g: &mut G) -> MplexConfig {
fn arbitrary(g: &mut Gen) -> MplexConfig {
MplexConfig {
max_substreams: g.gen_range(1, 100),
max_buffer_len: g.gen_range(1, 1000),
max_substreams: g.gen_range(1..100),
max_buffer_len: g.gen_range(1..1000),
max_buffer_behaviour: MaxBufferBehaviour::arbitrary(g),
split_send_size: g.gen_range(1, 10000),
split_send_size: g.gen_range(1..10000),
protocol_name: crate::config::DEFAULT_MPLEX_PROTOCOL_NAME,
}
}
Expand Down
2 changes: 1 addition & 1 deletion protocols/dcutr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ prost-build = "0.11"
[dev-dependencies]
env_logger = "0.9.0"
libp2p = { path = "../..", default-features = false, features = ["dcutr", "relay", "plaintext", "identify", "tcp-async-io", "ping", "noise", "dns-async-std", "yamux"] }
rand = "0.7"
rand = "0.8"
clap = {version = "3.1.6", features = ["derive"]}
6 changes: 6 additions & 0 deletions protocols/floodsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.39.1 [unreleased]

- Bump rand to 0.8 and quickcheck to 1. See [PR 2857].

[PR 2857]: https://github.com/libp2p/rust-libp2p/pull/2857

# 0.39.0

- Update to `libp2p-swarm` `v0.39.0`.
Expand Down
4 changes: 2 additions & 2 deletions protocols/floodsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-floodsub"
edition = "2021"
rust-version = "1.56.1"
description = "Floodsub protocol for libp2p"
version = "0.39.0"
version = "0.39.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -18,7 +18,7 @@ libp2p-core = { version = "0.36.0", path = "../../core", default-features = fals
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4"
prost = "0.11"
rand = "0.7"
rand = "0.8"
smallvec = "1.6.1"

[build-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.41.1 [unreleased]

- Bump rand to 0.8 and quickcheck to 1. See [PR 2857].

[PR 2857]: https://github.com/libp2p/rust-libp2p/pull/2857

# 0.41.0

- Update to `libp2p-swarm` `v0.39.0`.
Expand Down
6 changes: 3 additions & 3 deletions protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-gossipsub"
edition = "2021"
rust-version = "1.56.1"
description = "Gossipsub protocol for libp2p"
version = "0.41.0"
version = "0.41.1"
authors = ["Age Manning <Age@AgeManning.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -17,7 +17,7 @@ bytes = "1.0"
byteorder = "1.3.4"
fnv = "1.0.7"
futures = "0.3.5"
rand = "0.7.3"
rand = "0.8"
asynchronous-codec = "0.6"
unsigned-varint = { version = "0.7.0", features = ["asynchronous_codec"] }
log = "0.4.11"
Expand All @@ -37,7 +37,7 @@ prometheus-client = "0.18.0"
async-std = "1.6.3"
env_logger = "0.9.0"
libp2p = { path = "../../", default-features = false, features = ["plaintext", "yamux", "noise", "mplex", "gossipsub"] }
quickcheck = "0.9.2"
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
hex = "0.4.2"
derive_builder = "0.11.1"

Expand Down
9 changes: 4 additions & 5 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3664,7 +3664,6 @@ mod local_test {
use crate::IdentTopic;
use asynchronous_codec::Encoder;
use quickcheck::*;
use rand::Rng;

fn empty_rpc() -> GossipsubRpc {
GossipsubRpc {
Expand Down Expand Up @@ -3701,16 +3700,16 @@ mod local_test {
}

impl Arbitrary for GossipsubRpc {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary(g: &mut Gen) -> Self {
let mut rpc = empty_rpc();

for _ in 0..g.gen_range(0, 10) {
for _ in 0..g.gen_range(0..10u8) {
rpc.subscriptions.push(test_subscription());
}
for _ in 0..g.gen_range(0, 10) {
for _ in 0..g.gen_range(0..10u8) {
rpc.messages.push(test_message());
}
for _ in 0..g.gen_range(0, 10) {
for _ in 0..g.gen_range(0..10u8) {
rpc.control_msgs.push(test_control());
}
rpc
Expand Down
4 changes: 2 additions & 2 deletions protocols/gossipsub/src/behaviour/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3293,12 +3293,12 @@ mod tests {
*seq += 1;
RawGossipsubMessage {
source: Some(PeerId::random()),
data: (0..rng.gen_range(10, 30))
data: (0..rng.gen_range(10..30))
.into_iter()
.map(|_| rng.gen())
.collect(),
sequence_number: Some(*seq),
topic: topics[rng.gen_range(0, topics.len())].clone(),
topic: topics[rng.gen_range(0..topics.len())].clone(),
signature: None,
key: None,
validated: true,
Expand Down

0 comments on commit e530118

Please sign in to comment.