Skip to content

Commit

Permalink
Bump quickcheck dependency to 0.8.0 (#21)
Browse files Browse the repository at this point in the history
This is in service of an attempt to have the proxy depend only on a single version
of `rand`; `quickcheck` 0.6 depends on a much older `rand` than most of
our other dependencies.

Signed-off-by: Eliza Weisman <[email protected]>
  • Loading branch information
hawkw authored Jan 14, 2019
1 parent 1ad7018 commit 73ac4b4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
6 changes: 3 additions & 3 deletions rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false

[features]
default = []
arbitrary = ["quickcheck"]
arbitrary = ["quickcheck", "rand"]

[dependencies]
bytes = "0.4"
Expand All @@ -19,8 +19,8 @@ prost-types = "0.4.0"

tower-grpc = { git = "https://github.com/tower-rs/tower-grpc", default-features = false, features = ["protobuf"] }

quickcheck = { version = "0.6", default-features = false, optional = true }

quickcheck = { version = "0.8", default-features = false, optional = true }
rand = { version = "0.6", optional = true }

[build-dependencies]
tower-grpc-build = { git = "https://github.com/tower-rs/tower-grpc", default-features = false }
Expand Down
41 changes: 21 additions & 20 deletions rs/src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
use std::boxed::Box;

use quickcheck::*;
use rand::Rng;

use super::http_types::*;
use super::net::*;
use super::tap::*;

impl Arbitrary for ObserveRequest {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
ObserveRequest {
limit: g.gen(),
match_: Arbitrary::arbitrary(g),
Expand All @@ -18,15 +19,15 @@ impl Arbitrary for ObserveRequest {
}

impl Arbitrary for observe_request::Match {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
observe_request::Match {
match_: Arbitrary::arbitrary(g),
}
}
}

impl Arbitrary for observe_request::match_::Match {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
match g.gen::<u32>() % 6 {
0 => observe_request::match_::Match::All(Arbitrary::arbitrary(g)),
1 => observe_request::match_::Match::Any(Arbitrary::arbitrary(g)),
Expand All @@ -40,7 +41,7 @@ impl Arbitrary for observe_request::match_::Match {
}

impl Arbitrary for observe_request::match_::Seq {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
observe_request::match_::Seq {
matches: Arbitrary::arbitrary(g),
}
Expand All @@ -56,7 +57,7 @@ impl Arbitrary for observe_request::match_::Seq {
}

impl Arbitrary for observe_request::match_::Label {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
observe_request::match_::Label {
key: Arbitrary::arbitrary(g),
value: Arbitrary::arbitrary(g),
Expand All @@ -65,15 +66,15 @@ impl Arbitrary for observe_request::match_::Label {
}

impl Arbitrary for observe_request::match_::Tcp {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
observe_request::match_::Tcp {
match_: Arbitrary::arbitrary(g),
}
}
}

impl Arbitrary for observe_request::match_::tcp::Match {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
use self::observe_request::match_::tcp;

if g.gen::<bool>() {
Expand All @@ -85,7 +86,7 @@ impl Arbitrary for observe_request::match_::tcp::Match {
}

impl Arbitrary for observe_request::match_::tcp::PortRange {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
observe_request::match_::tcp::PortRange {
min: g.gen(),
max: g.gen(),
Expand All @@ -94,7 +95,7 @@ impl Arbitrary for observe_request::match_::tcp::PortRange {
}

impl Arbitrary for observe_request::match_::tcp::Netmask {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
let ip: Option<IpAddress> = Arbitrary::arbitrary(g);
let mask = match ip.as_ref().and_then(|a| a.ip.as_ref()) {
Some(&ip_address::Ip::Ipv4(_)) => g.gen::<u32>() % 32 + 1,
Expand All @@ -109,15 +110,15 @@ impl Arbitrary for observe_request::match_::tcp::Netmask {
}

impl Arbitrary for observe_request::match_::Http {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
observe_request::match_::Http {
match_: Arbitrary::arbitrary(g),
}
}
}

impl Arbitrary for observe_request::match_::http::Match {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
use self::observe_request::match_::http;

match g.gen::<u32>() % 4 {
Expand All @@ -131,15 +132,15 @@ impl Arbitrary for observe_request::match_::http::Match {
}

impl Arbitrary for observe_request::match_::http::StringMatch {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
observe_request::match_::http::StringMatch {
match_: Arbitrary::arbitrary(g),
}
}
}

impl Arbitrary for observe_request::match_::http::string_match::Match {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
use self::observe_request::match_::http::string_match;

match g.gen::<u32>() % 2 {
Expand All @@ -151,15 +152,15 @@ impl Arbitrary for observe_request::match_::http::string_match::Match {
}

impl Arbitrary for IpAddress {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
IpAddress {
ip: Arbitrary::arbitrary(g),
}
}
}

impl Arbitrary for ip_address::Ip {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
if g.gen::<bool>() {
ip_address::Ip::Ipv4(g.gen())
} else {
Expand All @@ -169,7 +170,7 @@ impl Arbitrary for ip_address::Ip {
}

impl Arbitrary for IPv6 {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
IPv6 {
first: g.gen(),
last: g.gen(),
Expand All @@ -178,15 +179,15 @@ impl Arbitrary for IPv6 {
}

impl Arbitrary for HttpMethod {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
HttpMethod {
type_: Arbitrary::arbitrary(g),
}
}
}

impl Arbitrary for http_method::Type {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
match g.gen::<u16>() % 9 {
8 => http_method::Type::Unregistered(String::arbitrary(g)),
n => http_method::Type::Registered(i32::from(n).into()),
Expand All @@ -195,15 +196,15 @@ impl Arbitrary for http_method::Type {
}

impl Arbitrary for Scheme {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
Scheme {
type_: Arbitrary::arbitrary(g),
}
}
}

impl Arbitrary for scheme::Type {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
fn arbitrary<G: Gen + Rng>(g: &mut G) -> Self {
match g.gen::<u16>() % 3 {
3 => scheme::Type::Unregistered(String::arbitrary(g)),
n => scheme::Type::Registered(i32::from(n).into()),
Expand Down
2 changes: 2 additions & 0 deletions rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extern crate prost_derive;
extern crate prost_types;
#[cfg(feature = "arbitrary")]
extern crate quickcheck;
#[cfg(feature = "arbitrary")]
extern crate rand;
extern crate tower_grpc;

use std::fmt;
Expand Down

0 comments on commit 73ac4b4

Please sign in to comment.