From cf0623e3029981284ea05dbb167ac5671753668e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 13 Aug 2020 01:05:20 +0200 Subject: [PATCH] aquatic_ws_protocol: fix warning about JsonValue Arbitrary impl Now it is clearer that only a single value is ever generated --- aquatic_ws_protocol/src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/aquatic_ws_protocol/src/lib.rs b/aquatic_ws_protocol/src/lib.rs index 09b4d40..c7da48d 100644 --- a/aquatic_ws_protocol/src/lib.rs +++ b/aquatic_ws_protocol/src/lib.rs @@ -330,6 +330,10 @@ mod tests { bytes } + fn sdp_json_value() -> JsonValue { + JsonValue(::serde_json::json!({ "sdp": "test" })) + } + impl Arbitrary for InfoHash { fn arbitrary(g: &mut G) -> Self { Self(arbitrary_20_bytes(g)) @@ -348,12 +352,6 @@ mod tests { } } - impl Arbitrary for JsonValue { - fn arbitrary(g: &mut G) -> Self { - Self(::serde_json::json!({ "sdp": "test" })) - } - } - impl Arbitrary for AnnounceEvent { fn arbitrary(g: &mut G) -> Self { match (bool::arbitrary(g), bool::arbitrary(g)){ @@ -372,7 +370,7 @@ mod tests { peer_id: Arbitrary::arbitrary(g), info_hash: Arbitrary::arbitrary(g), offer_id: Arbitrary::arbitrary(g), - offer: Arbitrary::arbitrary(g) + offer: sdp_json_value() } } } @@ -384,7 +382,7 @@ mod tests { peer_id: Arbitrary::arbitrary(g), info_hash: Arbitrary::arbitrary(g), offer_id: Arbitrary::arbitrary(g), - answer: Arbitrary::arbitrary(g) + answer: sdp_json_value() } } } @@ -393,7 +391,7 @@ mod tests { fn arbitrary(g: &mut G) -> Self { Self { offer_id: Arbitrary::arbitrary(g), - offer: Arbitrary::arbitrary(g) + offer: sdp_json_value() } } } @@ -412,7 +410,7 @@ mod tests { offers = Some(Arbitrary::arbitrary(g)); }, Some(false) => { - answer = Some(Arbitrary::arbitrary(g)); + answer = Some(sdp_json_value()); to_peer_id = Some(Arbitrary::arbitrary(g)); offer_id = Some(Arbitrary::arbitrary(g)); },