From 137bb362f21b353ca92cce7528e708b679c5242b Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 7 Aug 2026 11:56:03 +0800 Subject: [PATCH] fmt the envelope-marker test Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01ExUfAkYbq8UC9pQCiLy8TQ --- src/webrtc.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/webrtc.rs b/src/webrtc.rs index 0077914d8..9ecd98da0 100644 --- a/src/webrtc.rs +++ b/src/webrtc.rs @@ -1078,23 +1078,31 @@ mod tests { fn test_endpoint_ice_policy_declaration() { // An envelope with the marker declares full ICE; everything else — no marker, // wrong value, foreign scheme, garbage — reads as the old Relay-only semantics. - let marked = WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0","ice_policy":"all"}"#); + let marked = + WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0","ice_policy":"all"}"#); assert!(WebRTCStream::endpoint_declares_all_ice(&marked)); let unmarked = WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0"}"#); assert!(!WebRTCStream::endpoint_declares_all_ice(&unmarked)); - let wrong = WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0","ice_policy":"relay"}"#); + let wrong = + WebRTCStream::sdp_to_endpoint(r#"{"type":"offer","sdp":"v=0","ice_policy":"relay"}"#); assert!(!WebRTCStream::endpoint_declares_all_ice(&wrong)); assert!(!WebRTCStream::endpoint_declares_all_ice("")); - assert!(!WebRTCStream::endpoint_declares_all_ice("webrtc://not-base64!")); - assert!(!WebRTCStream::endpoint_declares_all_ice("https://example.com")); + assert!(!WebRTCStream::endpoint_declares_all_ice( + "webrtc://not-base64!" + )); + assert!(!WebRTCStream::endpoint_declares_all_ice( + "https://example.com" + )); // The marker must be invisible to the plain RTCSessionDescription parse old peers do. let sdp_json = WebRTCStream::get_remote_offer(&marked).unwrap(); - serde_json::from_str::(&sdp_json) - .expect("extra envelope key must not break RTCSessionDescription parsing"); + serde_json::from_str::< + webrtc::peer_connection::sdp::session_description::RTCSessionDescription, + >(&sdp_json) + .expect("extra envelope key must not break RTCSessionDescription parsing"); } #[test]