From e5420796df639080740d537692b74d64bcf194ed Mon Sep 17 00:00:00 2001 From: evdokimovs <49490279+evdokimovs@users.noreply.github.com> Date: Fri, 29 May 2020 11:26:46 +0300 Subject: [PATCH] Fix failing Jason unit test (#102, #27) - add Cancelled state to the KnownIceCandidatePairState from the 'medea-client-api-proto' crate - fix random fails of the web::peer::get_traffic_stats unit test --- jason/tests/peer/mod.rs | 14 ++++++++------ proto/client-api/CHANGELOG.md | 2 ++ proto/client-api/src/stats.rs | 6 ++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/jason/tests/peer/mod.rs b/jason/tests/peer/mod.rs index 99222319b..7be78e60f 100644 --- a/jason/tests/peer/mod.rs +++ b/jason/tests/peer/mod.rs @@ -560,6 +560,7 @@ async fn get_traffic_stats() { let second_peer_stats = peers.second_peer.get_stats().await.unwrap(); let mut second_peer_video_inbound_stats_count = 0; let mut second_peer_audio_inbound_stats_count = 0; + let mut has_succeeded_pair = false; for stat in second_peer_stats.0 { match stat.stats { RtcStatsType::InboundRtp(inbound) => { @@ -576,16 +577,17 @@ async fn get_traffic_stats() { "Second Peer shouldn't have any OutboundRtp stats." ), RtcStatsType::CandidatePair(candidate_pair) => { - // TODO: Fix test race where this assertion might fail cause - // left is `Unknown("cancelled")`. - assert_eq!( - candidate_pair.state, - NonExhaustive::Known(KnownIceCandidatePairState::Succeeded) - ); + if let NonExhaustive::Known( + KnownIceCandidatePairState::Succeeded, + ) = candidate_pair.state + { + has_succeeded_pair = true; + } } _ => (), } } + assert!(has_succeeded_pair); assert_eq!(second_peer_video_inbound_stats_count, 1); assert_eq!(second_peer_audio_inbound_stats_count, 1); } diff --git a/proto/client-api/CHANGELOG.md b/proto/client-api/CHANGELOG.md index b8ab4d6bb..1ddb8b2ce 100644 --- a/proto/client-api/CHANGELOG.md +++ b/proto/client-api/CHANGELOG.md @@ -48,6 +48,7 @@ All user visible changes to this project will be documented in this file. This p - `RtcIceCandidateStats`; - `RtcCertificateStats`; - `RtcIceServerStats`. +- `Cancelled` state to the `KnownIceCandidatePairState` ([#102]). [#28]: /../../pull/28 [#58]: /../../pull/58 @@ -57,6 +58,7 @@ All user visible changes to this project will be documented in this file. This p [#81]: /../../pull/81 [#87]: /../../pull/87 [#90]: /../../pull/90 +[#102]: /../../pull/102 diff --git a/proto/client-api/src/stats.rs b/proto/client-api/src/stats.rs index e3a638379..8e96aad2e 100644 --- a/proto/client-api/src/stats.rs +++ b/proto/client-api/src/stats.rs @@ -889,6 +889,12 @@ pub enum KnownIceCandidatePairState { /// unfreeze and move into the [`KnownIceCandidatePairState::Waiting`] /// state. Frozen, + + /// Other Candidate pair was nominated. + /// + /// This state is **obsolete and not spec compliant**, however, it still + /// may be emitted by some implementations. + Cancelled, } /// Non-exhaustive version of [`KnownIceCandidatePairState`].