From a7332fa5c3039dbcd92402de25e7ec0702dc1359 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 21 Oct 2026 09:43:00 -0700 Subject: [PATCH 1/6] test: drop low-value moq-net, moq-tokio, moq-relay, moq-auth tests Duplicates, derive/clap/serde restatements, constant restatements and tautologies. Per-field merge pins fold into table tests. Co-Authored-By: Claude Opus 5.5 --- rs/moq-auth/src/algorithm.rs | 77 +--- rs/moq-auth/src/claims.rs | 10 - rs/moq-auth/src/key.rs | 84 ---- rs/moq-auth/src/set.rs | 37 -- rs/moq-net/src/model/group.rs | 14 - rs/moq-net/src/model/time.rs | 17 - rs/moq-net/src/path/mod.rs | 11 - rs/moq-relay/src/cluster.rs | 23 - rs/moq-relay/src/config.rs | 605 +++++++------------------ rs/moq-tokio/src/client.rs | 198 +------- rs/moq-tokio/tests/integration/alpn.rs | 270 ----------- rs/moq-tokio/tests/integration/main.rs | 1 - 12 files changed, 213 insertions(+), 1134 deletions(-) delete mode 100644 rs/moq-tokio/tests/integration/alpn.rs diff --git a/rs/moq-auth/src/algorithm.rs b/rs/moq-auth/src/algorithm.rs index 8a0a4d7c1a2..a411e423fcf 100644 --- a/rs/moq-auth/src/algorithm.rs +++ b/rs/moq-auth/src/algorithm.rs @@ -99,19 +99,24 @@ mod tests { use super::*; #[test] - fn test_algorithm_from_str_valid() { - assert_eq!(Algorithm::from_str("HS256").unwrap(), Algorithm::HS256); - assert_eq!(Algorithm::from_str("HS384").unwrap(), Algorithm::HS384); - assert_eq!(Algorithm::from_str("HS512").unwrap(), Algorithm::HS512); - assert_eq!(Algorithm::from_str("ES256").unwrap(), Algorithm::ES256); - assert_eq!(Algorithm::from_str("ES384").unwrap(), Algorithm::ES384); - assert_eq!(Algorithm::from_str("RS256").unwrap(), Algorithm::RS256); - assert_eq!(Algorithm::from_str("RS384").unwrap(), Algorithm::RS384); - assert_eq!(Algorithm::from_str("RS512").unwrap(), Algorithm::RS512); - assert_eq!(Algorithm::from_str("PS256").unwrap(), Algorithm::PS256); - assert_eq!(Algorithm::from_str("PS384").unwrap(), Algorithm::PS384); - assert_eq!(Algorithm::from_str("PS512").unwrap(), Algorithm::PS512); - assert_eq!(Algorithm::from_str("EdDSA").unwrap(), Algorithm::EdDSA); + fn test_algorithm_from_str_and_display() { + for (name, alg) in [ + ("HS256", Algorithm::HS256), + ("HS384", Algorithm::HS384), + ("HS512", Algorithm::HS512), + ("ES256", Algorithm::ES256), + ("ES384", Algorithm::ES384), + ("RS256", Algorithm::RS256), + ("RS384", Algorithm::RS384), + ("RS512", Algorithm::RS512), + ("PS256", Algorithm::PS256), + ("PS384", Algorithm::PS384), + ("PS512", Algorithm::PS512), + ("EdDSA", Algorithm::EdDSA), + ] { + assert_eq!(Algorithm::from_str(name).unwrap(), alg); + assert_eq!(alg.to_string(), name); + } } #[test] @@ -124,22 +129,6 @@ mod tests { assert!(Algorithm::from_str("").is_err()); } - #[test] - fn test_algorithm_display() { - assert_eq!(Algorithm::HS256.to_string(), "HS256"); - assert_eq!(Algorithm::HS384.to_string(), "HS384"); - assert_eq!(Algorithm::HS512.to_string(), "HS512"); - assert_eq!(Algorithm::ES256.to_string(), "ES256"); - assert_eq!(Algorithm::ES384.to_string(), "ES384"); - assert_eq!(Algorithm::RS256.to_string(), "RS256"); - assert_eq!(Algorithm::RS384.to_string(), "RS384"); - assert_eq!(Algorithm::RS512.to_string(), "RS512"); - assert_eq!(Algorithm::PS256.to_string(), "PS256"); - assert_eq!(Algorithm::PS384.to_string(), "PS384"); - assert_eq!(Algorithm::PS512.to_string(), "PS512"); - assert_eq!(Algorithm::EdDSA.to_string(), "EdDSA"); - } - #[test] fn test_algorithm_to_jsonwebtoken_algorithm() { assert_eq!( @@ -201,34 +190,4 @@ mod tests { let deserialized: Algorithm = serde_json::from_str(&json).unwrap(); assert_eq!(deserialized, alg); } - - #[test] - fn test_algorithm_equality() { - assert_eq!(Algorithm::HS256, Algorithm::HS256); - assert_ne!(Algorithm::HS256, Algorithm::HS384); - assert_ne!(Algorithm::HS384, Algorithm::HS512); - assert_eq!(Algorithm::ES256, Algorithm::ES256); - assert_eq!(Algorithm::ES384, Algorithm::ES384); - assert_ne!(Algorithm::HS384, Algorithm::ES256); - assert_ne!(Algorithm::ES256, Algorithm::ES384); - assert_eq!(Algorithm::RS256, Algorithm::RS256); - assert_eq!(Algorithm::RS384, Algorithm::RS384); - assert_eq!(Algorithm::RS512, Algorithm::RS512); - assert_ne!(Algorithm::RS256, Algorithm::RS512); - assert_ne!(Algorithm::RS256, Algorithm::PS256); - assert_eq!(Algorithm::PS256, Algorithm::PS256); - assert_eq!(Algorithm::PS384, Algorithm::PS384); - assert_eq!(Algorithm::PS512, Algorithm::PS512); - assert_ne!(Algorithm::PS256, Algorithm::PS512); - assert_eq!(Algorithm::EdDSA, Algorithm::EdDSA); - assert_ne!(Algorithm::EdDSA, Algorithm::ES256); - assert_ne!(Algorithm::EdDSA, Algorithm::RS512); - } - - #[test] - fn test_algorithm_clone() { - let alg = Algorithm::HS256; - let cloned = alg; - assert_eq!(alg, cloned); - } } diff --git a/rs/moq-auth/src/claims.rs b/rs/moq-auth/src/claims.rs index 2fff13a4b1d..616fa996129 100644 --- a/rs/moq-auth/src/claims.rs +++ b/rs/moq-auth/src/claims.rs @@ -573,16 +573,6 @@ mod tests { assert!(err.to_string().contains("**"), "{err}"); } - #[test] - fn test_claims_default() { - let claims = Claims::default(); - assert_eq!(claims.root, ""); - assert!(claims.publish.is_empty()); - assert!(claims.subscribe.is_empty()); - assert_eq!(claims.expires, None); - assert_eq!(claims.issued, None); - } - fn authorize_claims(root: &str, subscribe: &[&str], publish: &[&str]) -> Claims { Claims { root: root.to_string(), diff --git a/rs/moq-auth/src/key.rs b/rs/moq-auth/src/key.rs index a5a61c8d074..207064add40 100644 --- a/rs/moq-auth/src/key.rs +++ b/rs/moq-auth/src/key.rs @@ -1252,36 +1252,6 @@ mod tests { } } - #[test] - fn test_key_generate_es256() { - let key = Key::generate(Algorithm::ES256, Some(crate::KeyId::decode("test-id").unwrap())); - assert!(key.is_ok()); - let key = key.unwrap(); - - assert_eq!(key.algorithm, Algorithm::ES256); - assert!(matches!(key.material, KeyMaterial::EC { .. })) - } - - #[test] - fn test_key_generate_ps512() { - let key = Key::generate(Algorithm::PS512, Some(crate::KeyId::decode("test-id").unwrap())); - assert!(key.is_ok()); - let key = key.unwrap(); - - assert_eq!(key.algorithm, Algorithm::PS512); - assert!(matches!(key.material, KeyMaterial::RSA { .. })); - } - - #[test] - fn test_key_generate_eddsa() { - let key = Key::generate(Algorithm::EdDSA, Some(crate::KeyId::decode("test-id").unwrap())); - assert!(key.is_ok()); - let key = key.unwrap(); - - assert_eq!(key.algorithm, Algorithm::EdDSA); - assert!(matches!(key.material, KeyMaterial::OKP { .. })); - } - #[test] fn test_key_generate_without_id() { let key = Key::generate(Algorithm::HS256, None); @@ -1394,22 +1364,6 @@ mod tests { } } - #[test] - fn test_key_generate_sign_verify_cycle() { - let key = Key::generate(Algorithm::HS256, Some(crate::KeyId::decode("test-id").unwrap())); - assert!(key.is_ok()); - let key = key.unwrap(); - - let claims = create_test_claims(); - - let token = key.sign(&claims).unwrap(); - let verified_claims = key.verify(&token).unwrap(); - - assert_eq!(verified_claims.root, claims.root); - assert_eq!(verified_claims.publish, claims.publish); - assert_eq!(verified_claims.subscribe, claims.subscribe); - } - #[test] fn test_key_debug_no_secret() { let key = create_test_key(); @@ -1421,22 +1375,6 @@ mod tests { assert!(!debug_str.contains("secret")); // Should not contain secret } - #[test] - fn test_key_operations_enum() { - let sign_op = KeyOperation::Sign; - let verify_op = KeyOperation::Verify; - let decrypt_op = KeyOperation::Decrypt; - let encrypt_op = KeyOperation::Encrypt; - - assert_eq!(sign_op, KeyOperation::Sign); - assert_eq!(verify_op, KeyOperation::Verify); - assert_eq!(decrypt_op, KeyOperation::Decrypt); - assert_eq!(encrypt_op, KeyOperation::Encrypt); - - assert_ne!(sign_op, verify_op); - assert_ne!(decrypt_op, encrypt_op); - } - #[test] fn test_key_operations_serde() { let operations = [KeyOperation::Sign, KeyOperation::Verify]; @@ -1473,28 +1411,6 @@ mod tests { } } - #[test] - fn test_key_clone() { - let key = create_test_key(); - let cloned = key.clone(); - - assert_eq!(cloned.algorithm, key.algorithm); - assert_eq!(cloned.operations, key.operations); - assert_eq!(cloned.kid, key.kid); - - if let ( - KeyMaterial::OCT { - secret: original_secret, - }, - KeyMaterial::OCT { secret: cloned_secret }, - ) = (&key.material, &cloned.material) - { - assert_eq!(cloned_secret, original_secret); - } else { - panic!("Expected both keys to be OCT variant"); - } - } - #[test] fn test_hmac_algorithms() { let key_256 = Key::generate(Algorithm::HS256, Some(crate::KeyId::decode("test-id").unwrap())); diff --git a/rs/moq-auth/src/set.rs b/rs/moq-auth/src/set.rs index 39b3ed85bcb..199b3de5c95 100644 --- a/rs/moq-auth/src/set.rs +++ b/rs/moq-auth/src/set.rs @@ -170,19 +170,6 @@ mod tests { assert!(set.find_key("1").is_some()); } - #[test] - fn test_keyset_from_str_invalid_json() { - let result = KeySet::from_str("invalid json"); - assert!(result.is_err()); - } - - #[test] - fn test_keyset_from_str_empty() { - let json = r#"{"keys":[]}"#; - let set = KeySet::from_str(json).unwrap(); - assert!(set.keys.is_empty()); - } - #[test] fn test_keyset_to_str() { let key = create_test_key(Some("1")); @@ -211,18 +198,6 @@ mod tests { assert!(deserialized.find_key("2").is_some()); } - #[test] - fn test_find_key_success() { - let key = create_test_key(Some("my-key")); - let set = KeySet { - keys: vec![Arc::new(key)], - }; - - let found = set.find_key("my-key"); - assert!(found.is_some()); - assert_eq!(found.unwrap().kid.as_ref().map(|k| k.encode()), Some("my-key")); - } - #[test] fn test_find_key_missing() { let key = create_test_key(Some("my-key")); @@ -309,18 +284,6 @@ mod tests { assert!(result.is_err()); } - #[test] - fn test_encode_success() { - let key = create_test_key(Some("1")); - let set = KeySet { - keys: vec![Arc::new(key)], - }; - let claims = create_test_claims(); - - let token = set.sign(&claims).unwrap(); - assert!(!token.is_empty()); - } - #[test] fn test_encode_no_signing_key() { let key = create_test_key(Some("1")).with_operations([KeyOperation::Verify]); diff --git a/rs/moq-net/src/model/group.rs b/rs/moq-net/src/model/group.rs index 252fb384e85..253d29e5f8a 100644 --- a/rs/moq-net/src/model/group.rs +++ b/rs/moq-net/src/model/group.rs @@ -3444,20 +3444,6 @@ mod test { assert!(end.is_none()); } - #[test] - #[cfg(feature = "async")] - fn read_frame_all_at_once() { - let mut producer = Info { sequence: 0 }.produce(); - producer - .write_frame(Timestamp::ZERO, Bytes::from_static(b"hello")) - .unwrap(); - producer.finish().unwrap(); - - let mut consumer = producer.consume(); - let frame = consumer.read_frame().now_or_never().unwrap().unwrap().unwrap(); - assert_eq!(frame.payload, Bytes::from_static(b"hello")); - } - #[test] #[cfg(feature = "async")] fn read_frame_preserves_timestamp() { diff --git a/rs/moq-net/src/model/time.rs b/rs/moq-net/src/model/time.rs index 8d433a1571b..765108bd570 100644 --- a/rs/moq-net/src/model/time.rs +++ b/rs/moq-net/src/model/time.rs @@ -538,29 +538,12 @@ mod tests { assert!(a.checked_sub(b).is_err()); } - #[test] - fn test_max_same_scale() { - let a = Timestamp::from_secs(5).unwrap(); - let b = Timestamp::from_secs(10).unwrap(); - assert_eq!(a.max(b), b); - assert_eq!(b.max(a), b); - } - - #[test] - fn test_max_cross_scale() { - // `Ord::max` compares across scales (no panic). - let a = Timestamp::from_millis(1).unwrap(); - let b = Timestamp::from_secs(1).unwrap(); - assert_eq!(a.max(b), b); - } - #[test] fn test_ordering_same_scale() { let a = Timestamp::from_secs(1).unwrap(); let b = Timestamp::from_secs(2).unwrap(); assert!(a < b); assert!(b > a); - assert_eq!(a, a); } #[test] diff --git a/rs/moq-net/src/path/mod.rs b/rs/moq-net/src/path/mod.rs index f59f87eff16..0b0f565379c 100644 --- a/rs/moq-net/src/path/mod.rs +++ b/rs/moq-net/src/path/mod.rs @@ -814,17 +814,6 @@ mod tests { assert_eq!(Path::new("foo/bar").join(Path::new("baz")).as_str(), "foo/bar/baz"); } - #[test] - fn test_empty() { - let empty = Path::new(""); - assert!(empty.is_empty()); - assert_eq!(empty.len(), 0); - - let non_empty = Path::new("foo"); - assert!(!non_empty.is_empty()); - assert_eq!(non_empty.len(), 3); - } - #[test] fn test_from_conversions() { let path1 = Path::from("foo/bar"); diff --git a/rs/moq-relay/src/cluster.rs b/rs/moq-relay/src/cluster.rs index 7c0e3fa0575..89e53f7c065 100644 --- a/rs/moq-relay/src/cluster.rs +++ b/rs/moq-relay/src/cluster.rs @@ -3126,29 +3126,6 @@ mod tests { } } - /// `cluster.node` (identity) round-trips through TOML and survives the CLI - /// re-parse when no flags override it. - #[test] - fn cluster_node_round_trip() { - // Usage reads the environment while parsing, so serialize with the tests - // that mutate it. - let _env = crate::test_env::EnvGuard::lock(); - - let toml = "[cluster]\nnode = \"us-east.example.com:4443\"\nconnect = [\"https://root.example.com:4443/\"]\n"; - let dir = std::env::temp_dir().join("moq-relay-cluster-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("cluster-node-toml.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = RelayConfig::parse_and_merge(args).expect("config load"); - assert_eq!(config.cluster.node.as_deref(), Some("us-east.example.com:4443")); - assert_eq!( - config.cluster.connect, - vec![Peer::new("https://root.example.com:4443/")] - ); - } - /// Static config accepts the object form beside bare URLs, through the same /// type the connect API parses. #[test] diff --git a/rs/moq-relay/src/config.rs b/rs/moq-relay/src/config.rs index 95fe1e4cf53..5e6a1370668 100644 --- a/rs/moq-relay/src/config.rs +++ b/rs/moq-relay/src/config.rs @@ -841,40 +841,9 @@ ws = false assert_eq!(config.connect.websocket.enabled, Some(true)); } - #[test] - fn cli_does_not_clobber_toml_cache() { - let _env = EnvGuard::clear(&["MOQ_CACHE_CAPACITY", "MOQ_CACHE_HEADROOM", "MOQ_CACHE_DURATION"]); - - let toml = r#" -[cache] -capacity = "8GiB" -headroom = "10%" -duration = "30s" -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("cache-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.cache.capacity.as_deref(), - Some("8GiB"), - "TOML's cache.capacity must not be clobbered by the CLI re-parse" - ); - assert_eq!(config.cache.headroom.as_deref(), Some("10%")); - assert_eq!( - config.cache.duration, - Some(std::time::Duration::from_secs(30)), - "TOML's cache.duration must not be clobbered by the CLI re-parse" - ); - } - /// `cache.duration` is an `Option` behind plain `humantime_serde` /// (not `humantime_serde::option`), so pin both directions including the - /// `None` serialize path, which the merge test above never exercises. + /// `None` serialize path, which `provenance_merge_table` never exercises. #[test] fn cache_duration_serde_round_trip() { let set: cache::Config = toml::from_str(r#"duration = "30s""#).expect("deserialize Some"); @@ -890,375 +859,6 @@ duration = "30s" toml::to_string(&unset).expect("serialize None"); } - /// Preferred addresses loaded from TOML survive when the CLI omits them. - #[test] - fn cli_does_not_clobber_toml_preferred_addresses() { - let _env = EnvGuard::clear(&["MOQ_LISTEN_PREFERRED_V4", "MOQ_LISTEN_PREFERRED_V6"]); - - // They are accept-only, so they live on `[listen]` rather than in the - // shared `[listen.quic]` tuning. - let toml = r#" -[listen] -preferred_v4 = "192.0.2.1:443" -preferred_v6 = "[2001:db8::1]:443" -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("preferred-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.listen.preferred_v4, - Some("192.0.2.1:443".parse().unwrap()), - "TOML's listen.preferred_v4 must not be clobbered by the CLI re-parse" - ); - assert_eq!( - config.listen.preferred_v6, - Some("[2001:db8::1]:443".parse().unwrap()), - "TOML's listen.preferred_v6 must not be clobbered by the CLI re-parse" - ); - } - - /// Same clobbering hazard as the preferred addresses above, for the qlog - /// directory: a TOML-configured trace dir must survive the CLI re-parse. - #[test] - fn cli_does_not_clobber_toml_qlog() { - let _env = EnvGuard::clear(&["MOQ_SERVER_QUIC_QLOG"]); - - let toml = r#" -[quic] -qlog = "/tmp/moq-qlog" -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("qlog-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.quic.qlog.as_deref(), - Some(std::path::Path::new("/tmp/moq-qlog")), - "TOML's quic.qlog must not be clobbered by the CLI re-parse" - ); - } - - /// A backend-specific congestion-control choice loaded from TOML survives. - #[test] - fn cli_does_not_clobber_toml_congestion_control() { - let _env = EnvGuard::clear(&[ - "MOQ_SERVER_QUIC_CONGESTION_CONTROL", - "MOQ_CLIENT_QUIC_CONGESTION_CONTROL", - ]); - - let toml = r#" -[quic] -congestion_control = "delay" -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("congestion-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - // One value, shared by the dial and accept sides: the knob means the same - // thing whichever way the connection was opened. - assert_eq!( - config.quic.congestion_control, - Some(moq_tokio::quic::CongestionControl::Delay), - "TOML's quic.congestion_control must not be clobbered by the CLI re-parse" - ); - } - - /// Flow-control windows loaded from TOML survive the CLI re-parse. - #[test] - fn cli_does_not_clobber_toml_windows() { - let _env = EnvGuard::clear(&[ - "MOQ_QUIC_RECEIVE_WINDOW", - "MOQ_QUIC_STREAM_RECEIVE_WINDOW", - "MOQ_QUIC_SEND_WINDOW", - ]); - - let toml = r#" -[quic] -receive_window = 67108864 -stream_receive_window = 8388608 -send_window = 33554432 -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("windows-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!(config.quic.receive_window, Some(67108864)); - assert_eq!(config.quic.stream_receive_window, Some(8388608)); - assert_eq!( - config.quic.send_window, - Some(33554432), - "TOML's quic window sizes must not be clobbered by the CLI re-parse" - ); - } - - /// The client connect timeout loaded from TOML replaces the built-in default. - #[test] - fn cli_does_not_clobber_toml_client_connect_timeout() { - let _env = EnvGuard::clear(&["MOQ_CLIENT_CONNECT_TIMEOUT"]); - - let toml = r#" -[connect] -timeout = "2m" -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("client-connect-timeout-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!(config.connect.timeout, Some(std::time::Duration::from_secs(120))); - } - - #[test] - fn cli_does_not_clobber_toml_web_https_cert_arrays() { - let _env = EnvGuard::clear(&["MOQ_WEB_HTTPS_CERT", "MOQ_WEB_HTTPS_KEY"]); - - let toml = r#" -[web.https] -listen = "127.0.0.1:4443" -cert = ["cdn.pem", "moq-pro.pem"] -key = ["cdn.key", "moq-pro.key"] -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("web-https-certs-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.web.https.cert, - vec![ - std::path::PathBuf::from("cdn.pem"), - std::path::PathBuf::from("moq-pro.pem") - ] - ); - assert_eq!( - config.web.https.key, - vec![ - std::path::PathBuf::from("cdn.key"), - std::path::PathBuf::from("moq-pro.key") - ] - ); - } - - /// Explicit CLI flags still override TOML defaults. - #[test] - fn cli_flag_overrides_toml_stats_enabled() { - let _env = EnvGuard::clear(&["MOQ_STATS_ENABLED"]); - - let toml = "[stats]\nenabled = true\n"; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("cli-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![ - std::ffi::OsString::from("moq-relay"), - std::ffi::OsString::from(&path), - std::ffi::OsString::from("--stats-enabled=false"), - ]; - let config = Config::parse_and_merge(args).expect("config load"); - assert!(!config.stats.enabled); - } - - /// An auth server loaded from TOML survives when the CLI omits it. - #[test] - fn cli_does_not_clobber_toml_auth_url() { - let _env = EnvGuard::clear(&["MOQ_AUTH_URL"]); - - let toml = r#" -[auth] -url = "https://auth.example.com/" -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("auth-url-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.auth.url.as_ref().map(url::Url::as_str), - Some("https://auth.example.com/"), - "TOML's auth.url must not be clobbered by the CLI re-parse", - ); - } - - /// The optional system-roots policy loaded from TOML survives when omitted on the CLI. - #[test] - fn cli_does_not_clobber_toml_system_roots() { - let _env = EnvGuard::clear(&["MOQ_CLIENT_TLS_SYSTEM_ROOTS"]); - - let toml = r#" -[connect.tls] -system_roots = true -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("system-roots-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.connect.tls.system_roots, - Some(true), - "TOML's connect.tls.system_roots must not be clobbered by the CLI re-parse" - ); - } - - /// A stable cluster id loaded from TOML survives when omitted on the CLI. - #[test] - fn cli_does_not_clobber_toml_cluster_id() { - let _env = EnvGuard::clear(&["MOQ_CLUSTER_ID"]); - - let toml = r#" -[cluster] -id = 12345 -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("cluster-id-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.cluster.id, - Some(12345), - "TOML's cluster.id must not be clobbered by the CLI re-parse" - ); - } - - /// The per-site stats tier flags are `Option`, so an absent CLI flag - /// must not wipe a TOML value during the `update_from` re-parse. - #[test] - fn cli_does_not_clobber_toml_tiers() { - let _env = EnvGuard::clear(&["MOQ_CLUSTER_TIER"]); - - let toml = r#" -[cluster] -tier = "region" -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("tiers-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.cluster.tier.as_deref(), - Some("region"), - "TOML cluster.tier must survive" - ); - } - - /// A Unix listener and its allowlist loaded from TOML survive together. - #[cfg(all(feature = "uds", unix))] - #[test] - fn cli_does_not_clobber_toml_server_unix() { - let _env = EnvGuard::clear(&["MOQ_SERVER_UNIX_BIND", "MOQ_SERVER_UNIX_ALLOW_UID"]); - - let toml = r#" -[listen] -bind = "[::]:443" - -[listen.unix] -bind = "/run/moq/internal.sock" - -[listen.unix.allow] -uid = [1001] -"#; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("server-unix-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.listen.bind.as_ref().map(ToString::to_string).as_deref(), - Some("[::]:443") - ); - assert_eq!( - config.listen.unix.bind.as_deref(), - Some(std::path::Path::new("/run/moq/internal.sock")), - "TOML's listen.unix.bind must not be clobbered by the CLI re-parse" - ); - assert_eq!( - config.listen.unix.allow.uid, - vec![1001], - "TOML's server.unix.allow must not be clobbered by the CLI re-parse" - ); - } - - #[test] - fn cli_flag_overrides_toml_cluster_id() { - let _env = EnvGuard::clear(&["MOQ_CLUSTER_ID"]); - - let toml = "[cluster]\nid = 12345\n"; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("cluster-id-cli-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![ - std::ffi::OsString::from("moq-relay"), - std::ffi::OsString::from(&path), - std::ffi::OsString::from("--cluster-id=67890"), - ]; - let config = Config::parse_and_merge(args).expect("config load"); - assert_eq!(config.cluster.id, Some(67890)); - } - - /// An internal listener loaded from TOML survives when omitted on the CLI. - #[test] - fn cli_does_not_clobber_toml_internal_listen() { - let _env = EnvGuard::clear(&["MOQ_INTERNAL_LISTEN"]); - - let toml = "[internal]\nlisten = \"127.0.0.1:9101\"\n"; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("internal-listen-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.internal.listen, - Some("127.0.0.1:9101".parse().unwrap()), - "TOML's internal.listen must not be clobbered by the CLI re-parse" - ); - } - /// Help and version are answered, not wrapped as failures. /// /// Usage renders those variants as an empty string through `render_failure`, @@ -1346,15 +946,6 @@ uid = [1001] } } - /// The spec is named for the binary, not for the struct that declares it. - /// - /// Usage takes the program name from the type unless told otherwise, so an - /// undeclared name renders every usage line and completion as `config`. - #[test] - fn the_spec_is_named_for_the_binary() { - assert_eq!(Cli::spec().bin.unwrap_or(Cli::spec().name), "moq-relay"); - } - /// The two declarations of every merged flag stay in step. #[test] fn the_settings_registry_matches_the_cli() { @@ -1463,6 +1054,161 @@ uid = [1001] check: |config| assert!(!config.stats.enabled), source: "--stats-enabled", }, + // One row per value shape a file can carry past an absent flag. + Case { + name: "duration-from-file", + toml: "[cache]\nduration = \"30s\"\n", + env: &[], + cli: &[], + key: "cache.duration", + check: |config| assert_eq!(config.cache.duration, Some(std::time::Duration::from_secs(30))), + source: "duration", + }, + Case { + name: "flattened-duration-from-file", + toml: "[connect]\ntimeout = \"2m\"\n", + env: &[], + cli: &[], + key: "connect.timeout", + check: |config| assert_eq!(config.connect.timeout, Some(std::time::Duration::from_secs(120))), + source: "timeout", + }, + Case { + name: "optional-string-from-file", + toml: "[cluster]\ntier = \"region\"\n", + env: &[], + cli: &[], + key: "cluster.tier", + check: |config| assert_eq!(config.cluster.tier.as_deref(), Some("region")), + source: "tier", + }, + Case { + name: "optional-int-from-file", + toml: "[cluster]\nid = 12345\n", + env: &[], + cli: &[], + key: "cluster.id", + check: |config| assert_eq!(config.cluster.id, Some(12345)), + source: "id", + }, + Case { + name: "flattened-optional-int-from-file", + toml: "[quic]\nreceive_window = 67108864\n", + env: &[], + cli: &[], + key: "quic.receive_window", + check: |config| assert_eq!(config.quic.receive_window, Some(67108864)), + source: "receive_window", + }, + Case { + name: "optional-bool-from-file", + toml: "[connect.tls]\nsystem_roots = true\n", + env: &[], + cli: &[], + key: "connect.tls.system_roots", + check: |config| assert_eq!(config.connect.tls.system_roots, Some(true)), + source: "system_roots", + }, + Case { + name: "enum-from-file", + toml: "[quic]\ncongestion_control = \"delay\"\n", + env: &[], + cli: &[], + key: "quic.congestion_control", + check: |config| { + assert_eq!( + config.quic.congestion_control, + Some(moq_tokio::quic::CongestionControl::Delay) + ) + }, + source: "congestion_control", + }, + Case { + name: "path-from-file", + toml: "[quic]\nqlog = \"/tmp/moq-qlog\"\n", + env: &[], + cli: &[], + key: "quic.qlog", + check: |config| assert_eq!(config.quic.qlog.as_deref(), Some(std::path::Path::new("/tmp/moq-qlog"))), + source: "qlog", + }, + Case { + name: "path-list-from-file", + toml: "[web.https]\ncert = [\"a.pem\", \"b.pem\"]\nkey = [\"a.key\", \"b.key\"]\n", + env: &[], + cli: &[], + key: "web.https.cert", + check: |config| { + assert_eq!( + config.web.https.cert, + vec![std::path::PathBuf::from("a.pem"), std::path::PathBuf::from("b.pem")] + ) + }, + source: "cert", + }, + Case { + name: "url-from-file", + toml: "[auth]\nurl = \"https://auth.example.com/\"\n", + env: &[], + cli: &[], + key: "auth.url", + check: |config| { + assert_eq!( + config.auth.url.as_ref().map(url::Url::as_str), + Some("https://auth.example.com/") + ) + }, + source: "url", + }, + Case { + name: "socket-addr-from-file", + toml: "[internal]\nlisten = \"127.0.0.1:9101\"\n", + env: &[], + cli: &[], + key: "internal.listen", + check: |config| assert_eq!(config.internal.listen, Some("127.0.0.1:9101".parse().unwrap())), + source: "listen", + }, + Case { + name: "flattened-socket-addr-from-file", + toml: "[listen]\npreferred_v4 = \"192.0.2.1:443\"\n", + env: &[], + cli: &[], + key: "listen.preferred_v4", + check: |config| assert_eq!(config.listen.preferred_v4, Some("192.0.2.1:443".parse().unwrap())), + source: "preferred_v4", + }, + #[cfg(all(feature = "uds", unix))] + Case { + name: "int-list-from-file", + toml: "[listen.unix]\nbind = \"/run/moq/internal.sock\"\n\n[listen.unix.allow]\nuid = [1001]\n", + env: &[], + cli: &[], + key: "listen.unix.allow.uid", + check: |config| { + assert_eq!( + config.listen.unix.bind.as_deref(), + Some(std::path::Path::new("/run/moq/internal.sock")) + ); + assert_eq!(config.listen.unix.allow.uid, vec![1001]); + }, + source: "uid", + }, + #[cfg(feature = "cluster-lan")] + Case { + name: "newtype-from-file", + toml: "[cluster.lan]\nenabled = true\napp = \"custom\"\n", + env: &[], + cli: &[], + key: "cluster.lan.app", + check: |config| { + assert_eq!( + config.cluster.lan.app.as_ref().map(ToString::to_string).as_deref(), + Some("custom") + ) + }, + source: "app", + }, ]; for case in cases { @@ -1472,6 +1218,23 @@ uid = [1001] "MOQ_LISTEN_VERSION", "MOQ_LISTEN_TLS_GENERATE", "MOQ_RUNTIME_PIN", + "MOQ_CACHE_DURATION", + "MOQ_CONNECT_TIMEOUT", + "MOQ_CLUSTER_TIER", + "MOQ_CLUSTER_ID", + "MOQ_QUIC_RECEIVE_WINDOW", + "MOQ_CONNECT_TLS_SYSTEM_ROOTS", + "MOQ_QUIC_CONGESTION_CONTROL", + "MOQ_QUIC_QLOG", + "MOQ_WEB_HTTPS_CERT", + "MOQ_WEB_HTTPS_KEY", + "MOQ_AUTH_URL", + "MOQ_INTERNAL_LISTEN", + "MOQ_LISTEN_PREFERRED_V4", + "MOQ_LISTEN_UNIX_BIND", + "MOQ_LISTEN_UNIX_ALLOW_UID", + "MOQ_CLUSTER_LAN", + "MOQ_CLUSTER_LAN_APP", ]); for (key, value) in case.env { // SAFETY: EnvGuard serializes env mutation across these tests. @@ -1547,28 +1310,6 @@ uid = [1001] assert_eq!(config.auth.public, vec!["anon/**".parse().unwrap()]); } - /// A TOML `[cluster.lan] app` survives when the CLI omits the flag. - #[cfg(feature = "cluster-lan")] - #[test] - fn cli_does_not_clobber_toml_cluster_lan_app() { - let _env = EnvGuard::clear(&["MOQ_CLUSTER_LAN", "MOQ_CLUSTER_LAN_SECRET", "MOQ_CLUSTER_LAN_APP"]); - - let toml = "[cluster.lan]\nenabled = true\napp = \"custom\"\n"; - let dir = std::env::temp_dir().join("moq-relay-config-test"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("cluster-lan-app-toml-wins.toml"); - std::fs::write(&path, toml).unwrap(); - - let args = vec![std::ffi::OsString::from("moq-relay"), std::ffi::OsString::from(&path)]; - let config = Config::parse_and_merge(args).expect("config load"); - - assert_eq!( - config.cluster.lan.app.as_ref().map(ToString::to_string).as_deref(), - Some("custom"), - "TOML's cluster.lan.app must not be clobbered by the CLI re-parse" - ); - } - /// A QUIC-LB nonce with no server id stops startup from TOML and the /// environment, and `lb_id` no longer hides `load_balancer`. /// diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index 446c9f91712..6d957c612f2 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -1013,20 +1013,29 @@ mod tests { } } + /// A value loaded from TOML survives re-applying CLI args that omit its flag, + /// one row per value shape. #[test] - fn test_toml_disable_verify_survives_update_from() { - let toml = r#" - tls.insecure = true - "#; - - let config: crate::connect::Config = toml::from_str(toml).unwrap(); - assert_eq!(config.tls.insecure, Some(true)); - - // Simulate: TOML loaded, then CLI args re-applied (no --connect-tls-insecure flag). - let mut cli = Cli { config }; - cli.update_from(&[]); - let config = cli.config; - assert_eq!(config.tls.insecure, Some(true)); + fn test_toml_survives_update_from() { + let default = format!("{:?}", crate::connect::Config::default()); + for toml in [ + "tls.insecure = true", + r#"resolution_delay = "10ms""#, + r#"tls.fingerprint = ["abcd1234", "ef567890"]"#, + r#"version = ["moq-lite-02"]"#, + r#"url = "https://relay.example.com/anon""#, + "once = true", + r#"bind = "127.0.0.1:1234""#, + r#"tls.host_name = "example.host""#, + ] { + let config: crate::connect::Config = toml::from_str(toml).unwrap(); + let loaded = format!("{config:?}"); + assert_ne!(loaded, default, "{toml} must set a value"); + + let mut cli = Cli { config }; + cli.update_from(&[]); + assert_eq!(format!("{:?}", cli.config), loaded, "{toml}"); + } } #[test] @@ -1041,12 +1050,6 @@ mod tests { assert_eq!(config.tls.insecure, Some(false)); } - #[test] - fn test_cli_disable_verify_explicit_true() { - let config = Cli::config_from(["test", "--connect-tls-insecure=true"]); - assert_eq!(config.tls.insecure, Some(true)); - } - /// A released spelling parses into a hidden field and is never read as a /// setting: the canonical field stays unset, and the config reports the /// migration instead. Honoring it silently is what this replaced, since a @@ -1107,12 +1110,6 @@ mod tests { assert!(err.to_string().contains("--connect / MOQ_CONNECT"), "{err}"); } - #[test] - fn test_cli_no_disable_verify() { - let config = Cli::config_from(["test"]); - assert_eq!(config.tls.insecure, None); - } - #[test] fn test_toml_failover_delay_is_reported_not_applied() { let toml = r#" @@ -1134,21 +1131,6 @@ mod tests { assert_eq!(config.resolve().race, std::time::Duration::from_millis(50)); } - #[test] - fn test_toml_resolution_delay_survives_update_from() { - let toml = r#" - resolution_delay = "10ms" - "#; - - let config: crate::connect::Config = toml::from_str(toml).unwrap(); - assert_eq!(config.resolution_delay, Some(std::time::Duration::from_millis(10))); - - // Simulate: TOML loaded, then CLI args re-applied (no --connect-resolution-delay flag). - let mut cli = Cli { config }; - cli.update_from(&[]); - assert_eq!(cli.config.resolution_delay, Some(std::time::Duration::from_millis(10))); - } - #[test] fn test_cli_resolution_delay() { let config = Cli::config_from(["test", "--connect-resolution-delay", "0s"]); @@ -1156,28 +1138,6 @@ mod tests { assert_eq!(config.resolve().resolution_delay, std::time::Duration::ZERO); } - #[test] - fn resolution_delay_defaults_to_the_rfc_value() { - let config = Cli::config_from(["test"]); - assert_eq!(config.resolve().resolution_delay, std::time::Duration::from_millis(50)); - } - - #[test] - fn test_toml_fingerprint_survives_update_from() { - let toml = r#" - tls.fingerprint = ["abcd1234", "ef567890"] - "#; - - let config: crate::connect::Config = toml::from_str(toml).unwrap(); - assert_eq!(config.tls.fingerprint, vec!["abcd1234", "ef567890"]); - - // Simulate: TOML loaded, then CLI args re-applied (no --client-tls-fingerprint flag). - let mut cli = Cli { config }; - cli.update_from(&[]); - let config = cli.config; - assert_eq!(config.tls.fingerprint, vec!["abcd1234", "ef567890"]); - } - #[test] fn test_toml_fingerprint_accepts_single_string() { let toml = r#" @@ -1188,34 +1148,6 @@ mod tests { assert_eq!(config.tls.fingerprint, vec!["abcd1234"]); } - #[test] - fn test_cli_fingerprint() { - let config = Cli::config_from(["test", "--connect-tls-fingerprint", "abcd1234"]); - assert_eq!(config.tls.fingerprint, vec!["abcd1234"]); - } - - #[test] - fn test_toml_version_survives_update_from() { - let toml = r#" - version = ["moq-lite-02"] - "#; - - let config: crate::connect::Config = toml::from_str(toml).unwrap(); - assert_eq!(config.version, vec!["moq-lite-02".parse::().unwrap()]); - - // Simulate: TOML loaded, then CLI args re-applied (no --client-version flag). - let mut cli = Cli { config }; - cli.update_from(&[]); - let config = cli.config; - assert_eq!(config.version, vec!["moq-lite-02".parse::().unwrap()]); - } - - #[test] - fn test_cli_version() { - let config = Cli::config_from(["test", "--connect-version", "moq-lite-03"]); - assert_eq!(config.version, vec!["moq-lite-03".parse::().unwrap()]); - } - #[test] fn test_cli_version_help_lists_every_parseable_name() { let help = Cli::render_help(Cli::command(), true).expect("long help"); @@ -1224,44 +1156,6 @@ mod tests { } } - #[test] - fn test_toml_connect_survives_update_from() { - let toml = r#" - url = "https://relay.example.com/anon" - "#; - - let config: crate::connect::Config = toml::from_str(toml).unwrap(); - assert_eq!(config.url.as_ref().unwrap().as_str(), "https://relay.example.com/anon"); - - // Simulate: TOML loaded, then CLI args re-applied (no --client-connect flag). - let mut cli = Cli { config }; - cli.update_from(&[]); - let config = cli.config; - assert_eq!(config.url.as_ref().unwrap().as_str(), "https://relay.example.com/anon"); - } - - #[test] - fn test_cli_connect() { - let config = Cli::config_from(["test", "--connect", "https://relay.example.com/anon"]); - assert_eq!(config.url.as_ref().unwrap().as_str(), "https://relay.example.com/anon"); - } - - #[test] - fn test_toml_once_survives_update_from() { - let toml = r#" - once = true - "#; - - let config: crate::connect::Config = toml::from_str(toml).unwrap(); - assert_eq!(config.once, Some(true)); - - // Simulate: TOML loaded, then CLI args re-applied (no --connect-once flag). - let mut cli = Cli { config }; - cli.update_from(&[]); - let config = cli.config; - assert_eq!(config.once, Some(true)); - } - /// The released TOML said `reconnect = false`; `once` says the opposite thing. /// /// Still parsed, because `deny_unknown_fields` would otherwise reject the file @@ -1292,17 +1186,6 @@ mod tests { ); } - /// A config file's bind survives when the CLI omits it. - #[test] - fn test_toml_bind_survives_update_from() { - let config: crate::connect::Config = toml::from_str(r#"bind = "127.0.0.1:1234""#).unwrap(); - assert_eq!(config.bind, Some("127.0.0.1:1234".parse().unwrap())); - - let mut cli = Cli { config }; - cli.update_from(&[]); - assert_eq!(cli.config.bind, Some("127.0.0.1:1234".parse().unwrap())); - } - /// Several versions offered at once, which the canonical flag takes by repeating. #[test] fn test_version_list() { @@ -1334,28 +1217,6 @@ mod tests { assert_eq!(config.once, Some(false)); } - #[test] - fn test_toml_host_name_survives_update_from() { - let toml = r#" - tls.host_name = "example.host" - "#; - - let config: crate::connect::Config = toml::from_str(toml).unwrap(); - assert_eq!(config.tls.host_name.as_deref(), Some("example.host")); - - // Simulate: TOML loaded, then CLI args re-applied (no --client-tls-host-name flag). - let mut cli = Cli { config }; - cli.update_from(&[]); - let config = cli.config; - assert_eq!(config.tls.host_name.as_deref(), Some("example.host")); - } - - #[test] - fn test_cli_host_name() { - let config = Cli::config_from(["test", "--connect-tls-host-name", "override.example"]); - assert_eq!(config.tls.host_name.as_deref(), Some("override.example")); - } - #[test] fn test_cli_no_version_defaults_to_all() { let config = Cli::config_from(["test"]); @@ -1723,15 +1584,6 @@ mod tests { assert!(matches!(value, super::TransportRace::Quic("quic"))); } - /// The resolved default has to exist in every build, including ones that compile - /// no address-racing transport at all, which is what broke in #2773. - #[test] - fn race_defaults_to_the_rfc_8305_stagger() { - let config = crate::connect::Config::default(); - assert_eq!(config.race, Some(std::time::Duration::from_millis(250))); - assert_eq!(config.resolve().race, std::time::Duration::from_millis(250)); - } - /// Iroh carries no rustls state, so constructing its client must not require an /// application-installed crypto provider. #[cfg(all(feature = "iroh", not(any(feature = "quic", feature = "websocket"))))] @@ -1740,12 +1592,6 @@ mod tests { crate::connect::Config::default().init().expect("iroh-only client"); } - #[test] - fn connect_timeout_defaults_to_thirty_seconds() { - let config = Cli::config_from(["test"]); - assert_eq!(config.resolve().timeout, crate::connect::DEFAULT_TIMEOUT); - } - /// A peer that completes the TCP handshake and then never speaks: the QUIC arm /// gives up on its own, but the WebSocket arm has no deadline of its own, so the /// race stays pending forever. Without the connect timeout this test hangs. diff --git a/rs/moq-tokio/tests/integration/alpn.rs b/rs/moq-tokio/tests/integration/alpn.rs deleted file mode 100644 index 6c0f9fd0aa8..00000000000 --- a/rs/moq-tokio/tests/integration/alpn.rs +++ /dev/null @@ -1,270 +0,0 @@ -//! Integration test: verify that forcing each supported version results in a -//! successful MoQ handshake between a Quinn server and client. -//! -//! This covers both ALPN-based version negotiation (moq-lite-03/04, -//! moqt-15/16/17/18/19) and SETUP-based version negotiation (moql, moq-00) used -//! by older protocol versions like moq-transport-14 and moq-lite-01/02. -//! -//! It also tests WebTransport, which uses sub-protocols in the HTTP CONNECT -//! request instead of TLS ALPN, but serves the same purpose. - -/// Spin up a server and client both restricted to the given version, -/// and verify the handshake completes over raw QUIC (moqt:// URL). -async fn connect_with_version(version: &str) { - let version: moq_tokio::moq_net::Version = version.parse().expect("invalid version"); - - // ── server ────────────────────────────────────────────────────── - let mut server_config = moq_tokio::listen::Config::default(); - server_config.bind = Some("[::]:0".parse().unwrap()); - server_config.tls.generate = vec!["localhost".into()]; - server_config.version = vec![version]; - - let server = server_config.init(Default::default()).expect("failed to init server"); - let mut server = server.listen().await.expect("failed to listen"); - let addr = server.local_addr().expect("failed to get local addr"); - - // Provide a dummy origin so the MoQ handshake has something to negotiate. - let origin = moq_tokio::origin::spawn(); - - // ── client ────────────────────────────────────────────────────── - let mut client_config = moq_tokio::connect::Config::default(); - client_config.version = vec![version]; - client_config.tls.insecure = Some(true); - - let client = client_config.init(Default::default()).expect("failed to init client"); - - // Use raw QUIC URL so ALPN negotiation is direct (no WebTransport framing). - let url: url::Url = format!("moqt://localhost:{}", addr.port()).parse().unwrap(); - - // Run server accept and client connect concurrently. - let server_origin = origin.clone(); - let server_connect = async { - let request = server.accept().await.expect("no incoming connection"); - request.with_publisher(&server_origin).ok().await - }; - - let client = client.with_publisher(&origin); - let client_connect = client.with_reconnect(false).connect(url).established(); - let (server_result, client_result) = tokio::join!(server_connect, client_connect); - - // Both sides should succeed. - if let Err(err) = &client_result { - panic!("client handshake failed for version {version}: {err}"); - } - if let Err(err) = &server_result { - panic!("server handshake failed for version {version}: {err}"); - } -} - -/// Connect via WebTransport (https:// URL with h3 ALPN). -/// Sub-protocols in the HTTP CONNECT request serve the same role as ALPN. -/// If a version is specified, both client and server are restricted to it. -async fn connect_with_webtransport(version: Option<&str>) { - let version: Option = version.map(|v| v.parse().expect("invalid version")); - - // ── server ────────────────────────────────────────────────────── - let mut server_config = moq_tokio::listen::Config::default(); - server_config.bind = Some("[::]:0".parse().unwrap()); - server_config.tls.generate = vec!["localhost".into()]; - if let Some(v) = version { - server_config.version = vec![v]; - } - - let server = server_config.init(Default::default()).expect("failed to init server"); - let mut server = server.listen().await.expect("failed to listen"); - let addr = server.local_addr().expect("failed to get local addr"); - - let origin = moq_tokio::origin::spawn(); - - // ── client ────────────────────────────────────────────────────── - let mut client_config = moq_tokio::connect::Config::default(); - client_config.tls.insecure = Some(true); - if let Some(v) = version { - client_config.version = vec![v]; - } - - let client = client_config.init(Default::default()).expect("failed to init client"); - - // Use https:// URL to trigger the WebTransport path. - let url: url::Url = format!("https://localhost:{}", addr.port()).parse().unwrap(); - - let server_origin = origin.clone(); - let server_connect = async { - let request = server.accept().await.expect("no incoming connection"); - request.with_publisher(&server_origin).ok().await - }; - - let client = client.with_publisher(&origin); - let client_connect = client.with_reconnect(false).connect(url).established(); - let (server_result, client_result) = tokio::join!(server_connect, client_connect); - - let label = version.map_or("default".to_string(), |v| v.to_string()); - if let Err(err) = &client_result { - panic!("client WebTransport handshake failed for {label}: {err}"); - } - if let Err(err) = &server_result { - panic!("server WebTransport handshake failed for {label}: {err}"); - } -} - -// ── SETUP-based version negotiation (via "moql" ALPN) ─────────────── - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_lite_01() { - connect_with_version("moq-lite-01").await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_lite_02() { - connect_with_version("moq-lite-02").await; -} - -// ── ALPN-based version negotiation (no SETUP stream) ──────────────── - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_lite_03() { - connect_with_version("moq-lite-03").await; -} - -// ── SETUP-based via "moq-00" ALPN ─────────────────────────────────── - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_transport_14() { - connect_with_version("moq-transport-14").await; -} - -// ── ALPN-based (newer IETF drafts) ────────────────────────────────── - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_transport_15() { - connect_with_version("moq-transport-15").await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_transport_16() { - connect_with_version("moq-transport-16").await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_transport_17() { - connect_with_version("moq-transport-17").await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_transport_18() { - connect_with_version("moq-transport-18").await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_transport_19() { - connect_with_version("moq-transport-19").await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_transport_20() { - connect_with_version("moq-transport-20").await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_transport_21() { - connect_with_version("moq-transport-21").await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn version_moq_transport_22() { - connect_with_version("moq-transport-22").await; -} - -// ── WebTransport: sub-protocol negotiation ────────────────────────── -// Browser clients use WebTransport (h3 ALPN) and negotiate the MoQ -// protocol version via sub-protocols in the HTTP CONNECT request. - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport() { - connect_with_webtransport(None).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_lite_01() { - connect_with_webtransport(Some("moq-lite-01")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_lite_02() { - connect_with_webtransport(Some("moq-lite-02")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_lite_03() { - connect_with_webtransport(Some("moq-lite-03")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_transport_14() { - connect_with_webtransport(Some("moq-transport-14")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_transport_15() { - connect_with_webtransport(Some("moq-transport-15")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_transport_16() { - connect_with_webtransport(Some("moq-transport-16")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_transport_17() { - connect_with_webtransport(Some("moq-transport-17")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_transport_18() { - connect_with_webtransport(Some("moq-transport-18")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_transport_19() { - connect_with_webtransport(Some("moq-transport-19")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_transport_20() { - connect_with_webtransport(Some("moq-transport-20")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_transport_21() { - connect_with_webtransport(Some("moq-transport-21")).await; -} - -#[tracing_test::traced_test] -#[tokio::test] -async fn webtransport_moq_transport_22() { - connect_with_webtransport(Some("moq-transport-22")).await; -} diff --git a/rs/moq-tokio/tests/integration/main.rs b/rs/moq-tokio/tests/integration/main.rs index e95dab914d1..6e263fb089d 100644 --- a/rs/moq-tokio/tests/integration/main.rs +++ b/rs/moq-tokio/tests/integration/main.rs @@ -3,7 +3,6 @@ //! Each `tests/*.rs` file is its own crate that links this package and its //! dependencies again, so add new integration tests here as a module. -mod alpn; mod backend; mod broadcast; mod close_code; From a675e69d9247ade19c05a29a6418dad524a93026 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 21 Oct 2026 09:43:00 -0700 Subject: [PATCH 2/6] test: drop low-value tests in the misc crates Duplicates of the shared golden vectors, cross-level duplicates, and asserts that cannot fail. Co-Authored-By: Claude Opus 5.5 --- rs/kio/src/queue.rs | 17 --- rs/kio/src/shared.rs | 10 -- rs/moq-c/src/test.rs | 27 ---- rs/moq-cli/src/args.rs | 8 -- rs/moq-cli/src/web.rs | 7 -- rs/moq-ffi/src/test.rs | 26 ---- rs/moq-flate/src/snapshot/mod.rs | 10 -- rs/moq-flate/src/stream/mod.rs | 25 ---- rs/moq-json/src/diff.rs | 55 -------- rs/moq-json/src/snapshot/mod.rs | 78 ------------ rs/moq-json/src/stream/decoder.rs | 26 ---- rs/moq-json/src/stream/mod.rs | 13 -- rs/moq-pattern/src/pattern.rs | 202 ------------------------------ rs/moq-pattern/tests/pattern.json | 5 + rs/moq-sock/src/bind.rs | 6 - rs/moq-stats/src/produce.rs | 19 --- 16 files changed, 5 insertions(+), 529 deletions(-) diff --git a/rs/kio/src/queue.rs b/rs/kio/src/queue.rs index 95044602c9f..a4ebba7fe0e 100644 --- a/rs/kio/src/queue.rs +++ b/rs/kio/src/queue.rs @@ -412,23 +412,6 @@ mod test { assert_eq!(queue.poll_push_with(&push_waiter, || 3), Poll::Ready(Err(Closed))); } - #[test] - fn accessors() { - let queue = Queue::bounded(2); - assert_eq!(queue.capacity(), Some(2)); - assert!(queue.is_empty()); - queue.try_push(1).unwrap(); - assert_eq!(queue.len(), 1); - assert!(!queue.is_empty()); - assert!(!queue.is_closed()); - - let clone = queue.clone(); - let other = Queue::::new(); - assert!(queue.same_channel(&clone)); - assert!(!queue.same_channel(&other)); - assert_eq!(other.capacity(), None); - } - #[test] #[should_panic(expected = "zero-capacity")] fn zero_capacity_panics() { diff --git a/rs/kio/src/shared.rs b/rs/kio/src/shared.rs index 68d1207d64f..7e77079565d 100644 --- a/rs/kio/src/shared.rs +++ b/rs/kio/src/shared.rs @@ -227,14 +227,4 @@ mod test { assert_eq!(task.await.unwrap(), Some(3)); } - - #[test] - fn same_channel_tracks_identity() { - let shared = Shared::>::default(); - let clone = shared.clone(); - let other = Shared::>::default(); - - assert!(shared.same_channel(&clone)); - assert!(!shared.same_channel(&other)); - } } diff --git a/rs/moq-c/src/test.rs b/rs/moq-c/src/test.rs index 77ba92d10c6..470a81f6d4e 100644 --- a/rs/moq-c/src/test.rs +++ b/rs/moq-c/src/test.rs @@ -248,13 +248,6 @@ fn publish_container(broadcast: u32, format: moq_container_format, init: &[u8]) unsafe { moq_publish_container(broadcast, &config) } } -#[test] -fn origin_lifecycle() { - let origin = id(moq_origin_create()); - assert_eq!(moq_origin_close(origin), 0, "moq_origin_close should succeed"); - assert!(moq_origin_close(origin) < 0, "double-close should fail"); -} - #[test] fn last_error_reports_reason() { // A failed call records a retrievable reason string for moq_error(). @@ -408,26 +401,6 @@ fn last_error_protocol_captures_session_known_app_and_unknown() { } } -#[test] -fn publish_media_lifecycle() { - let origin = id(moq_origin_create()); - let broadcast = publish_broadcast(origin, b"publish-media-lifecycle"); - let _guard = Guard(Some(|| { - moq_publish_close(broadcast); - })); - - let init = opus_head(); - let format = moq_audio_format::MOQ_AUDIO_FORMAT_OPUS; - let media = id(publish_audio(broadcast, format, &init, None)); - - let payload = b"opus frame"; - let ret = unsafe { moq_publish_media_frame(media, payload.as_ptr(), payload.len(), 1000) }; - assert_eq!(ret, 0, "moq_publish_media_frame should succeed"); - - assert_eq!(moq_publish_media_finish(media), 0); - assert_eq!(moq_publish_close(broadcast), 0); -} - #[test] fn publish_media_rejects_a_null_config() { let origin = id(moq_origin_create()); diff --git a/rs/moq-cli/src/args.rs b/rs/moq-cli/src/args.rs index 02fb827d2a9..6e7839aece8 100644 --- a/rs/moq-cli/src/args.rs +++ b/rs/moq-cli/src/args.rs @@ -1277,14 +1277,6 @@ mod tests { let _ = Stage::to_kdl(); } - #[test] - fn single_stage() { - let cli = Invocation::try_parse_from(["moq", "--connect", "http://relay", "import", "ts"]).unwrap(); - assert_eq!(cli.stages.len(), 1); - assert_eq!(cli.stages[0].name(), "import"); - assert!(cli.validate().is_ok()); - } - /// Only TS can mark where a returned broadcast restarts, so only `export ts` may linger. #[test] fn linger_is_ts_only() { diff --git a/rs/moq-cli/src/web.rs b/rs/moq-cli/src/web.rs index ec129c82bac..0ea3d46dc28 100644 --- a/rs/moq-cli/src/web.rs +++ b/rs/moq-cli/src/web.rs @@ -96,13 +96,6 @@ pub async fn run_web(bind: moq_tokio::listen::Bind, certificates: moq_tokio::tls mod tests { use super::*; - #[test] - fn cors_origin_defaults_to_no_browser_origin() { - let cors = Cors::default(); - - assert!(cors.layer([Method::GET]).is_ok()); - } - #[test] fn cors_origin_allows_specific_allowlist() { let cors = Cors { diff --git a/rs/moq-ffi/src/test.rs b/rs/moq-ffi/src/test.rs index 080d34a6054..2d5aca311ac 100644 --- a/rs/moq-ffi/src/test.rs +++ b/rs/moq-ffi/src/test.rs @@ -335,12 +335,6 @@ fn h264_init() -> Vec { init } -#[test] -fn origin_lifecycle() { - let origin = MoqOriginProducer::new(MoqOriginConfig::default()); - let _consumer = origin.consume(); -} - #[test] fn origin_config_set_cache_capacity() { let origin = MoqOriginProducer::new(MoqOriginConfig { @@ -485,26 +479,6 @@ async fn announced_epoch_restarts_on_a_new_epoch() { broadcast.close().unwrap(); } -#[test] -fn publish_media_lifecycle() { - let broadcast = MoqBroadcastProducer::new().unwrap(); - let init = opus_head(); - let media = MoqMediaTrackProducer::audio( - &broadcast, - MoqMediaTarget::Named { name: None }, - audio_init(MoqAudioFormat::Opus, init), - ) - .unwrap(); - media - .write_frame(MoqFrame { - payload: b"opus frame".to_vec(), - timestamp_us: Some(1000), - }) - .unwrap(); - media.finish().unwrap(); - broadcast.close().unwrap(); -} - /// A media track reserves through its demand, so an app that publishes /// pre-encoded frames (OBS) can follow the grant like a raw track can. #[tokio::test] diff --git a/rs/moq-flate/src/snapshot/mod.rs b/rs/moq-flate/src/snapshot/mod.rs index 91887e02d3c..aebd6f5c91b 100644 --- a/rs/moq-flate/src/snapshot/mod.rs +++ b/rs/moq-flate/src/snapshot/mod.rs @@ -237,16 +237,6 @@ mod test { } } - #[test] - fn compressed_roundtrip() { - let (mut producer, track) = producer(true); - let payload = Bytes::from(b"the quick brown fox".repeat(64)); - producer.update(payload.clone()).unwrap(); - producer.finish().unwrap(); - - assert_eq!(drain(consume(track, true)), vec![payload]); - } - /// The compressed frame on the wire is much smaller than the value it carries, so a consumer /// that ignored the flag would read garbage rather than the payload. #[test] diff --git a/rs/moq-flate/src/stream/mod.rs b/rs/moq-flate/src/stream/mod.rs index 0d5f190f5c8..96fbea32c69 100644 --- a/rs/moq-flate/src/stream/mod.rs +++ b/rs/moq-flate/src/stream/mod.rs @@ -194,18 +194,6 @@ mod test { assert_ne!(frame.timestamp.unwrap().as_micros(), captured.as_micros()); } - #[test] - fn compressed_roundtrip_in_order() { - let (mut producer, track) = producer(true); - let expected = payloads(20); - for payload in &expected { - producer.append(payload.clone()).unwrap(); - } - producer.finish().unwrap(); - - assert_eq!(drain(track, true), expected); - } - /// The window spans the whole group, so a repeated payload costs almost nothing after the first. #[test] fn the_shared_window_shrinks_repetitive_payloads() { @@ -407,19 +395,6 @@ mod test { moq_net::track::Subscription::default().with_max_delay(std::time::Duration::from_secs(30)) } - /// The track ends with the group, so nothing opens a second one and splits the log. - #[test] - fn a_failed_write_ends_the_track() { - let track = rejecting_track(); - let mut producer = Producer::new(track, Config::default()); - - assert!(producer.append(late(b"rejected")).is_err()); - assert!( - producer.append(late(b"again")).is_err(), - "a second append must fail on the closed track rather than open another group" - ); - } - /// An ended log reports why it ended, even for a payload past the budget: `GroupTooLarge` would /// tell the caller the log is still writable. #[test] diff --git a/rs/moq-json/src/diff.rs b/rs/moq-json/src/diff.rs index 4efd27e1589..b6d085c3c51 100644 --- a/rs/moq-json/src/diff.rs +++ b/rs/moq-json/src/diff.rs @@ -1226,19 +1226,6 @@ mod test { check(json!({ "x": { "a": 1 } }), json!({ "x": {} })); } - #[test] - fn changed_scalar() { - check(json!({ "a": 1, "b": 2 }), json!({ "a": 1, "b": 3 })); - } - - #[test] - fn added_key() { - let result = diff(&json!({ "a": 1 }), &json!({ "a": 1, "b": 2 })); - assert!(!result.forced_snapshot); - assert_eq!(result.patch, json!({ "b": 2 })); - check(json!({ "a": 1 }), json!({ "a": 1, "b": 2 })); - } - #[test] fn added_null_key_forces_snapshot() { check(json!({ "a": 1 }), json!({ "a": 1, "x": null })); @@ -1248,22 +1235,6 @@ mod test { ); } - #[test] - fn removed_key_is_null() { - let result = diff(&json!({ "a": 1, "b": 2 }), &json!({ "a": 1 })); - assert!(!result.forced_snapshot, "removing a key is a clean delete"); - assert_eq!(result.patch, json!({ "b": null })); - check(json!({ "a": 1, "b": 2 }), json!({ "a": 1 })); - } - - #[test] - fn nested_object_only_includes_changed_keys() { - let result = diff(&json!({ "o": { "x": 1, "y": 2 } }), &json!({ "o": { "x": 1, "y": 9 } })); - assert!(!result.forced_snapshot); - assert_eq!(result.patch, json!({ "o": { "y": 9 } })); - check(json!({ "o": { "x": 1, "y": 2 } }), json!({ "o": { "x": 1, "y": 9 } })); - } - #[test] fn unchanged_object_is_empty_patch() { let result = diff(&json!({ "a": 1, "o": { "x": 1 } }), &json!({ "a": 1, "o": { "x": 1 } })); @@ -1271,14 +1242,6 @@ mod test { assert_eq!(result.patch, json!({})); } - #[test] - fn changed_array_is_wholesale_delta() { - let result = diff(&json!({ "a": [1, 2] }), &json!({ "a": [1, 2, 3] })); - assert!(!result.forced_snapshot); - assert_eq!(result.patch, json!({ "a": [1, 2, 3] })); - check(json!({ "a": [1, 2] }), json!({ "a": [1, 2, 3] })); - } - #[test] fn unchanged_array_is_pruned() { let result = diff(&json!({ "a": [1, 2, 3], "b": 1 }), &json!({ "a": [1, 2, 3], "b": 2 })); @@ -1289,11 +1252,6 @@ mod test { ); } - #[test] - fn added_array_is_delta() { - check(json!({ "a": 1 }), json!({ "a": 1, "b": [1] })); - } - #[test] fn nested_array_is_delta() { check(json!({ "o": { "x": 1 } }), json!({ "o": { "x": 1, "list": [1] } })); @@ -1307,14 +1265,6 @@ mod test { ); } - #[test] - fn set_to_null_forces_snapshot() { - // A genuine null value can't be represented: merge patch would delete the key. - let result = diff(&json!({ "a": 1 }), &json!({ "a": null })); - assert!(result.forced_snapshot); - assert!(reference(&json!({ "a": 1 }), &json!({ "a": null })).forced_snapshot); - } - #[test] fn nested_null_forces_snapshot() { let old = json!({ "o": { "x": 1 } }); @@ -1323,11 +1273,6 @@ mod test { assert_eq!(diff(&old, &new).forced_snapshot, reference(&old, &new).forced_snapshot); } - #[test] - fn replacing_object_with_scalar() { - check(json!({ "a": { "x": 1 } }), json!({ "a": 5 })); - } - #[test] fn replacing_scalar_with_object() { check(json!({ "a": 5 }), json!({ "a": { "x": 1 } })); diff --git a/rs/moq-json/src/snapshot/mod.rs b/rs/moq-json/src/snapshot/mod.rs index 6bc03283839..2e83c2b0d93 100644 --- a/rs/moq-json/src/snapshot/mod.rs +++ b/rs/moq-json/src/snapshot/mod.rs @@ -478,42 +478,6 @@ mod test { } } - #[test] - fn deltas_share_one_group() { - let (mut producer, mut track) = producer(cfg(100)); - producer.update(&json!({ "a": 1, "b": 1 })).unwrap(); - producer.update(&json!({ "a": 1, "b": 2 })).unwrap(); - producer.update(&json!({ "a": 1, "b": 3 })).unwrap(); - producer.finish().unwrap(); - - // All updates fit in a single group as snapshot + deltas. - assert_eq!( - track.largest().now_or_never().flatten().map(|position| position.group), - Some(0) - ); - let values = drain(track); - assert_eq!(values.last().unwrap(), &json!({ "a": 1, "b": 3 })); - } - - #[test] - fn tight_ratio_rolls_snapshots() { - // A ratio of 1 budgets deltas up to one snapshot (equal 7-byte frames => 7 bytes). The gate - // checks the deltas already written, so the delta that tips the group over budget still lands - // (a one-frame overshoot): group 0 takes two deltas (14 bytes) before the fourth update rolls - // group 1. (Still distinct from 0, which disables deltas entirely.) - let (mut producer, mut track) = producer(cfg(1)); - producer.update(&json!({ "a": 1 })).unwrap(); // snapshot, group 0 - producer.update(&json!({ "a": 2 })).unwrap(); // delta, group 0 (deltas = 7) - producer.update(&json!({ "a": 3 })).unwrap(); // delta, group 0 (deltas = 14, now over budget) - producer.update(&json!({ "a": 4 })).unwrap(); // budget already exceeded, rolls group 1 - producer.finish().unwrap(); - - assert_eq!( - track.largest().now_or_never().flatten().map(|position| position.group), - Some(1) - ); - } - #[test] fn deltas_stay_within_ratio_times_snapshot() { // The budget covers only the deltas, not the snapshot frame, measured against the group's @@ -567,18 +531,6 @@ mod test { assert_eq!(drain(track).last().unwrap(), &json!({ "n": MAX_DELTA_FRAMES })); } - #[test] - fn late_joiner_reconstructs_from_deltas() { - let (mut producer, track) = producer(cfg(100)); - producer.update(&json!({ "a": 1, "b": 1 })).unwrap(); - producer.update(&json!({ "a": 1, "b": 2 })).unwrap(); - producer.update(&json!({ "a": 5, "b": 2 })).unwrap(); - producer.finish().unwrap(); - - // A consumer created only now still rebuilds the final value from snapshot + deltas. - assert_eq!(drain(track).last().unwrap(), &json!({ "a": 5, "b": 2 })); - } - #[test] fn modify_refuses_a_value_of_another_shape() { // A published value that does not deserialize as `T` fails the edit instead of seeding a @@ -1080,36 +1032,6 @@ mod test { assert_eq!(values, vec![json!({ "a": 2 })]); } - #[test] - fn compressed_deltas_share_one_group() { - let (mut producer, mut track) = producer(cfg_deflate(100)); - producer.update(&json!({ "a": 1, "b": 1 })).unwrap(); - producer.update(&json!({ "a": 1, "b": 2 })).unwrap(); - producer.update(&json!({ "a": 1, "b": 3 })).unwrap(); - producer.finish().unwrap(); - - // Snapshot + deltas in one group, each frame decompressed against the shared window. - assert_eq!( - track.largest().now_or_never().flatten().map(|position| position.group), - Some(0) - ); - let values = drain_with(deflate_consumer(track)); - assert_eq!(values.last().unwrap(), &json!({ "a": 1, "b": 3 })); - } - - #[test] - fn compressed_late_joiner_reconstructs_from_deltas() { - let (mut producer, track) = producer(cfg_deflate(100)); - producer.update(&json!({ "a": 1, "b": 1 })).unwrap(); - producer.update(&json!({ "a": 1, "b": 2 })).unwrap(); - producer.update(&json!({ "a": 5, "b": 2 })).unwrap(); - producer.finish().unwrap(); - - // A consumer created only now rebuilds the final value from the compressed snapshot + deltas. - let values = drain_with(deflate_consumer(track)); - assert_eq!(values.last().unwrap(), &json!({ "a": 5, "b": 2 })); - } - #[test] fn compressed_deltas_roll_on_compressed_budget() { // With compression the budget is measured on compressed frame sizes: `snapshot_len` and diff --git a/rs/moq-json/src/stream/decoder.rs b/rs/moq-json/src/stream/decoder.rs index 288fdbacf40..d836b9a67f6 100644 --- a/rs/moq-json/src/stream/decoder.rs +++ b/rs/moq-json/src/stream/decoder.rs @@ -83,38 +83,12 @@ mod test { .collect() } - #[test] - fn plaintext_roundtrip_in_order() { - let values: Vec = (0..5).map(|n| json!({ "n": n })).collect(); - assert_eq!(roundtrip(false, &values), values); - } - #[test] fn compressed_roundtrip_in_order() { let values: Vec = (0..20).map(|n| json!({ "group": n, "pts": n * 2_000 })).collect(); assert_eq!(roundtrip(true, &values), values); } - #[test] - fn the_shared_window_shrinks_repetitive_records() { - let mut encoder = Encoder::::new(cfg(true)); - let sizes: Vec = (0..8) - .map(|n| { - let record = encoder.encode(&json!({ "group": n, "pts": n * 2_000 })).unwrap(); - let len = record.payload().len(); - record.commit(); - len - }) - .collect(); - - let raw = serde_json::to_vec(&json!({ "group": 7, "pts": 14_000 })).unwrap().len(); - assert!( - *sizes.last().unwrap() < raw / 2, - "windowed record {} should be far below its raw size {raw}", - sizes.last().unwrap() - ); - } - /// A caller that rolls a group has to restart both windows, or the new group's frames decode /// against context the decoder on the other side never received. #[test] diff --git a/rs/moq-json/src/stream/mod.rs b/rs/moq-json/src/stream/mod.rs index 7239ca41db5..7f6a2b3d8f9 100644 --- a/rs/moq-json/src/stream/mod.rs +++ b/rs/moq-json/src/stream/mod.rs @@ -196,19 +196,6 @@ mod test { assert_eq!(size, frame.payload.len()); } - #[test] - fn compressed_roundtrip_in_order() { - let (mut producer, track) = producer(compressed()); - for n in 0..20 { - producer.append(&json!({ "group": n, "pts": n * 2_000 })).unwrap(); - } - producer.finish().unwrap(); - - let records = drain(consume(track, true)); - assert_eq!(records.len(), 20); - assert_eq!(records[7], json!({ "group": 7, "pts": 14_000 })); - } - #[test] fn all_records_ride_one_group() { let (mut producer, mut track) = producer(compressed()); diff --git a/rs/moq-pattern/src/pattern.rs b/rs/moq-pattern/src/pattern.rs index c4b0978d153..3e28bf73d93 100644 --- a/rs/moq-pattern/src/pattern.rs +++ b/rs/moq-pattern/src/pattern.rs @@ -995,16 +995,6 @@ mod tests { ); } - #[test] - fn literal_and_subtree_normalize_paths() { - assert_eq!(Pattern::literal("/foo//bar/").unwrap(), pattern("foo/bar")); - assert_eq!(Pattern::literal("").unwrap(), Pattern::default()); - assert_eq!(Pattern::subtree("foo").unwrap(), pattern("foo/**")); - assert_eq!(Pattern::subtree("/").unwrap(), Pattern::all()); - assert_eq!(Pattern::literal("a/*"), Err(InvalidPattern::InvalidSegment("*".into()))); - assert_eq!(Pattern::literal("**"), Err(InvalidPattern::InvalidSegment("**".into()))); - } - #[test] fn as_prefix_accepts_literals_then_globstar() { assert_eq!(Pattern::all().as_prefix(), Some("")); @@ -1018,184 +1008,6 @@ mod tests { assert_eq!(pattern("foo*/**").as_prefix(), None); } - #[test] - fn matches_whole_segments() { - let cases = [ - ("", "", true), - ("", "a", false), - ("a", "a", true), - ("a", "a/b", false), - ("a", "ab", false), - ("*", "a", true), - ("*", "", false), - ("*", "a/b", false), - ("**", "", true), - ("**", "a/b/c", true), - ("a/**", "a", true), - ("a/**", "a/b/c", true), - ("a/**", "b", false), - ("**/c", "c", true), - ("**/c", "a/b/c", true), - ("**/c", "a/c/b", false), - ("a/**/c", "a/c", true), - ("a/**/c", "a/x/y/c", true), - ("a/**/c", "a", false), - ("a/*/c", "a/x/c", true), - ("a/*/c", "a/c", false), - ("a/*/**", "a", false), - ("a/*/**", "a/b", true), - ("**/transcode.pro", "pid/foo.hang/transcode.pro", true), - ("**/transcode.pro", "pid/foo.transcode.pro", false), - ("**/*.hang", "pid/cam.hang", true), - ("**/*.hang", ".hang", true), - ("**/*.hang", "pid/cam.hang/x", false), - ("foo*", "foo", true), - ("foo*", "foobar", true), - ("foo*", "fo", false), - ("foo.*.hang", "foo..hang", true), - ("foo.*.hang", "foo.1.hang", true), - ("foo.*.hang", "foo.hang", false), - ("a*a", "a", false), - ("a*a", "aa", true), - ]; - for (text, path, expected) in cases { - assert_eq!(pattern(text).matches(path), expected, "{text} vs {path}"); - } - // Paths normalize like broadcast paths. - assert!(pattern("a/b").matches("/a//b/")); - } - - #[test] - fn contains_is_containment() { - let cases = [ - ("**", "**", true), - ("**", "", true), - ("**", "a/*/b", true), - ("", "**", false), - ("*", "a", true), - ("a", "*", false), - ("a/**", "a", true), - ("a/**", "a/b/**", true), - ("a/**", "**", false), - ("a/**", "**/a", false), - ("**/a", "a", true), - ("**/a", "**/b/a", true), - ("**/a", "a/**", false), - ("*/**", "**", false), - ("*/**", "a/**", true), - ("*/*/**", "a/**", false), - ("*/*/**", "a/b/**", true), - ("a/**/c", "a/c", true), - ("a/**/c", "a/x/c", true), - ("a/**/c", "a/**/x/c", true), - ("a/*/**/*", "a/**/b", false), - ("a/*/c", "a/b/c", true), - ("a/*/c", "a/**/c", false), - ("*", "*.hang", true), - ("*.hang", "*", false), - ("*.hang", "cam.hang", true), - ("*.hang", "cam.hang2", false), - ("*.hang", "*.hang", true), - ("*.hang", "cam*.hang", true), - ("*.hang", "cam*hang", false), - ("foo*", "foo.*.hang", true), - ("foo.*", "foo*", false), - ("**/*.hang", "pid/*/cam.hang", true), - ]; - for (outer, inner, expected) in cases { - assert_eq!( - pattern(outer).contains(&pattern(inner)), - expected, - "{outer} contains {inner}" - ); - } - } - - #[test] - fn overlaps_is_symmetric_intersection() { - let cases = [ - ("a", "a", true), - ("a", "b", false), - ("a", "*", true), - ("a", "a/*", false), - ("a/**", "**/b", true), - ("a/**", "b/**", false), - ("a/*", "*/b", true), - ("a/*", "b/*", false), - ("*/*", "a/**", true), - ("*", "a/**", true), - ("*", "a/*/**", false), - ("**", "", true), - ("a/**/b", "**/c", false), - ("a/**/b", "**/*", true), - ("*.hang", "cam*", true), - ("*.hang", "cam.msf", false), - ("*.hang", "*.msf", false), - ("foo*", "foo.bar*", true), - ("foo*", "fob*", false), - ("a*b", "ab", true), - ("ab*", "*ab", true), - ("a/**/b", "x/**", false), - ("a/**/b", "**/x", false), - ]; - for (a, b, expected) in cases { - assert_eq!(pattern(a).overlaps(&pattern(b)), expected, "{a} overlaps {b}"); - assert_eq!(pattern(b).overlaps(&pattern(a)), expected, "{b} overlaps {a}"); - } - } - - #[test] - fn specificity_ranks_by_what_is_pinned_down() { - // Strictly descending. - let ranked = ["a/b/c", "a/b", "a/*.hang", "a/*", "a/**", "*.hang", "*", "**"]; - for pair in ranked.windows(2) { - assert!( - pattern(pair[0]).specificity() > pattern(pair[1]).specificity(), - "{} should outrank {}", - pair[0], - pair[1] - ); - } - // A longer literal head breaks otherwise equal ties. - assert!(pattern("a/**").specificity() > pattern("**/a").specificity()); - // A partial pinning more bytes is more specific than one pinning fewer. - assert!(pattern("cam*.hang").specificity() > pattern("*.hang").specificity()); - assert!(pattern("*.hang").specificity() > pattern("*").specificity()); - // Equal structure is one tier. - assert_eq!(pattern("*/a").specificity(), pattern("*/b").specificity()); - assert_eq!(pattern("*/a/**").specificity(), pattern("*/**/a").specificity()); - } - - #[test] - fn rebase_is_set_valued() { - let cases: &[(&str, &str, &[&str])] = &[ - ("**", "a", &["**"]), - ("**/a", "a", &["", "**/a"]), - ("a/**", "a", &["**"]), - ("a/**", "a/b", &["**"]), - ("a/**", "b", &[]), - ("a/b", "a", &["b"]), - ("a/b", "a/b", &[""]), - ("a/b", "a/b/c", &[]), - ("*/b", "a", &["b"]), - ("a/*/c", "a/x", &["c"]), - ("a/**/b/c", "a/b", &["**/b/c", "c"]), - ("a/**/b", "a/b/b", &["**/b", ""]), - ("**/b/c", "b", &["**/b/c", "c"]), - ("", "", &[""]), - ("", "a", &[]), - ("**", "", &["**"]), - ("*.hang/**", "cam.hang", &["**"]), - ("*.hang/**", "cam.msf", &[]), - ("**/*.hang", "a.hang", &["", "**/*.hang"]), - ]; - for (text, root, expected) in cases { - let got = pattern(text).rebase(root); - let expected: Patterns = expected.iter().map(|e| pattern(e)).collect(); - assert_eq!(got, expected, "{text} rebased at {root}"); - } - } - #[test] fn rooted_inverts_rebase() { assert_eq!(pattern("**").rooted("a/b").unwrap(), pattern("a/b/**")); @@ -1210,20 +1022,6 @@ mod tests { assert_eq!(pattern("b").rooted(&deep), Err(InvalidPattern::TooManySegments)); } - #[test] - fn head_is_the_literal_prefix() { - assert_eq!(pattern("a/b/*/c").head(), "a/b"); - assert_eq!(pattern("**/a").head(), ""); - assert_eq!(pattern("a/b").head(), "a/b"); - assert_eq!(pattern("").head(), ""); - assert_eq!(pattern("a/b*/c").head(), "a"); - assert!(!pattern("a/b*").is_literal()); - assert!(pattern("a/b").is_literal()); - assert!(!pattern("a/*").is_literal()); - assert!(pattern("a/**").has_globstar()); - assert!(!pattern("a/*").has_globstar()); - } - #[cfg(feature = "serde")] #[test] fn serde_round_trips_as_text() { diff --git a/rs/moq-pattern/tests/pattern.json b/rs/moq-pattern/tests/pattern.json index 3603c992e29..4ad6d5a3f64 100644 --- a/rs/moq-pattern/tests/pattern.json +++ b/rs/moq-pattern/tests/pattern.json @@ -270,6 +270,11 @@ "path": "/a/", "expect": true }, + { + "pattern": "a/b", + "path": "/a//b/", + "expect": true + }, { "pattern": "a", "path": "a/b", diff --git a/rs/moq-sock/src/bind.rs b/rs/moq-sock/src/bind.rs index 5b758438b2d..7947d5bdbd4 100644 --- a/rs/moq-sock/src/bind.rs +++ b/rs/moq-sock/src/bind.rs @@ -475,12 +475,6 @@ mod tests { } } - #[test] - fn udp_ipv4_still_binds() { - let socket = udp(Udp::new("127.0.0.1:0".parse().unwrap())).unwrap(); - assert!(socket.local_addr().unwrap().is_ipv4()); - } - /// A reuseport group is only useful if every member can hold the same port, /// so bind a second socket to the first one's address and check it takes. #[test] diff --git a/rs/moq-stats/src/produce.rs b/rs/moq-stats/src/produce.rs index 4f21883c188..34769299624 100644 --- a/rs/moq-stats/src/produce.rs +++ b/rs/moq-stats/src/produce.rs @@ -2165,25 +2165,6 @@ mod tests { assert_eq!(read_last_frame(&stats, "publisher.json").await["foo/bar"].bytes, 30); } - #[tokio::test(start_paused = true)] - async fn single_broadcast_path_announced() { - // No matter how many broadcasts get bumped, exactly one stats - // broadcast is announced (the per-node aggregate). - let (producer, origin) = test_producer(Some("sjc/1")); - - let _f1 = feed(producer.registry(), Tier::default(), "foo/bar", true, 1, 8).await; - let _f2 = feed(producer.registry(), Tier::default(), "baz/qux", true, 1, 8).await; - - assert_eq!(announced(&origin).await.0, ".stats/node/sjc/1"); - } - - #[tokio::test(start_paused = true)] - async fn task_announces_without_node_suffix() { - let (producer, origin) = test_producer(None); - let _f = feed(producer.registry(), Tier::default(), "foo/bar", true, 1, 8).await; - assert_eq!(announced(&origin).await.0, ".stats/node"); - } - #[tokio::test(start_paused = true)] async fn frame_emits_expected_counters() { let (producer, origin) = test_producer(Some("sjc")); From 64d42f8655e3c6aaa80091b2b00c7be04af532b5 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 21 Oct 2026 09:43:00 -0700 Subject: [PATCH 3/6] test: drop low-value tests in the media crates Duplicates, derive and third-party restatements, tautologies and old-bug replays. Co-Authored-By: Claude Opus 5.5 --- rs/hang/src/catalog/root.rs | 15 ------ rs/hang/src/catalog/text/format.rs | 5 -- rs/moq-audio/src/encode/producer.rs | 36 ------------- rs/moq-gst/src/sink/pad.rs | 32 +----------- rs/moq-gst/src/sink/timeline.rs | 8 --- rs/moq-gst/tests/element.rs | 22 -------- rs/moq-hls/src/import.rs | 21 -------- rs/moq-msf/src/lib.rs | 6 --- rs/moq-mux/src/clock.rs | 9 ---- rs/moq-mux/src/codec/h264/mod.rs | 23 --------- rs/moq-mux/src/container/consumer.rs | 40 --------------- rs/moq-mux/src/container/fmp4/export.rs | 19 +------ rs/moq-mux/src/container/fmp4/import_test.rs | 31 ------------ rs/moq-mux/src/container/fmp4/muxer.rs | 32 ------------ rs/moq-mux/src/container/mkv/import_test.rs | 19 ------- rs/moq-mux/src/container/ts/catalog.rs | 8 --- rs/moq-mux/src/container/ts/export_test.rs | 50 ------------------- rs/moq-mux/src/rate.rs | 16 +----- rs/moq-mux/src/select.rs | 8 --- rs/moq-rtc/src/codec/vp9.rs | 29 ----------- rs/moq-rtc/src/session.rs | 10 +--- rs/moq-rtmp/src/rml/handshake/mod.rs | 23 --------- .../src/rml/messages/types/audio_data.rs | 26 ---------- .../src/rml/messages/types/video_data.rs | 26 ---------- rs/moq-rtmp/src/rml/time.rs | 8 --- rs/moq-srt/src/server.rs | 34 ------------- rs/moq-transcode/examples/transcode.rs | 23 --------- rs/moq-video/src/convert.rs | 17 ------- rs/moq-video/src/decode/backend/openh264.rs | 20 -------- rs/moq-video/src/encode/encoder.rs | 33 ------------ rs/moq-video/src/size.rs | 5 -- 31 files changed, 5 insertions(+), 649 deletions(-) diff --git a/rs/hang/src/catalog/root.rs b/rs/hang/src/catalog/root.rs index 4fc866506aa..89a3a5c8292 100644 --- a/rs/hang/src/catalog/root.rs +++ b/rs/hang/src/catalog/root.rs @@ -842,14 +842,6 @@ mod test { assert!(output.contains(r#""magic":7"#), "unknown fields dropped: {output}"); } - #[test] - fn empty_text_section_omitted() { - // A catalog without captions omits the text section, as it does for empty video and audio. - let catalog = Catalog::<()>::default(); - let output = catalog.to_json().expect("failed to encode"); - assert!(!output.contains("text"), "empty text section leaked: {output}"); - } - #[test] fn empty_video_and_audio_sections_omitted() { // A data-only broadcast must not advertise media it does not have. An old publisher's @@ -1038,13 +1030,6 @@ mod test { ); } - #[test] - fn clock_stays_off_the_wire_when_absent() { - // Absent clock stays off the wire. Empty video and audio are omitted as well. - let output = Catalog::<()>::default().to_json().expect("failed to encode"); - assert_eq!(output, "{}"); - } - #[test] fn packaged_clock_fixture_decodes() { // The canonical new shape: the root clock plus an archive without a wall field. diff --git a/rs/hang/src/catalog/text/format.rs b/rs/hang/src/catalog/text/format.rs index 8125fec686c..d2fbadaf96c 100644 --- a/rs/hang/src/catalog/text/format.rs +++ b/rs/hang/src/catalog/text/format.rs @@ -106,11 +106,6 @@ mod tests { assert_eq!(parsed.to_string(), "cea708"); } - #[test] - fn role_default_is_subtitle() { - assert_eq!(TextRole::default(), TextRole::Subtitle); - } - #[test] fn role_roundtrip() { for (s, r) in [("subtitle", TextRole::Subtitle), ("caption", TextRole::Caption)] { diff --git a/rs/moq-audio/src/encode/producer.rs b/rs/moq-audio/src/encode/producer.rs index 471ab8474a7..f26e1844875 100644 --- a/rs/moq-audio/src/encode/producer.rs +++ b/rs/moq-audio/src/encode/producer.rs @@ -1224,42 +1224,6 @@ mod tests { assert_eq!(pts, vec![0, 5_000_000]); } - /// Finish leaves the handle, so abort can still run. - #[tokio::test] - async fn abort_after_finish() { - let mut broadcast = moq_net::broadcast::Info::new().produce(); - let catalog = moq_mux::catalog::Producer::new(&mut broadcast, moq_mux::catalog::Config::default()).unwrap(); - let consumer = broadcast.consume(); - let options = Options { - track: Some("audio".to_string()), - ..Options::default() - }; - let mut producer = Producer::new( - &mut broadcast, - catalog, - Input { - layout: Layout::Mono, - ..Input::default() - }, - &options, - ) - .unwrap(); - let mut track = moq_mux::container::Consumer::new( - consumer - .track("audio") - .unwrap() - .subscribe(moq_net::track::Subscription::default()) - .await - .unwrap(), - moq_mux::container::legacy::Wire(moq_mux::container::Kind::Audio), - ); - - producer.write(&full_frame(0)).unwrap(); - producer.finish().unwrap(); - assert!(packet(&mut track).await.is_some()); - producer.abort(moq_net::Error::Cancel); - } - /// A sub-frame write never reaches the closed track, so the producer must /// refuse it itself rather than buffering samples that cannot be published. #[tokio::test] diff --git a/rs/moq-gst/src/sink/pad.rs b/rs/moq-gst/src/sink/pad.rs index f6723f8f7f9..27a18e70530 100644 --- a/rs/moq-gst/src/sink/pad.rs +++ b/rs/moq-gst/src/sink/pad.rs @@ -1600,20 +1600,6 @@ mod tests { ); } - // An unsupported media type fails the pad rather than the session. - #[test] - fn unsupported_caps_fails_the_pad() { - gst::init().unwrap(); - let (broadcast, catalog) = producers(); - let mut pad = Pad::new(); - pad.observe_caps( - &broadcast, - &catalog, - producer_options(&gst::Caps::builder("video/x-raw").build(), None), - ); - assert!(pad.is_failed()); - } - // An opaque track nobody can name is unfindable: it is absent from the catalog by design, so a // generated name would publish bytes no consumer could ask for. #[test] @@ -1874,6 +1860,7 @@ mod tests { } // A failed pad drops further buffers (and never panics) instead of writing them. + // An unsupported media type fails the pad rather than the session. #[test] fn failed_pad_drops_buffers() { gst::init().unwrap(); @@ -1973,23 +1960,6 @@ mod tests { ); } - // A regressing PTS within an Active timeline still emits: frames arrive in decode order and B-frames - // carry non-monotonic presentation timestamps, so a PTS regression is reordering, not an error. - #[test] - fn regressing_pts_within_an_active_timeline_still_emits() { - gst::init().unwrap(); - let mut pad = Pad::new(); - pad.observe_segment(time_segment_at(0, 0)); - assert_eq!( - pad.frame_timestamp(Some(gst::ClockTime::from_mseconds(10_000))), - Ok(10_000_000) - ); - assert_eq!( - pad.frame_timestamp(Some(gst::ClockTime::from_mseconds(6_000))), - Ok(6_000_000) - ); - } - // Running time is shared, so two pads keep their A/V offset through real segments. #[test] fn two_pads_keep_av_aligned_through_real_segments() { diff --git a/rs/moq-gst/src/sink/timeline.rs b/rs/moq-gst/src/sink/timeline.rs index 87c452835e4..fcfce9b9763 100644 --- a/rs/moq-gst/src/sink/timeline.rs +++ b/rs/moq-gst/src/sink/timeline.rs @@ -110,12 +110,4 @@ mod tests { fn out_of_segment_frame_is_dropped() { assert!(frame_micros(None).is_err()); } - - // frame_micros is a stateless conversion (no last-emitted state, no per-pad anchor). The real - // A/V-offset guarantee is exercised by two_pads_keep_av_aligned_through_real_segments. - #[test] - fn frame_micros_is_stateless() { - assert_eq!(frame_micros(Some(7_000_000)), Ok(7_000)); - assert_eq!(frame_micros(Some(5_000_000)), Ok(5_000)); - } } diff --git a/rs/moq-gst/tests/element.rs b/rs/moq-gst/tests/element.rs index 11b8e6c3b5c..970d76899bc 100644 --- a/rs/moq-gst/tests/element.rs +++ b/rs/moq-gst/tests/element.rs @@ -1466,28 +1466,6 @@ fn a_pad_kept_across_runs_publishes_again() { let _ = sink.set_state(gst::State::Null); } -// Final EOS closes admission only for that run. Returning to READY and starting again must accept a -// new request pad instead of retaining eos_posted from the previous session. -#[test] -fn a_new_run_accepts_pads_again() { - init(); - let sink = publisher(); - let first = sink.request_pad_simple("sink_0").expect("request sink_0"); - sink.set_state(gst::State::Paused).expect("start first run"); - assert!(send_caps(&first)); - assert!(first.send_event(gst::event::Eos::new())); - assert!( - sink.request_pad_simple("sink_1").is_none(), - "the finalized run refuses another pad" - ); - - sink.set_state(gst::State::Ready).expect("stop first run"); - sink.set_state(gst::State::Paused).expect("start second run"); - let second = sink.request_pad_simple("sink_1").expect("the new run accepts sink_1"); - assert_eq!(second.parent(), Some(sink.clone().upcast())); - let _ = sink.set_state(gst::State::Null); -} - // An application polls the status through notify rather than by asking on a timer. #[test] fn status_notifies_on_each_transition() { diff --git a/rs/moq-hls/src/import.rs b/rs/moq-hls/src/import.rs index e7a889bf2a4..579fb9d348b 100644 --- a/rs/moq-hls/src/import.rs +++ b/rs/moq-hls/src/import.rs @@ -1153,13 +1153,6 @@ mod tests { } } - #[test] - fn hls_config_new_sets_fields() { - let url = Url::parse("https://example.com/stream.m3u8").unwrap(); - let cfg = Config::new(url.clone()); - assert_eq!(cfg.playlist, url); - } - #[test] fn select_variants_handles_audio_first_codecs() { // CODECS lists the audio codec first; the video codec must still be found. @@ -1331,20 +1324,6 @@ mod tests { assert!(matches!(err, Error::MissingByteRangeOffset { .. })); } - #[test] - fn ranged_resource_builds_http_range_request() { - let url = Url::parse("https://example.com/media.mp4").unwrap(); - let request = fetcher() - .request(&Resource { - url, - range: Some(ResolvedRange { start: 2, length: 3 }), - }) - .build() - .unwrap(); - - assert_eq!(request.headers()[reqwest::header::RANGE], "bytes=2-4"); - } - #[tokio::test] async fn ranged_http_resource_accepts_matching_partial_response() { let (url, server) = serve_response("206 Partial Content", &[("Content-Range", "bytes 2-4/6")], b"cde").await; diff --git a/rs/moq-msf/src/lib.rs b/rs/moq-msf/src/lib.rs index d335f486ae6..ac2f09511c8 100644 --- a/rs/moq-msf/src/lib.rs +++ b/rs/moq-msf/src/lib.rs @@ -931,12 +931,6 @@ mod test { assert_eq!(value["version"], serde_json::json!("draft-01")); } - #[test] - fn draft01_string_version_decodes() { - let catalog = Catalog::<()>::from_str(r#"{"version":"draft-01","tracks":[]}"#).unwrap(); - assert!(catalog.tracks.is_empty()); - } - #[test] fn unknown_version_string_is_accepted() { // A future draft we don't specifically recognize still decodes; we don't diff --git a/rs/moq-mux/src/clock.rs b/rs/moq-mux/src/clock.rs index 1a237b14782..a89db2d210d 100644 --- a/rs/moq-mux/src/clock.rs +++ b/rs/moq-mux/src/clock.rs @@ -278,15 +278,6 @@ mod tests { moq_net::Timestamp::from_micros(v).unwrap() } - #[test] - fn copies_share_one_epoch() { - let clock = Clock::at(epoch(), moq_epoch() + Duration::from_secs(1)).unwrap(); - let shared = clock; - // Compare the anchors, not live readings: two `now()` calls race the clock. - assert_eq!(clock.instant, shared.instant); - assert_eq!(clock.wall(), shared.wall()); - } - /// A capture maps onto the clock's own timeline, and one ahead of now or before the epoch is /// refused rather than clamped. #[moq_clock::test] diff --git a/rs/moq-mux/src/codec/h264/mod.rs b/rs/moq-mux/src/codec/h264/mod.rs index f318fc0ecb0..0164802f6ed 100644 --- a/rs/moq-mux/src/codec/h264/mod.rs +++ b/rs/moq-mux/src/codec/h264/mod.rs @@ -1098,29 +1098,6 @@ mod tests { assert_eq!(out.as_ref(), expected.as_ref()); } - #[test] - fn avc3_export_e2e_payload_shape() { - // Mirror the byte shapes used by the export integration test so any - // divergence surfaces here in isolation. - let sps = &[0x67u8, 0x42, 0xc0, 0x1f, 0xde, 0xad, 0xbe, 0xef][..]; - let pps = &[0x68u8, 0xce, 0x3c, 0x80][..]; - let idr = &[0x65u8, 0x88, 0x84, 0x21, 0x00, 0x11, 0x22, 0x33][..]; - let pslice = &[0x61u8, 0xe0, 0x12, 0x34][..]; - - let mut tx = Avc1::new(); - let key = annexb_frame(&[sps, pps, idr]); - let key_out = tx.transform(key).expect("transform key").expect("output"); - assert!(tx.avcc().is_some()); - - assert_eq!(key_out.len(), 4 + idr.len()); - assert_eq!(&key_out[4..], idr); - - let p = annexb_frame(&[pslice]); - let p_out = tx.transform(p).expect("transform p").expect("output"); - assert_eq!(p_out.len(), 4 + pslice.len()); - assert_eq!(&p_out[4..], pslice); - } - fn decode_avcc(bytes: &Bytes) -> mp4_atom::Avcc { use mp4_atom::Atom; mp4_atom::Avcc::decode_body(&mut std::io::Cursor::new(bytes.as_ref())).unwrap() diff --git a/rs/moq-mux/src/container/consumer.rs b/rs/moq-mux/src/container/consumer.rs index 9b7c547e9df..6eab6128fc5 100644 --- a/rs/moq-mux/src/container/consumer.rs +++ b/rs/moq-mux/src/container/consumer.rs @@ -2228,25 +2228,6 @@ mod tests { assert_eq!(frames[1].timestamp, ts(30_000)); } - // ---- B-frames ---- - - #[tokio::test] - async fn bframes_within_group() { - let mut track = track_producer("test", hang::container::track_info(hang::catalog::PRIORITY.video)); - let consumer_track = - track.subscribe(moq_net::track::Subscription::default().with_max_delay(Duration::from_millis(500))); - let mut consumer = Consumer::new(consumer_track, Container::Legacy(crate::container::Kind::Data)); - - write_group(&mut track, 0, &[ts(0), ts(66_000), ts(33_000)]); - track.finish().unwrap(); - - let frames = read_all(&mut consumer).await.unwrap(); - assert_eq!(frames.len(), 3); - assert_eq!(frames[0].timestamp, ts(0)); - assert_eq!(frames[1].timestamp, ts(66_000)); - assert_eq!(frames[2].timestamp, ts(33_000)); - } - // ---- Track Lifecycle ---- #[tokio::test] @@ -2991,27 +2972,6 @@ mod tests { // ---- Frame Decoding ---- - #[tokio::test] - async fn frame_timestamp_and_index_decoding() { - let mut track = track_producer("test", hang::container::track_info(hang::catalog::PRIORITY.video)); - let consumer_track = - track.subscribe(moq_net::track::Subscription::default().with_max_delay(Duration::from_millis(500))); - let mut consumer = Consumer::new(consumer_track, Container::Legacy(crate::container::Kind::Data)); - - write_group(&mut track, 0, &[ts(0), ts(33_333), ts(66_666)]); - track.finish().unwrap(); - - let frames = read_all(&mut consumer).await.unwrap(); - assert_eq!(frames.len(), 3); - - assert_eq!(frames[0].timestamp, ts(0)); - assert!(frames[0].keyframe); - - assert_eq!(frames[1].timestamp, ts(33_333)); - - assert_eq!(frames[2].timestamp, ts(66_666)); - } - #[tokio::test] async fn frame_payload_preserved() { let track = track_producer("test", hang::container::track_info(hang::catalog::PRIORITY.video)); diff --git a/rs/moq-mux/src/container/fmp4/export.rs b/rs/moq-mux/src/container/fmp4/export.rs index f7356f20438..8acdfc7f366 100644 --- a/rs/moq-mux/src/container/fmp4/export.rs +++ b/rs/moq-mux/src/container/fmp4/export.rs @@ -1282,6 +1282,8 @@ mod tests { ); } + /// The duration cap splits a GOP across fragments, so the successor is a delta frame + /// in the SAME group. That one is a real bound and is still used. #[test] fn infer_trailing_duration_from_successor_frame() { let successor = frame(83_334, None); @@ -1353,23 +1355,6 @@ mod tests { assert_eq!(duration_micros(&frames[2]), 21_000, "nothing after it at all"); } - /// The duration cap splits a GOP across fragments, so the successor is a delta frame - /// in the SAME group. That one is a real bound and is still used. - #[test] - fn infer_crosses_a_mid_group_fragment_boundary() { - let successor = frame(83_334, None); - let mut frames = vec![frame(41_667, None)]; - infer_missing_durations( - &mut frames, - Some(&successor), - Duration::from_millis(33), - moq_net::Timescale::MICRO, - ) - .unwrap(); - - assert_eq!(frames[0].duration, Some(ts(41_667))); - } - /// The HLS fetch origin concatenates a segment's groups, and for audio those are often /// one packet each -- so EVERY packet sits at a boundary and none of them may be timed /// by the next. Opus states its own duration, which is what keeps that exact instead of diff --git a/rs/moq-mux/src/container/fmp4/import_test.rs b/rs/moq-mux/src/container/fmp4/import_test.rs index a4500da0bee..daf3ab1c842 100644 --- a/rs/moq-mux/src/container/fmp4/import_test.rs +++ b/rs/moq-mux/src/container/fmp4/import_test.rs @@ -881,37 +881,6 @@ fn decode_rejects_durationless_multisample() { assert!(matches!(err, super::Error::MissingSampleDuration), "got {err:?}"); } -/// A single-sample fragment needs no duration (nothing follows it), so it still decodes. -#[test] -fn decode_single_sample_no_duration_ok() { - let frag = super::encode_fragment(info(1, scale(), 0), &[sample(0, true, None)]).unwrap(); - let out = super::decode( - frag, - None, - super::Track::new(scale(), crate::container::fmp4::Kind::Video), - ) - .unwrap(); - assert_eq!(out.len(), 1); - assert_eq!(out[0].timestamp.as_micros(), 0); -} - -/// With the durations the producer now backfills, every sample's DTS round-trips -/// through a multi-sample fragment. -#[test] -fn decode_multisample_with_durations_roundtrips() { - let frames = vec![sample(0, true, Some(33_000)), sample(33_000, false, Some(33_000))]; - let frag = super::encode_fragment(info(1, scale(), 0), &frames).unwrap(); - let out = super::decode( - frag, - None, - super::Track::new(scale(), crate::container::fmp4::Kind::Video), - ) - .unwrap(); - assert_eq!(out.len(), 2); - assert_eq!(out[0].timestamp.as_micros(), 0); - assert_eq!(out[1].timestamp.as_micros(), 33_000); -} - /// A FLAC track (fLaC sample entry + dfLa STREAMINFO) imports into the catalog with /// rate/channels taken from STREAMINFO (not the 16.16 audio box) and the WebCodecs /// description carried out of band. diff --git a/rs/moq-mux/src/container/fmp4/muxer.rs b/rs/moq-mux/src/container/fmp4/muxer.rs index 39cb8021d07..5a97c897c0c 100644 --- a/rs/moq-mux/src/container/fmp4/muxer.rs +++ b/rs/moq-mux/src/container/fmp4/muxer.rs @@ -790,36 +790,4 @@ mod tests { ); } } - - // A group boundary is never a duration, even when the groups arrived consecutively: the - // publisher may have paused across it (moq-boy runs its PTS on a clock that keeps going - // while the encoder is off), which is what once produced a 2405 second sample. - #[tokio::test] - async fn audio_fragment_does_not_absorb_a_pause() { - use hang::catalog::AudioCodec; - - let config = AudioConfig::new(AudioCodec::Opus, 48_000, 2); - let muxer = Muxer::audio(&config).unwrap(); - - // Two one-packet groups either side of a 40 minute pause, fetched back to back. - let packet = Bytes::from_static(&[0x78, 0x00, 0x00, 0x00]); - let frames: Vec = [63_244, 2_405_070_000] - .into_iter() - .map(|micros| Frame { - payload: packet.clone(), - ..frame(micros, true) - }) - .collect(); - let fragment = muxer.fragment(0, &frames).unwrap(); - - let timescale = moq_net::Timescale::new(48_000).unwrap(); - let decoded = super::super::decode( - fragment, - None, - super::super::Track::new(timescale, crate::container::fmp4::Kind::Video), - ) - .unwrap(); - let first = decoded[0].duration.unwrap().as_micros(); - assert_eq!(first, 20_000, "the pause is a discontinuity, not a 2405 second sample"); - } } diff --git a/rs/moq-mux/src/container/mkv/import_test.rs b/rs/moq-mux/src/container/mkv/import_test.rs index bc4bb9a274c..2a706a74d76 100644 --- a/rs/moq-mux/src/container/mkv/import_test.rs +++ b/rs/moq-mux/src/container/mkv/import_test.rs @@ -744,25 +744,6 @@ fn test_unsupported_codec_skipped() { assert!(matches!(a.codec, AudioCodec::Opus)); } -#[test] -fn test_block_timestamp_scaling() { - // TimestampScale = 1_000_000 ns (1ms). Cluster timestamp = 1000, block rel = 33 - // → 1033 ms = 1_033_000 us. - let data = MkvBuilder::new() - .header("webm") - .segment_start() - .info(1_000_000) - .track_video(1, "V_VP9", 16, 16) - .cluster(1000, || vec![simple_block(1, 33, true, b"f")]) - .segment_end() - .build(); - - // Smoke check: parsing succeeds. Timestamp value itself is internal to the - // container::Producer; the catalog round-trip above already exercises the - // rendition wiring. - let _ = run(&data); -} - /// A rendition must never be advertised when its media producer could not be built. /// /// Publishing the media producer is fallible (it enrolls the track in the broadcast timeline, minting the diff --git a/rs/moq-mux/src/container/ts/catalog.rs b/rs/moq-mux/src/container/ts/catalog.rs index 7eeb043081d..63cfff2eab5 100644 --- a/rs/moq-mux/src/container/ts/catalog.rs +++ b/rs/moq-mux/src/container/ts/catalog.rs @@ -462,14 +462,6 @@ impl Catalog for Ext { mod test { use super::*; - #[test] - fn empty_section_omitted() { - // An empty `mpegts` section serializes to `{}` so a media-only broadcast stays - // byte-identical to one without the extension. - let ext = Ext::default(); - assert_eq!(serde_json::to_string(&ext).unwrap(), "{}"); - } - #[test] fn mux_rate_alone_is_not_empty() { // The rate is the only field of a media-only CBR source, so it must keep the diff --git a/rs/moq-mux/src/container/ts/export_test.rs b/rs/moq-mux/src/container/ts/export_test.rs index eddf7e573b4..09f26247d91 100644 --- a/rs/moq-mux/src/container/ts/export_test.rs +++ b/rs/moq-mux/src/container/ts/export_test.rs @@ -680,56 +680,6 @@ fn reassemble_video(ts: &[u8], expected_stream_type: StreamType) -> Vec { reassembled } -/// In-band avc3: SPS/PPS are inline in the bitstream. ExportSource strips them -/// into a synthesized avcC, and the muxer re-injects them on the keyframe. -#[tokio::test(start_paused = true)] -async fn export_avc3_in_band_reassembles() { - let mut broadcast = moq_net::broadcast::Info::new().produce(); - let consumer = broadcast.consume(); - let mut catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap(); - - let track = broadcast - .create_track( - broadcast.unique_name(".avc3"), - hang::container::track_info(hang::catalog::PRIORITY.video), - ) - .unwrap(); - let name = track.name().to_string(); - { - let mut cfg = VideoConfig::new(H264 { - profile: 0x64, - constraints: 0, - level: 0x1f, - inline: true, - }); - cfg.container = Container::Legacy; - catalog.modify().unwrap().video.renditions.insert(name.clone(), cfg); - } - let mut producer = Producer::new(track, HangContainer::Legacy(crate::container::Kind::Data)); - - // IDR slice (NAL type 5), padded past 184 bytes to span multiple TS packets. - let mut idr = vec![0x65u8]; - idr.extend(std::iter::repeat_n(0xAB, 300)); - // Annex-B keyframe: inline SPS + PPS + IDR. - producer - .write(Frame { - timestamp: Timestamp::from_micros(0).unwrap(), - duration: None, - payload: annexb(&[SPS, PPS, &idr]), - keyframe: true, - }) - .unwrap(); - producer.finish().unwrap(); - - // Keep the producers alive (see `export_aac_roundtrip`). - let ts = drain(consumer).await; - assert_packet_aligned(&ts); - - let reassembled = reassemble_video(&ts, StreamType::H264); - // The parameter sets the muxer re-injected, followed by the slice, all Annex-B. - assert_eq!(reassembled.as_slice(), annexb(&[SPS, PPS, &idr]).as_ref()); -} - /// In-band avc3 carrying two distinct PPS (a real broadcast trait): both must /// survive the round-trip, or slices referencing the dropped one stop decoding /// (regression for non-existing PPS 0 referenced). diff --git a/rs/moq-mux/src/rate.rs b/rs/moq-mux/src/rate.rs index f5744652424..eb3b88115a8 100644 --- a/rs/moq-mux/src/rate.rs +++ b/rs/moq-mux/src/rate.rs @@ -243,20 +243,6 @@ mod tests { assert_eq!(raised, bps(1_250_000)); } - #[test] - fn raise_eventually_reaches_the_estimate() { - let mut control = control(); - let start = moq_clock::now(); - control.update(Some(bps(1_000_000)), start).unwrap(); // target 1M - - // Feed a steady healthy estimate every 100ms; the ramp should walk the - // target back up to the ceiling and then stop. - for tick in 1..=200 { - control.update(Some(bps(4_000_000)), start + Duration::from_millis(100 * tick)); - } - assert_eq!(control.target(), bps(4_000_000)); - } - /// Regression: the ramp allowance per tick (25%/s * 100ms = 2.5%) is smaller /// than the hysteresis threshold (5%), so a raise is suppressed on any single /// tick. Suppression must not reset the ramp anchor, or the allowance would be @@ -286,7 +272,7 @@ mod tests { /// Regression: the ramp stops growing `next` once it reaches the ceiling, so a /// target that lands within the 5% deadband of it has no move left that can /// clear hysteresis. Without the exemption for a raise that reaches `desired`, - /// the walk above stalls at 3_866_256 and the sender never returns to the + /// the walk below stalls at 3_866_256 and the sender never returns to the /// bitrate it was configured with. #[test] fn a_raise_reaching_the_ceiling_beats_hysteresis() { diff --git a/rs/moq-mux/src/select.rs b/rs/moq-mux/src/select.rs index c1016506986..c8421052eef 100644 --- a/rs/moq-mux/src/select.rs +++ b/rs/moq-mux/src/select.rs @@ -197,14 +197,6 @@ mod tests { assert!(catalog.audio.renditions.is_empty()); } - #[test] - fn video_only_drops_audio() { - let mut catalog = catalog(vec![h264("v")], vec![opus("a")]); - Broadcast::default().video(Video::default()).retain(&mut catalog); - assert_eq!(video_names(&catalog), vec!["v"]); - assert!(catalog.audio.renditions.is_empty()); - } - #[test] fn name_matches_exact() { let mut catalog = catalog(vec![h264("lo"), h264("hi")], vec![]); diff --git a/rs/moq-rtc/src/codec/vp9.rs b/rs/moq-rtc/src/codec/vp9.rs index e70dae9828e..93b81e2c84c 100644 --- a/rs/moq-rtc/src/codec/vp9.rs +++ b/rs/moq-rtc/src/codec/vp9.rs @@ -29,32 +29,3 @@ impl codec::Bridge for Bridge { self.import.abort(err); } } - -#[cfg(test)] -mod tests { - use bytes::Bytes; - - use crate::codec::{self, Bridge as _}; - - #[test] - fn keyframe_publishes_catalog_dimensions() { - let mut broadcast = moq_net::broadcast::Info::new().produce(); - let catalog = moq_mux::catalog::Producer::new(&mut broadcast, moq_mux::catalog::Config::default()).unwrap(); - let mut bridge = super::Bridge::new(broadcast, catalog.clone()).unwrap(); - - assert!(catalog.snapshot().video.renditions.is_empty()); - - // VP9 profile 0 keyframe header for 320x240. - bridge - .push(codec::Frame { - timestamp_us: 0, - payload: Bytes::from_static(&[0x82, 0x49, 0x83, 0x42, 0x20, 0x13, 0xf0, 0x0e, 0xf0, 0x00]), - }) - .unwrap(); - - let snapshot = catalog.snapshot(); - let config = snapshot.video.renditions.values().next().unwrap(); - assert_eq!(config.coded_width, Some(320)); - assert_eq!(config.coded_height, Some(240)); - } -} diff --git a/rs/moq-rtc/src/session.rs b/rs/moq-rtc/src/session.rs index 2321a8e2d35..e1b90ad4d3e 100644 --- a/rs/moq-rtc/src/session.rs +++ b/rs/moq-rtc/src/session.rs @@ -616,20 +616,12 @@ mod tests { assert!(advertised_candidates(&advertised, local).is_err()); } - #[test] - fn ingest_clock_rebases_first_frame_to_zero() { - let mut clock = IngestClock::default(); - let mid = Mid::from("0"); - let t0 = Instant::now(); - // Raw RTP base is a large random value; the first frame must map to 0. - assert_eq!(clock.normalize(mid, t0, 5_000_000_000), 0); - } - #[test] fn ingest_clock_tracks_rtp_delta_within_track() { let mut clock = IngestClock::default(); let mid = Mid::from("0"); let t0 = Instant::now(); + // Raw RTP base is a large random value; the first frame must map to 0. assert_eq!(clock.normalize(mid, t0, 5_000_000_000), 0); // A later frame advances by the RTP delta, not by arrival jitter. let arrival = t0 + Duration::from_millis(17); // jittered arrival, ignored after anchor diff --git a/rs/moq-rtmp/src/rml/handshake/mod.rs b/rs/moq-rtmp/src/rml/handshake/mod.rs index 0a97e654282..d61b8448a57 100644 --- a/rs/moq-rtmp/src/rml/handshake/mod.rs +++ b/rs/moq-rtmp/src/rml/handshake/mod.rs @@ -644,13 +644,6 @@ mod tests { 0x77_u8, 0x17_u8, 0xd9_u8, 0x34_u8, 0x5a_u8, 0x09_u8, 0xd2_u8, 0x8c_u8, 0xfc_u8, 0x6e_u8, 0x39_u8, 0x59_u8, ]; - #[test] - fn can_start_client_handshake() { - let handshake = Handshake::new(PeerType::Server); - - assert_eq!(handshake.current_stage, Stage::NeedToSendP0AndP1); - } - #[test] fn bad_version_if_first_byte_is_not_a_3() { let mut handshake = Handshake::new(PeerType::Server); @@ -829,22 +822,6 @@ mod tests { assert_eq!(&expected[..], &hmac[..]); } - #[test] - fn hmac_test3() { - let mut mac = Hmac::::new_from_slice(&[0x0b; 20]).unwrap(); - mac.update(b"Hi There"); - - let expected = [ - 176_u8, 52_u8, 76_u8, 97_u8, 216_u8, 219_u8, 56_u8, 83_u8, 92_u8, 168_u8, 175_u8, 206_u8, 175_u8, 11_u8, - 241_u8, 43_u8, 136_u8, 29_u8, 194_u8, 0_u8, 201_u8, 131_u8, 61_u8, 167_u8, 38_u8, 233_u8, 55_u8, 108_u8, - 46_u8, 50_u8, 207_u8, 247_u8, - ]; - - let result = mac.finalize(); - let code_bytes = result.into_bytes(); - assert_eq!(&expected[..], &code_bytes[..]); - } - #[test] fn can_get_digest_from_c1() { match get_digest_for_received_packet(&JWPLAYER_C1, &(GENUINE_FP_CONST.as_bytes())) { diff --git a/rs/moq-rtmp/src/rml/messages/types/audio_data.rs b/rs/moq-rtmp/src/rml/messages/types/audio_data.rs index bcd40f73379..acd061461f8 100644 --- a/rs/moq-rtmp/src/rml/messages/types/audio_data.rs +++ b/rs/moq-rtmp/src/rml/messages/types/audio_data.rs @@ -9,29 +9,3 @@ pub fn serialize(data: Bytes) -> Result { pub fn deserialize(data: Bytes) -> Result { Ok(RtmpMessage::AudioData { data }) } - -#[cfg(test)] -mod tests { - use super::{deserialize, serialize}; - use crate::rml::messages::RtmpMessage; - use bytes::Bytes; - - #[test] - fn can_serialize_message() { - let expected = vec![1, 2, 3, 4]; - let raw_message = serialize(Bytes::from(vec![1, 2, 3, 4])).unwrap(); - - assert_eq!(&raw_message[..], &expected[..]); - } - - #[test] - fn can_deserialize_message() { - let data = Bytes::from(vec![1, 2, 3, 4]); - let expected = RtmpMessage::AudioData { - data: Bytes::from(vec![1, 2, 3, 4]), - }; - let result = deserialize(data).unwrap(); - - assert_eq!(result, expected); - } -} diff --git a/rs/moq-rtmp/src/rml/messages/types/video_data.rs b/rs/moq-rtmp/src/rml/messages/types/video_data.rs index cf534fff972..9eec03da015 100644 --- a/rs/moq-rtmp/src/rml/messages/types/video_data.rs +++ b/rs/moq-rtmp/src/rml/messages/types/video_data.rs @@ -9,29 +9,3 @@ pub fn serialize(bytes: Bytes) -> Result { pub fn deserialize(data: Bytes) -> Result { Ok(RtmpMessage::VideoData { data }) } - -#[cfg(test)] -mod tests { - use super::{deserialize, serialize}; - use crate::rml::messages::RtmpMessage; - use bytes::Bytes; - - #[test] - fn can_serialize_message() { - let expected = vec![1, 2, 3, 4]; - let raw_message = serialize(Bytes::from(vec![1, 2, 3, 4])).unwrap(); - - assert_eq!(&raw_message[..], &expected[..]); - } - - #[test] - fn can_deserialize_message() { - let data = Bytes::from(vec![1, 2, 3, 4]); - let expected = RtmpMessage::VideoData { - data: Bytes::from(vec![1, 2, 3, 4]), - }; - - let result = deserialize(data).unwrap(); - assert_eq!(result, expected); - } -} diff --git a/rs/moq-rtmp/src/rml/time.rs b/rs/moq-rtmp/src/rml/time.rs index 29ed5fc1c79..b61a9ed6958 100644 --- a/rs/moq-rtmp/src/rml/time.rs +++ b/rs/moq-rtmp/src/rml/time.rs @@ -277,12 +277,4 @@ mod tests { assert!(time1 > 20, "time1 was not greater than 20"); assert_eq!(time1, 50, "time1 was not equal to 50"); } - - #[test] - fn can_set_timestamp_value() { - let mut time = RtmpTimestamp::new(50); - time.set(60); - - assert_eq!(time, 60); - } } diff --git a/rs/moq-srt/src/server.rs b/rs/moq-srt/src/server.rs index 450f9028351..28e669896db 100644 --- a/rs/moq-srt/src/server.rs +++ b/rs/moq-srt/src/server.rs @@ -766,40 +766,6 @@ mod tests { } } - /// Regression: a reordered frame paced before the first packet must be clamped up - /// to it, not transmitted with an earlier SRT timestamp. Reproduces the tune-in - /// sequence a looping TS source triggers intermittently: a fast first delivery - /// leaves the anchor at the live edge, then a newer frame re-anchors and an older - /// (reordered) frame paces behind it -- below the first packet, which would - /// underflow the receiver's u32 timestamp and stall in-order delivery after ~one - /// packet. - #[test] - fn reordered_frame_is_clamped_to_the_first_packet() { - use moq_net::Timestamp; - let ms = |m: u64| Timestamp::from_micros(m * 1_000).unwrap(); - - // Drive pace + clamp exactly like `serve_subscribe`, with controlled `now`s so - // the second frame re-anchors (its media outruns wall-clock) and the third is a - // reorder whose media trails the new anchor. - let start = Instant::ZERO + Duration::from_secs(1); - let mut pacer = moq_mux::Pacer::default(); - let mut floor = None; - - // i0: first frame, delivered ~instantly -> stamped at the live edge. - let first = clamp_to_floor(pacer.pace(ms(1_400), start), &mut floor); - // i1: 83ms newer in media, produced ~1ms later -> re-anchors to `now`. - let _ = clamp_to_floor(pacer.pace(ms(1_483), start + Duration::from_millis(1)), &mut floor); - // i2: a reordered B-frame 41ms behind the new anchor. - let unclamped = pacer.pace(ms(1_442), start + Duration::from_millis(2)); - let clamped = clamp_to_floor(unclamped, &mut floor); - - assert!( - unclamped < first, - "the reorder paces before the first packet without the clamp (the bug)" - ); - assert_eq!(clamped, first, "the clamp holds it at the first packet's instant"); - } - /// A reordered (B-frame) timestamp arrives on the same generation, so it must be /// clamped to the first packet rather than re-anchored: treating every backwards /// step as a rewind would drag the whole stream onto the reorder's instant. diff --git a/rs/moq-transcode/examples/transcode.rs b/rs/moq-transcode/examples/transcode.rs index a81a1286d39..2546c1d2d87 100644 --- a/rs/moq-transcode/examples/transcode.rs +++ b/rs/moq-transcode/examples/transcode.rs @@ -95,26 +95,3 @@ async fn main() -> anyhow::Result<()> { res = session.closed() => Ok(res?), } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn parses_defaults() { - let argv = ["transcode", "--source", "input"].map(std::ffi::OsStr::new); - let args = Args::try_parse_from(&argv).unwrap(); - assert_eq!(args.url.as_str(), "http://localhost:4443/anon"); - assert_eq!(args.source, "input"); - assert_eq!(args.output, None); - } - - #[test] - fn rejects_unknown_and_duplicate_flags() { - let unknown = ["transcode", "--source", "input", "--unknown"].map(std::ffi::OsStr::new); - assert!(Args::try_parse_from(&unknown).is_err()); - - let duplicate = ["transcode", "--source", "input", "--source", "other"].map(std::ffi::OsStr::new); - assert!(Args::try_parse_from(&duplicate).is_err()); - } -} diff --git a/rs/moq-video/src/convert.rs b/rs/moq-video/src/convert.rs index 3e960761478..9bb8c00a3b3 100644 --- a/rs/moq-video/src/convert.rs +++ b/rs/moq-video/src/convert.rs @@ -277,21 +277,4 @@ mod tests { ); } } - - /// Converting borrows the surface, so the same one converts twice. - /// - /// The reason this matters is not the second conversion: it is that a - /// caller holding an `Arc` it cannot unwrap, which is every consumer - /// of a publisher's preview, has no way to reach a consuming exit at all. - #[test] - fn conversion_leaves_the_surface_alone() { - let size = Size::new(32, 32); - let surface = Surface::I420(I420::new(size, vec![128; I420::len(size).unwrap()]).unwrap()); - - let first = rgba(&surface, &Config::default()).unwrap(); - let second = bgra(&surface, &Config::default()).unwrap(); - assert_eq!(first.data().len(), second.data().len()); - // And the surface is still there to ask again. - assert_eq!(surface.width(), size.width); - } } diff --git a/rs/moq-video/src/decode/backend/openh264.rs b/rs/moq-video/src/decode/backend/openh264.rs index ca76df3648d..810fac22ec8 100644 --- a/rs/moq-video/src/decode/backend/openh264.rs +++ b/rs/moq-video/src/decode/backend/openh264.rs @@ -419,26 +419,6 @@ mod tests { } } - /// Regression: a stream that reorders used to exhaust openh264's picture pool - /// within a second, because the crate's flush-after-decode released the - /// reordering slot without releasing the picture. Every access unit after - /// that failed with `dsOutOfMemory` until the next keyframe, which a player - /// sees as a picture that appears for a third of a second and then freezes. - #[test] - fn a_stream_with_b_frames_decodes_all_the_way_through() { - let mut decoder = open(); - let mut decoded = 0; - for (index, (payload, keyframe)) in access_units().into_iter().enumerate() { - decoded += decoder - .decode(payload, at(index), keyframe) - .unwrap_or_else(|e| panic!("access unit {index} failed: {e}")) - .len(); - } - decoded += decoder.flush().expect("the drain works").len(); - - assert_eq!(decoded, PICTURES, "the stream lost pictures"); - } - /// A reordered picture carries the timestamp of the access unit it was coded /// in, not of the call it fell out of. The two differ by several frames once /// B slices are in play, so stamping a picture with the call's timestamp diff --git a/rs/moq-video/src/encode/encoder.rs b/rs/moq-video/src/encode/encoder.rs index a90cc0b45e3..ab11316afa1 100644 --- a/rs/moq-video/src/encode/encoder.rs +++ b/rs/moq-video/src/encode/encoder.rs @@ -636,23 +636,6 @@ mod tests { ); } - /// The bring-your-own-pixels path: RGBA in through `Surface::rgba`, Annex-B out. - #[test] - #[cfg(feature = "openh264")] - fn encode_rgba_surface_emits_annexb() { - let config = Config { - kind: Kind::Software, - ..Config::new(320, 240, crate::Rate::new(30, 1).unwrap()) - }; - let mut encoder = Encoder::new(&config).unwrap(); - - let mut frames = encoder.encode(&gray_frame(320, 240, 0)).unwrap(); - frames.extend(encoder.finish().unwrap()); - assert!(!frames.is_empty()); - let packets = payloads(&frames); - assert!(packets[0].starts_with(&[0, 0, 0, 1]) || packets[0].starts_with(&[0, 0, 1])); - } - /// The same path starting from planar I420 the caller already has. #[test] #[cfg(feature = "openh264")] @@ -1075,22 +1058,6 @@ mod tests { assert!(encoder.encode(&gray_frame(320, 240, 1)).is_ok()); } - /// Setting the current rate must not reach the backend at all: the control - /// loop is allowed to be chatty, and the encoder shouldn't pay for it. - #[test] - #[cfg(feature = "openh264")] - fn set_bitrate_to_current_is_a_noop() { - let config = Config { - kind: Kind::Software, - ..Config::new(320, 240, crate::Rate::new(30, 1).unwrap()) - }; - let mut encoder = Encoder::new(&config).unwrap(); - - let opened = encoder.bitrate(); - encoder.set_bitrate(opened).unwrap(); - assert_eq!(encoder.bitrate(), opened); - } - #[test] fn default_bitrate_scales_with_resolution() { let small = Config::new(320, 240, crate::Rate::new(30, 1).unwrap()).resolved_bitrate(); diff --git a/rs/moq-video/src/size.rs b/rs/moq-video/src/size.rs index 591fe897104..1633c087a5f 100644 --- a/rs/moq-video/src/size.rs +++ b/rs/moq-video/src/size.rs @@ -133,9 +133,4 @@ mod tests { .is_err() ); } - - #[test] - fn display_reads_as_a_resolution() { - assert_eq!(Size::new(1920, 1080).to_string(), "1920x1080"); - } } From ef75bdc77cbcd457b802db7e348fc04bfd2ec934 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 21 Oct 2026 10:02:09 -0700 Subject: [PATCH 4/6] test: drop trivial constant and getter tests Constants and defaults restated as literals, constructors read back, fixed-string round trips, and asserts that restate the implementation line for line. Co-Authored-By: Claude Opus 5.5 --- rs/hang/src/catalog/audio/codec.rs | 33 -------------------- rs/hang/src/catalog/audio/mod.rs | 11 ------- rs/hang/src/catalog/mode.rs | 15 --------- rs/hang/src/catalog/priority.rs | 13 -------- rs/hang/src/catalog/text/format.rs | 20 ------------ rs/hang/src/catalog/video/codec.rs | 15 --------- rs/hang/src/catalog/video/mod.rs | 11 ------- rs/hang/src/container/frame.rs | 23 -------------- rs/hang/src/snapshot.rs | 1 - rs/hang/src/timeline.rs | 5 --- rs/moq-audio/src/encode/encoder.rs | 20 ------------ rs/moq-auth/src/set.rs | 12 -------- rs/moq-bench/src/config.rs | 20 +----------- rs/moq-bench/src/host.rs | 5 ++- rs/moq-ffi/src/ffi.rs | 7 ----- rs/moq-ffi/src/video.rs | 8 ----- rs/moq-hls/src/error.rs | 9 ------ rs/moq-hls/src/import.rs | 12 -------- rs/moq-mux/src/catalog/tracks.rs | 18 ----------- rs/moq-mux/src/codec/vp9/mod.rs | 19 ------------ rs/moq-mux/src/container/consumer.rs | 12 -------- rs/moq-mux/src/container/ts/stats.rs | 5 ++- rs/moq-mux/src/rate.rs | 5 --- rs/moq-net/src/error.rs | 33 +------------------- rs/moq-net/src/ietf/cluster.rs | 10 ++---- rs/moq-net/src/ietf/epoch.rs | 4 +-- rs/moq-net/src/ietf/subscribe_namespace.rs | 7 ----- rs/moq-net/src/lite/setup.rs | 10 ------ rs/moq-net/src/model/cache.rs | 12 -------- rs/moq-net/src/model/origin.rs | 7 ----- rs/moq-net/src/model/time.rs | 8 ----- rs/moq-nvenc/src/safe/session.rs | 8 ----- rs/moq-relay/src/auth.rs | 5 ++- rs/moq-srt/src/server.rs | 11 ------- rs/moq-tokio/src/client.rs | 21 ------------- rs/moq-tokio/src/connection.rs | 9 ------ rs/moq-tokio/src/listen.rs | 11 ------- rs/moq-tokio/src/quic.rs | 36 ---------------------- rs/moq-tokio/src/server.rs | 10 ------ rs/moq-tokio/src/unix.rs | 8 ----- rs/moq-transcode/src/ladder.rs | 6 ---- 41 files changed, 11 insertions(+), 504 deletions(-) diff --git a/rs/hang/src/catalog/audio/codec.rs b/rs/hang/src/catalog/audio/codec.rs index 38ad1348ab3..8ade9caae18 100644 --- a/rs/hang/src/catalog/audio/codec.rs +++ b/rs/hang/src/catalog/audio/codec.rs @@ -124,36 +124,3 @@ impl FromStr for AudioCodec { Ok(Self::Unknown(s.to_string())) } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn flac_roundtrip() { - let codec = AudioCodec::from_str("flac").unwrap(); - assert_eq!(codec, AudioCodec::Flac); - assert_eq!(codec.to_string(), "flac"); - assert_eq!(codec.kind(), AudioCodecKind::Flac); - } - - #[test] - fn pcm_roundtrip() { - let codec = AudioCodec::from_str("pcm").unwrap(); - assert_eq!(codec, AudioCodec::Pcm); - assert_eq!(codec.to_string(), "pcm"); - assert_eq!(codec.kind(), AudioCodecKind::Pcm); - } - - #[test] - fn codec_kind_discriminants_are_stable() { - assert_eq!(AudioCodecKind::AAC as isize, 0); - assert_eq!(AudioCodecKind::Opus as isize, 1); - assert_eq!(AudioCodecKind::Unknown as isize, 2); - assert_eq!(AudioCodecKind::Flac as isize, 3); - assert_eq!(AudioCodecKind::Mp3 as isize, 4); - assert_eq!(AudioCodecKind::Pcm as isize, 5); - assert_eq!(AudioCodecKind::Ac3 as isize, 6); - assert_eq!(AudioCodecKind::Ec3 as isize, 7); - } -} diff --git a/rs/hang/src/catalog/audio/mod.rs b/rs/hang/src/catalog/audio/mod.rs index d36c5491c91..e7c1f69ca98 100644 --- a/rs/hang/src/catalog/audio/mod.rs +++ b/rs/hang/src/catalog/audio/mod.rs @@ -291,17 +291,6 @@ mod test { assert_eq!(catalog.enabled().count(), 1); } - #[test] - fn label_round_trips() { - let mut config = AudioConfig::new(AudioCodec::Opus, 48_000, 2); - config.label = Some("English".to_string()); - - let encoded = serde_json::to_value(&config).expect("failed to encode"); - assert_eq!(encoded["label"], "English"); - let decoded: AudioConfig = serde_json::from_value(encoded).expect("failed to decode"); - assert_eq!(decoded.label.as_deref(), Some("English")); - } - #[test] fn enabled_is_written_only_when_false() { let mut config = AudioConfig::new(AudioCodec::Opus, 48_000, 2); diff --git a/rs/hang/src/catalog/mode.rs b/rs/hang/src/catalog/mode.rs index 8f597cda4c6..8c1d49b9b96 100644 --- a/rs/hang/src/catalog/mode.rs +++ b/rs/hang/src/catalog/mode.rs @@ -51,21 +51,6 @@ impl FromStr for Mode { mod test { use super::*; - #[test] - fn known_roundtrip() { - for (mode, json) in [(Mode::Snapshot, r#""snapshot""#), (Mode::Stream, r#""stream""#)] { - let config = crate::catalog::JsonConfig::new(mode.clone()); - let encoded = serde_json::to_value(&config).unwrap(); - assert_eq!(encoded["mode"].to_string(), json); - assert_eq!( - serde_json::from_value::(encoded) - .unwrap() - .mode, - mode - ); - } - } - #[test] fn unknown_roundtrip() { let wire = serde_json::json!({ "mode": "future" }); diff --git a/rs/hang/src/catalog/priority.rs b/rs/hang/src/catalog/priority.rs index ad88b4d9075..d8ba1902ed4 100644 --- a/rs/hang/src/catalog/priority.rs +++ b/rs/hang/src/catalog/priority.rs @@ -24,16 +24,3 @@ pub const PRIORITY: Priorities = Priorities { audio: 80, video: 60, }; - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn media_priorities_match_the_browser() { - assert_eq!(PRIORITY.catalog, 100); - assert_eq!(PRIORITY.text, 90); - assert_eq!(PRIORITY.audio, 80); - assert_eq!(PRIORITY.video, 60); - } -} diff --git a/rs/hang/src/catalog/text/format.rs b/rs/hang/src/catalog/text/format.rs index d2fbadaf96c..cf6ae5395a1 100644 --- a/rs/hang/src/catalog/text/format.rs +++ b/rs/hang/src/catalog/text/format.rs @@ -87,18 +87,6 @@ impl FromStr for TextRole { mod tests { use super::*; - #[test] - fn format_roundtrip() { - for (s, f) in [ - ("vtt", TextFormat::Vtt), - ("ttml", TextFormat::Ttml), - ("utf8", TextFormat::Utf8), - ] { - assert_eq!(TextFormat::from_str(s).unwrap(), f); - assert_eq!(f.to_string(), s); - } - } - #[test] fn format_unknown_preserved() { let parsed = TextFormat::from_str("cea708").unwrap(); @@ -106,14 +94,6 @@ mod tests { assert_eq!(parsed.to_string(), "cea708"); } - #[test] - fn role_roundtrip() { - for (s, r) in [("subtitle", TextRole::Subtitle), ("caption", TextRole::Caption)] { - assert_eq!(TextRole::from_str(s).unwrap(), r); - assert_eq!(r.to_string(), s); - } - } - #[test] fn role_unknown_preserved() { let parsed = TextRole::from_str("commentary").unwrap(); diff --git a/rs/hang/src/catalog/video/codec.rs b/rs/hang/src/catalog/video/codec.rs index f4e65bc7569..b5b746bdbe5 100644 --- a/rs/hang/src/catalog/video/codec.rs +++ b/rs/hang/src/catalog/video/codec.rs @@ -80,18 +80,3 @@ impl FromStr for VideoCodec { Ok(Self::Unknown(s.to_string())) } } - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_vp8() { - let encoded = "vp8"; - let decoded = VideoCodec::from_str(encoded).expect("failed to parse"); - assert_eq!(decoded, VideoCodec::VP8); - - let output = decoded.to_string(); - assert_eq!(output, encoded); - } -} diff --git a/rs/hang/src/catalog/video/mod.rs b/rs/hang/src/catalog/video/mod.rs index 1a4feba1fe9..784bb7378e7 100644 --- a/rs/hang/src/catalog/video/mod.rs +++ b/rs/hang/src/catalog/video/mod.rs @@ -446,17 +446,6 @@ mod test { assert_eq!(catalog.enabled().count(), 1); } - #[test] - fn label_round_trips() { - let mut config = VideoConfig::new(VideoCodec::VP8); - config.label = Some("Main camera".to_string()); - - let encoded = serde_json::to_value(&config).expect("failed to encode"); - assert_eq!(encoded["label"], "Main camera"); - let decoded: VideoConfig = serde_json::from_value(encoded).expect("failed to decode"); - assert_eq!(decoded.label.as_deref(), Some("Main camera")); - } - #[test] fn display_aspect_uses_canonical_json_names() { let mut config = VideoConfig::new(H264 { diff --git a/rs/hang/src/container/frame.rs b/rs/hang/src/container/frame.rs index e03900bf001..62019211256 100644 --- a/rs/hang/src/container/frame.rs +++ b/rs/hang/src/container/frame.rs @@ -160,22 +160,6 @@ mod test { assert_eq!(decoded.timestamp, Timestamp::from_micros(1_234_567).expect("timestamp")); } - /// Publishers stamp the kind's priority, which is what keeps audio ahead of video - /// both on the wire and in `bandwidth::Allocator`. It is a parameter precisely so - /// this can't silently fall back to the undifferentiated default. - #[test] - fn track_info_carries_the_publisher_priority() { - use crate::catalog::PRIORITY; - - assert_eq!(track_info(PRIORITY.video).priority, PRIORITY.video); - assert_eq!(track_info(PRIORITY.audio).priority, PRIORITY.audio); - } - - #[test] - fn track_info_uses_container_timescale() { - assert_eq!(track_info(crate::catalog::PRIORITY.video).timescale, Some(TIMESCALE)); - } - #[test] fn media_tracks_declare_their_retention() { // A media track is read as history (a segmented egress FETCHes segments a playlist @@ -188,11 +172,4 @@ mod test { assert_eq!(at.timescale, Some(Timescale::MILLI)); assert_eq!(at.max_age, Some(MAX_AGE)); } - - #[test] - fn non_media_tracks_keep_the_default_retention() { - // Catalog and timeline metadata impose no publisher age limit; local cache policy - // still controls storage. - assert_eq!(crate::Catalog::default_track_info().max_age, None); - } } diff --git a/rs/hang/src/snapshot.rs b/rs/hang/src/snapshot.rs index c8b1f99cf93..6052ea47e15 100644 --- a/rs/hang/src/snapshot.rs +++ b/rs/hang/src/snapshot.rs @@ -179,7 +179,6 @@ mod tests { assert!(echo::is_echo(&moq_net::Path::new("room/alice.echo"))); assert!(!echo::is_echo(&moq_net::Path::new("room.echo/alice"))); assert!(!echo::is_echo(&moq_net::Path::new("room/alice.echoes"))); - assert_eq!(echo::TRACK, "feedback.json"); } #[test] diff --git a/rs/hang/src/timeline.rs b/rs/hang/src/timeline.rs index 4c0df4dab40..c9c3e53faef 100644 --- a/rs/hang/src/timeline.rs +++ b/rs/hang/src/timeline.rs @@ -269,11 +269,6 @@ mod test { } } - #[test] - fn default_name_appends_the_suffix() { - assert_eq!(default_name("video0"), "video0.timeline.z"); - } - #[test] fn typed_extension_flattens() { // An application extends the record with its own typed section, flattened into the object. diff --git a/rs/moq-audio/src/encode/encoder.rs b/rs/moq-audio/src/encode/encoder.rs index 4788c1eba19..348a002825a 100644 --- a/rs/moq-audio/src/encode/encoder.rs +++ b/rs/moq-audio/src/encode/encoder.rs @@ -901,20 +901,6 @@ mod tests { assert_eq!(enc.bitrate(), original); } - #[test] - fn codec_roundtrips_as_str() { - assert_eq!(Codec::Opus.as_str(), "opus"); - assert_eq!(Codec::Opus.to_string(), "opus"); - assert_eq!("opus".parse::().unwrap(), Codec::Opus); - assert_eq!(Codec::Pcm.as_str(), "pcm"); - assert_eq!(Codec::Pcm.to_string(), "pcm"); - assert_eq!("pcm".parse::().unwrap(), Codec::Pcm); - assert_eq!(Codec::Aac.as_str(), "aac"); - assert_eq!(Codec::Aac.to_string(), "aac"); - assert_eq!("aac".parse::().unwrap(), Codec::Aac); - assert!("mp3".parse::().is_err()); - } - #[test] fn settings_fix_the_codec_rate() { let enc = Encoder::new(&Settings::new(24_000, Layout::Mono)).unwrap(); @@ -1170,10 +1156,4 @@ mod tests { assert_eq!(finish.packets().len(), 3); assert_eq!(finish.discard_padding(), 3 * 1024 - backend::stub::DELAY); } - - /// Opus signals its lookahead as pre-skip, so the producer folds none of it. - #[test] - fn opus_folds_no_delay() { - assert_eq!(Encoder::new(&Settings::default()).unwrap().folded_delay(), 0); - } } diff --git a/rs/moq-auth/src/set.rs b/rs/moq-auth/src/set.rs index 199b3de5c95..19d71f13834 100644 --- a/rs/moq-auth/src/set.rs +++ b/rs/moq-auth/src/set.rs @@ -170,18 +170,6 @@ mod tests { assert!(set.find_key("1").is_some()); } - #[test] - fn test_keyset_to_str() { - let key = create_test_key(Some("1")); - let set = KeySet { - keys: vec![Arc::new(key)], - }; - - let json = set.to_str().unwrap(); - assert!(json.contains("\"keys\"")); - assert!(json.contains("\"kid\":\"1\"")); - } - #[test] fn test_keyset_serde_round_trip() { let key1 = create_test_key(Some("1")); diff --git a/rs/moq-bench/src/config.rs b/rs/moq-bench/src/config.rs index cae111ea1e7..fa0217c9f49 100644 --- a/rs/moq-bench/src/config.rs +++ b/rs/moq-bench/src/config.rs @@ -504,17 +504,8 @@ url = "https://example.com" } #[test] - fn defaults_apply_without_toml() { + fn a_default_run_publishes_without_expecting_delivery() { let config = Config::parse_and_merge(["moq-bench"]).unwrap(); - assert_eq!(config.connections(), Range::new(1, 1)); - assert_eq!(config.broadcasts(), Range::new(1, 1)); - assert_eq!(config.subscribe(), Range::new(0, 0)); - assert_eq!(config.fps(), Range::new(30, 30)); - assert_eq!(config.frame_size(), Range::new(1200, 1200)); - assert_eq!(config.group_size(), Range::new(60, 60)); - assert_eq!(config.max_delay(), Duration::from_secs(2)); - assert_eq!(config.name(), "bench"); - assert_eq!(config.fanout(), None); assert!(!config.expects_delivery()); assert!(config.publishes()); } @@ -567,15 +558,6 @@ url = "https://example.com" } } - /// The spec is named for the binary, not for the struct that declares it. - /// - /// Usage takes the program name from the type unless told otherwise, so an - /// undeclared name renders every usage line and completion as `config`. - #[test] - fn the_spec_is_named_for_the_binary() { - assert_eq!(Config::spec().bin.unwrap_or(Config::spec().name), "moq-bench"); - } - #[test] fn the_settings_registry_matches_the_cli() { let drift = Settings::SETTINGS_REGISTRY.drift(Config::SETTINGS_BINDINGS); diff --git a/rs/moq-bench/src/host.rs b/rs/moq-bench/src/host.rs index e48a45ca0f5..b9985f73eef 100644 --- a/rs/moq-bench/src/host.rs +++ b/rs/moq-bench/src/host.rs @@ -345,9 +345,8 @@ mod linux { let err = usage_rs::render_failure(Args::spec(), &argv, &err); assert!(err.contains("greater than 0s"), "unexpected error: {err}"); - // Nonzero still parses, and the default holds. - let args = Args::parse_from(&[]).unwrap(); - assert_eq!(args.interval, PositiveDuration(Duration::from_secs(1))); + // The default still passes the same check. + Args::parse_from(&[]).unwrap(); } /// A duration shorter than the interval must cap the sleep, not stretch the diff --git a/rs/moq-ffi/src/ffi.rs b/rs/moq-ffi/src/ffi.rs index fc20b92ca1e..7b9bbebefd3 100644 --- a/rs/moq-ffi/src/ffi.rs +++ b/rs/moq-ffi/src/ffi.rs @@ -684,13 +684,6 @@ mod tests { use super::*; - #[test] - fn runtime_uses_parallel_workers() { - let runtime = Runtime::new(false); - assert_eq!(runtime.runtime_flavor(), tokio::runtime::RuntimeFlavor::MultiThread); - runtime.shutdown(); - } - #[test] fn shutdown_joins_a_worker_callback() { let runtime = Arc::new(Runtime::new(false)); diff --git a/rs/moq-ffi/src/video.rs b/rs/moq-ffi/src/video.rs index 064698febc6..9130efee3b2 100644 --- a/rs/moq-ffi/src/video.rs +++ b/rs/moq-ffi/src/video.rs @@ -999,14 +999,6 @@ mod decode_tests { assert!(video_config(config).is_ok()); } - #[test] - fn video_config_round_trips_the_catalog_fields() { - let config = video_config(catalog_video("avc1.64001f")).unwrap(); - assert_eq!(config.coded_width, Some(1280)); - assert_eq!(config.coded_height, Some(720)); - assert_eq!(config.framerate, Some(30.0)); - } - #[test] fn surface_is_refused_where_no_variant_exists() { assert!(matches!(decoder_output(true, false), Err(MoqError::Unsupported))); diff --git a/rs/moq-hls/src/error.rs b/rs/moq-hls/src/error.rs index 5332d48646e..aea371cb853 100644 --- a/rs/moq-hls/src/error.rs +++ b/rs/moq-hls/src/error.rs @@ -181,15 +181,6 @@ pub type Result = std::result::Result; mod tests { use super::*; - /// The import loop consults this, so an origin's settled answer has to reach it intact. - #[test] - fn an_http_failure_reports_its_status() { - // A failure the origin never answered carries no status, so the budget decides instead. - assert_eq!(Error::NoVariants.status(), None); - assert_eq!(Error::ParsePlaylist("not a playlist".to_string()).status(), None); - assert_eq!(Error::Moq(moq_net::Error::Transport("lost".to_string())).status(), None); - } - #[tokio::test] async fn http_error_redacts_url() { // A freed port refuses the connection, so reqwest fails with the dialed URL attached. diff --git a/rs/moq-hls/src/import.rs b/rs/moq-hls/src/import.rs index 579fb9d348b..e9480985dc9 100644 --- a/rs/moq-hls/src/import.rs +++ b/rs/moq-hls/src/import.rs @@ -1186,18 +1186,6 @@ mod tests { assert_eq!(uris, ["large.m3u8", "medium.m3u8", "small.m3u8"]); } - #[test] - fn hls_import_starts_without_tracks() { - let mut broadcast = moq_net::broadcast::Info::new().produce(); - let catalog = CatalogProducer::new(&mut broadcast, moq_mux::catalog::Config::default()).unwrap(); - let url = Url::parse("https://example.com/master.m3u8").unwrap(); - let cfg = Config::new(url); - let hls = Import::new(broadcast, catalog, cfg).unwrap(); - - assert!(hls.video.is_empty()); - assert!(hls.audio.is_none()); - } - /// Joining a live window must start near its edge, not replay the whole thing. #[test] fn first_anchor_joins_near_the_live_edge() { diff --git a/rs/moq-mux/src/catalog/tracks.rs b/rs/moq-mux/src/catalog/tracks.rs index 70d6a478e18..5e1e447eaa6 100644 --- a/rs/moq-mux/src/catalog/tracks.rs +++ b/rs/moq-mux/src/catalog/tracks.rs @@ -942,24 +942,6 @@ mod tests { moq_net::Timestamp::from_micros(micros).unwrap() } - // Legacy and 0 unless selected, and a clone (what an importer is handed) carries the selection. - #[test] - fn a_video_hint_applies_its_container_and_preference_to_every_config() { - let mut config = hang::catalog::VideoConfig::new(hang::catalog::VideoCodec::VP8); - VideoHint::default().apply(&mut config); - assert_eq!(config.container, hang::catalog::Container::Legacy); - assert_eq!(config.preference, 0); - - let hint = VideoHint { - container: hang::catalog::Container::Loc, - preference: -1, - ..Default::default() - }; - hint.apply(&mut config); - assert_eq!(config.container, hang::catalog::Container::Loc); - assert_eq!(config.preference, -1); - } - /// Feed ~40ms 100 kB frames over more than the bitrate window, with a measured /// 40ms container batch span. PTS spacing alone says nothing about flush delay. fn feed>(rendition: &mut Rendition) { diff --git a/rs/moq-mux/src/codec/vp9/mod.rs b/rs/moq-mux/src/codec/vp9/mod.rs index e428c23ef28..bb7c92b0bba 100644 --- a/rs/moq-mux/src/codec/vp9/mod.rs +++ b/rs/moq-mux/src/codec/vp9/mod.rs @@ -359,23 +359,4 @@ mod tests { frame[1] = 0x00; // corrupt the sync code assert!(FrameHeader::parse(&frame).is_err()); } - - #[test] - fn vpcc_round_trips_catalog() { - let vp9 = VP9 { - profile: 2, - level: 31, - bit_depth: 10, - chroma_subsampling: 1, - color_primaries: 9, - transfer_characteristics: 16, - matrix_coefficients: 9, - full_range: true, - }; - let vpcc = vpcc(&vp9); - assert_eq!(vpcc.profile, 2); - assert_eq!(vpcc.bit_depth, 10); - assert_eq!(vpcc.matrix_coefficients, 9); - assert!(vpcc.video_full_range_flag); - } } diff --git a/rs/moq-mux/src/container/consumer.rs b/rs/moq-mux/src/container/consumer.rs index 6eab6128fc5..0938e9ead7c 100644 --- a/rs/moq-mux/src/container/consumer.rs +++ b/rs/moq-mux/src/container/consumer.rs @@ -1099,18 +1099,6 @@ mod tests { // ---- Basic Reading ---- - #[test] - fn new_inherits_the_initial_subscription_latency() { - let track = track_producer("test", hang::container::track_info(hang::catalog::PRIORITY.video)); - let max_delay = Duration::from_millis(250); - let subscriber = track.subscribe(moq_net::track::Subscription::default().with_max_delay(max_delay)); - - let mut consumer = Consumer::new(subscriber, Container::Legacy(crate::container::Kind::Data)); - - assert_eq!(consumer.max_delay, max_delay); - assert_eq!(consumer.subscriber().subscription().max_delay, max_delay); - } - #[tokio::test] async fn read_single_group() { let mut track = track_producer("test", hang::container::track_info(hang::catalog::PRIORITY.video)); diff --git a/rs/moq-mux/src/container/ts/stats.rs b/rs/moq-mux/src/container/ts/stats.rs index a760599e5e4..f86c790ee02 100644 --- a/rs/moq-mux/src/container/ts/stats.rs +++ b/rs/moq-mux/src/container/ts/stats.rs @@ -439,10 +439,9 @@ impl Log { mod test { use super::*; - /// `Class` keeps its `as` values with `Data` last, and an unknown name reads as data. + /// A class a later version adds reads as data. #[test] - fn class_keeps_its_discriminants() { - assert_eq!([Class::Data as u8, Class::Audio as u8, Class::Video as u8], [0, 1, 2]); + fn an_unknown_class_reads_as_data() { let class: Class = serde_json::from_str(r#""subtitle""#).unwrap(); assert_eq!(class, Class::Data); } diff --git a/rs/moq-mux/src/rate.rs b/rs/moq-mux/src/rate.rs index eb3b88115a8..00e2fc9fb83 100644 --- a/rs/moq-mux/src/rate.rs +++ b/rs/moq-mux/src/rate.rs @@ -185,11 +185,6 @@ mod tests { Control::new(Policy::new(bps(4_000_000))) } - #[test] - fn starts_optimistic() { - assert_eq!(control().target(), bps(4_000_000)); - } - #[test] fn drop_applies_immediately() { let mut control = control(); diff --git a/rs/moq-net/src/error.rs b/rs/moq-net/src/error.rs index 50236cead74..07c1e567e33 100644 --- a/rs/moq-net/src/error.rs +++ b/rs/moq-net/src/error.rs @@ -789,19 +789,6 @@ mod tests { ); } - // The moq-transport codes we reuse must keep moq-transport's values. - assert_eq!(SessionError::Unauthorized.to_code(), 0x2); - assert_eq!(SessionError::Expired.to_code(), 0x18); - assert_eq!(SessionError::InvalidRequestId.to_code(), 0x4); - assert_eq!(SessionError::TooManyRequests.to_code(), 0x7); - assert_eq!(SessionError::InvalidPath.to_code(), 0x8); - assert_eq!(SessionError::GoawayTimeout.to_code(), 0x10); - assert_eq!(SessionError::AuthTokenCacheOverflow.to_code(), 0x13); - assert_eq!(SessionError::Version.to_code(), 0x15); - assert_eq!(SessionError::UnknownAuthTokenAlias.to_code(), 0x17); - assert_eq!(SessionError::InvalidAuthority.to_code(), 0x19); - assert_eq!(SessionError::TooManyRequestUpdates.to_code(), 0x1B); - // The reserved 32-47 range, and anything else unregistered, keeps its value instead // of being given a meaning. A peer on the old placeholders (0x20-0x22) lands here. for code in [0x1f, 0x20, 0x21, 0x22, 0x2f, 0x30] { @@ -848,25 +835,7 @@ mod tests { assert_eq!(StreamError::from_code(err.to_code()), err, "{err:?} did not round trip"); } - // moq-lite's own 48-63 range, pinned to the draft's table. - for (err, code) in [ - (StreamError::ControlTimeout, 0x31), - (StreamError::GroupTooLarge, 0x32), - (StreamError::NotFound, 0x33), - (StreamError::Old, 0x34), - (StreamError::Evicted, 0x35), - (StreamError::Unroutable, 0x36), - (StreamError::WrongSize, 0x37), - (StreamError::FrameTooLarge, 0x38), - (StreamError::TimestampMismatch, 0x39), - (StreamError::NotFetchable, 0x3a), - (StreamError::Unauthorized, 0x3b), - ] { - assert_eq!(err.to_code(), code, "{err:?} moved off its assigned code"); - } - - // The reserved 32-47 range carries no meaning, including the values the four - // codes above used to be sent from: a peer still emitting them is not given one. + // The reserved 32-47 range carries no meaning, so a peer emitting it is not given one. for code in 0x20..0x30 { assert_eq!(StreamError::from_code(code), StreamError::Unknown(code)); } diff --git a/rs/moq-net/src/ietf/cluster.rs b/rs/moq-net/src/ietf/cluster.rs index 6af83ec0bc0..0fccddb3906 100644 --- a/rs/moq-net/src/ietf/cluster.rs +++ b/rs/moq-net/src/ietf/cluster.rs @@ -285,14 +285,8 @@ mod tests { } #[test] - fn code_points() { - // The registry values are what other implementations key on; a typo here is - // invisible against ourselves and fatal against anyone else. The parity is - // load-bearing too: odd values are length-prefixed, even ones bare varints. - assert_eq!(HOP_ID, 0x40B54); - assert_eq!(RELAY_COST, 0x40B56); - assert_eq!(HOP_PATH, 0x40B57); - assert_eq!(ROUTE_COST, 0x40B58); + fn code_point_parity() { + // The parity is load-bearing: odd values are length-prefixed, even ones bare varints. assert_eq!(HOP_ID % 2, 0); assert_eq!(RELAY_COST % 2, 0); assert_eq!(HOP_PATH % 2, 1); diff --git a/rs/moq-net/src/ietf/epoch.rs b/rs/moq-net/src/ietf/epoch.rs index d3083e8d848..34f99e994c2 100644 --- a/rs/moq-net/src/ietf/epoch.rs +++ b/rs/moq-net/src/ietf/epoch.rs @@ -59,10 +59,8 @@ mod tests { const VERSION: Version = Version::Draft19; #[test] - fn code_points() { + fn code_point_parity() { // The parity is load-bearing: odd values are length-prefixed, even ones bare varints. - assert_eq!(EPOCH, 0x40B68); - assert_eq!(EPOCH_PARAM, 0x40B69); assert_eq!(EPOCH % 2, 0); assert_eq!(EPOCH_PARAM % 2, 1); } diff --git a/rs/moq-net/src/ietf/subscribe_namespace.rs b/rs/moq-net/src/ietf/subscribe_namespace.rs index 45a317b22a2..8f05b592c65 100644 --- a/rs/moq-net/src/ietf/subscribe_namespace.rs +++ b/rs/moq-net/src/ietf/subscribe_namespace.rs @@ -627,13 +627,6 @@ mod tests { assert!(crate::coding::decode_buf(&mut buf, Version::Draft18, SubscribeNamespace::decode_msg).is_err()); } - #[test] - fn message_ids() { - // 0x11 through draft-17 (legacy), renumbered to 0x50 in draft-18 (#1542). - assert_eq!(SubscribeNamespaceLegacy::ID, 0x11); - assert_eq!(SubscribeNamespace::ID, 0x50); - } - #[test] fn draft18_omits_subscribe_options() { // Draft-18 modern body: Request ID (0x00), empty namespace field-count diff --git a/rs/moq-net/src/lite/setup.rs b/rs/moq-net/src/lite/setup.rs index 52254dd4360..9f0ca1c4ada 100644 --- a/rs/moq-net/src/lite/setup.rs +++ b/rs/moq-net/src/lite/setup.rs @@ -642,16 +642,6 @@ mod tests { assert_eq!(got.probe, ProbeLevel::Increase); } - #[test] - fn role_wire_codes() { - // The draft pins Publisher=1 / Subscriber=2. A swap here would still round-trip - // against our own decoder, but break every other implementation. - for (role, code) in [(Role::Publisher, 1u64), (Role::Subscriber, 2)] { - assert_eq!(role.to_code(), code); - assert_eq!(Role::from_code(code), Some(role)); - } - } - #[test] fn unknown_role_decodes_as_bidirectional() { // A role value the receiver doesn't recognize (a future extension, or an explicit diff --git a/rs/moq-net/src/model/cache.rs b/rs/moq-net/src/model/cache.rs index 74c5f73868c..e3a7cd3a076 100644 --- a/rs/moq-net/src/model/cache.rs +++ b/rs/moq-net/src/model/cache.rs @@ -1355,13 +1355,6 @@ mod test { assert_eq!(pool.used(), 0); } - #[test] - fn config_applies_capacity_and_expiry() { - let pool = bounded(1000); - assert_eq!(pool.capacity(), Some(1000)); - assert_eq!(pool.expiry(), Some(DEFAULT_EXPIRY)); - } - #[test] fn weak_follows_the_last_strong_handle() { let pool = bounded(1000); @@ -1584,11 +1577,6 @@ mod test { assert!(!track.expiry_due(Some(u64::MAX))); } - #[test] - fn standalone_origin_enables_default_expiry() { - assert_eq!(crate::origin::Config::default().pool.expiry(), Some(DEFAULT_EXPIRY)); - } - #[test] fn collecting_before_the_deadline_does_not_postpone_it() { let pool = Pool::new(Config::default().with_expiry(Duration::from_secs(2))); diff --git a/rs/moq-net/src/model/origin.rs b/rs/moq-net/src/model/origin.rs index edff1690e81..04f7f0ab929 100644 --- a/rs/moq-net/src/model/origin.rs +++ b/rs/moq-net/src/model/origin.rs @@ -9283,13 +9283,6 @@ mod tests { announced.expect_next_ended("live").await; } - #[moq_clock::test] - async fn charged_wildcard_cost_accumulates_across_hops() { - let first = Cost::new(4).charged(1); - let second = first.charged(2); - assert_eq!(second, Cost::new(7)); - } - #[moq_clock::test] async fn local_broadcast_is_invisible_until_announced() { let producer = origin(1).produce(); diff --git a/rs/moq-net/src/model/time.rs b/rs/moq-net/src/model/time.rs index 765108bd570..cb406416404 100644 --- a/rs/moq-net/src/model/time.rs +++ b/rs/moq-net/src/model/time.rs @@ -599,14 +599,6 @@ mod tests { assert_eq!(format!("{:?}", t), "1ms"); } - #[test] - fn test_new() { - let t = Timestamp::new(5000, Timescale::MILLI).unwrap(); - assert_eq!(t.value(), 5000); - assert_eq!(t.scale(), Timescale::MILLI); - assert_eq!(t.as_millis(), 5000); - } - #[test] fn test_custom_scale_convert() { // 120 units at 60Hz = 2 seconds, expressed at 1000Hz = 2000 ms. diff --git a/rs/moq-nvenc/src/safe/session.rs b/rs/moq-nvenc/src/safe/session.rs index c16ab3c9fc4..22b84449290 100644 --- a/rs/moq-nvenc/src/safe/session.rs +++ b/rs/moq-nvenc/src/safe/session.rs @@ -631,14 +631,6 @@ mod tests { assert_eq!(*events.lock().unwrap(), ["wait", "abandon"]); } - #[test] - fn session_identity_rejects_cross_session_resources() { - let first = Arc::new(()); - let second = Arc::new(()); - assert!(same_session(&first, &first, &first)); - assert!(!same_session(&first, &second, &first)); - } - /// Whether an NVENC session can run here. Hardware tests return early /// without one, so they pass on GPU-less CI. fn driver_available() -> bool { diff --git a/rs/moq-relay/src/auth.rs b/rs/moq-relay/src/auth.rs index ee7a841e2a9..21ba21d5d6a 100644 --- a/rs/moq-relay/src/auth.rs +++ b/rs/moq-relay/src/auth.rs @@ -1257,12 +1257,11 @@ mod tests { assert!(grant.publish.is_empty()); } - /// The verification concurrency defaults to 128, reads from `[auth]`, and refuses 0, + /// The verification concurrency reads from `[auth]` and refuses 0, /// which would leave every in-band token waiting forever. #[test] - fn verifications_default_and_refuse_zero() { + fn verifications_parse_and_refuse_zero() { let config = config(Some("http://127.0.0.1:4440/"), &[]); - assert_eq!(config.verifications, 128); let parsed: Config = toml::from_str("url = \"http://127.0.0.1:4440/\"\nverifications = 4\n").unwrap(); assert_eq!(parsed.verifications, 4); let zero = Config { diff --git a/rs/moq-srt/src/server.rs b/rs/moq-srt/src/server.rs index 28e669896db..c51096223f1 100644 --- a/rs/moq-srt/src/server.rs +++ b/rs/moq-srt/src/server.rs @@ -675,17 +675,6 @@ mod tests { assert!(host_instant(moq_net::time::now() + Duration::from_millis(100)) > now); } - #[test] - fn send_buffer_uses_standard_srt_window() { - let mut options = SocketOptions::default(); - configure_buffers(&mut options); - - assert_eq!( - options.sender.buffer_size, - SRT_BUFFER_PACKETS * options.session.max_segment_size - ); - } - /// Regression for #2978: a frame that completes a chunk must not re-stamp bytes /// already buffered from an earlier pacing instant. #[test] diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index 6d957c612f2..a0ca66921b6 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -1110,27 +1110,6 @@ mod tests { assert!(err.to_string().contains("--connect / MOQ_CONNECT"), "{err}"); } - #[test] - fn test_toml_failover_delay_is_reported_not_applied() { - let toml = r#" - failover_delay = "1s" - "#; - - let config: crate::connect::Config = toml::from_str(toml).unwrap(); - assert_eq!(config.resolve().race, crate::connect::DEFAULT_RACE); - assert!( - config.deprecated().to_string().contains("failover_delay -> race"), - "{}", - config.deprecated() - ); - } - - #[test] - fn test_cli_failover_delay() { - let config = Cli::config_from(["test", "--connect-race", "50ms"]); - assert_eq!(config.resolve().race, std::time::Duration::from_millis(50)); - } - #[test] fn test_cli_resolution_delay() { let config = Cli::config_from(["test", "--connect-resolution-delay", "0s"]); diff --git a/rs/moq-tokio/src/connection.rs b/rs/moq-tokio/src/connection.rs index 66b3ecd4dcb..f0151307740 100644 --- a/rs/moq-tokio/src/connection.rs +++ b/rs/moq-tokio/src/connection.rs @@ -1958,15 +1958,6 @@ mod tests { assert_eq!(pacing.next(Duration::from_millis(400)), Duration::from_millis(400)); } - #[test] - fn test_backoff_default() { - let backoff = Backoff::default(); - assert_eq!(backoff.initial, Some(Duration::from_secs(1))); - assert_eq!(backoff.multiplier, 2); - assert_eq!(backoff.max, Some(Duration::from_secs(5))); - assert_eq!(backoff.timeout, Some(Duration::from_secs(10))); - } - #[test] fn poll_forward_mirrors_until_the_source_closes() { let src = BandwidthProducer::new(); diff --git a/rs/moq-tokio/src/listen.rs b/rs/moq-tokio/src/listen.rs index eea8aa3acc3..5fe86304b76 100644 --- a/rs/moq-tokio/src/listen.rs +++ b/rs/moq-tokio/src/listen.rs @@ -894,17 +894,6 @@ load_balancer = { id = "ab", nonce = 8 } }; assert_eq!(config.resolved_timeout(), None); } - - /// The canonical spellings, which is what `--help` teaches. - #[test] - fn canonical_spellings_parse() { - let config = config_from(["test", "--listen", "[::]:443", "--listen-version", "moq-lite-03"]); - assert_eq!( - config.bind.as_ref().map(ToString::to_string).as_deref(), - Some("[::]:443") - ); - assert_eq!(config.version, vec!["moq-lite-03".parse::().unwrap()]); - } } #[cfg(test)] diff --git a/rs/moq-tokio/src/quic.rs b/rs/moq-tokio/src/quic.rs index f31ebdeb1a9..c3132ef695d 100644 --- a/rs/moq-tokio/src/quic.rs +++ b/rs/moq-tokio/src/quic.rs @@ -1094,42 +1094,6 @@ mod tests { assert!(at_limit.validate().is_ok(), "{max_streams}"); } } - - #[test] - fn window_flags_parse() { - let quic = parse(&[ - "--quic-receive-window", - "67108864", - "--quic-stream-receive-window", - "8388608", - "--quic-send-window", - "33554432", - ]); - assert_eq!(quic.receive_window, Some(67108864)); - assert_eq!(quic.stream_receive_window, Some(8388608)); - assert_eq!(quic.send_window, Some(33554432)); - } - - #[test] - fn toml_round_trips() { - let toml = r#" - max_streams = 7000 - gso = false - congestion_control = "delay" - receive_window = 67108864 - stream_receive_window = 8388608 - send_window = 33554432 - qlog = "/tmp/qlog" - "#; - let quic: Config = toml::from_str(toml).unwrap(); - assert_eq!(quic.max_streams, Some(7000)); - assert_eq!(quic.gso, Some(false)); - assert_eq!(quic.congestion_control, Some(CongestionControl::Delay)); - assert_eq!(quic.receive_window, Some(67108864)); - assert_eq!(quic.stream_receive_window, Some(8388608)); - assert_eq!(quic.send_window, Some(33554432)); - assert_eq!(quic.qlog.as_deref(), Some(std::path::Path::new("/tmp/qlog"))); - } } #[cfg(test)] diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index 0cb916e091f..b174ef82b16 100644 --- a/rs/moq-tokio/src/server.rs +++ b/rs/moq-tokio/src/server.rs @@ -2948,16 +2948,6 @@ mod tests { assert!(server.accept_health().is_empty()); } - #[test] - fn transport_names_are_stable() { - assert_eq!(Transport::Quic.as_str(), "quic"); - assert_eq!(Transport::Iroh.as_str(), "iroh"); - assert_eq!(Transport::WebSocket.as_str(), "websocket"); - assert_eq!(Transport::Tcp.as_str(), "tcp"); - assert_eq!(Transport::Unix.as_str(), "unix"); - assert_eq!(Transport::WebTransport.as_str(), "webtransport"); - } - /// Building the endpoint needs a runtime, and `certificates()` must stay /// readable without one (no guard escapes to the caller). #[cfg(feature = "quic")] diff --git a/rs/moq-tokio/src/unix.rs b/rs/moq-tokio/src/unix.rs index 9737ad42857..125651c0ceb 100644 --- a/rs/moq-tokio/src/unix.rs +++ b/rs/moq-tokio/src/unix.rs @@ -456,12 +456,4 @@ mod legacy_tests { assert_eq!(config.allow.uid, vec![501]); assert_eq!(config.allow.gid, vec![20]); } - - /// No flag at all leaves the allowlist empty, so the parent directory's - /// permissions stay the only filesystem gate. - #[test] - fn no_allowlist_stays_unset() { - let config = parse(&["--listen-unix-bind", "/tmp/moq.sock"]); - assert!(config.allow.is_empty()); - } } diff --git a/rs/moq-transcode/src/ladder.rs b/rs/moq-transcode/src/ladder.rs index 42d3ee72d46..78efba1d38b 100644 --- a/rs/moq-transcode/src/ladder.rs +++ b/rs/moq-transcode/src/ladder.rs @@ -151,12 +151,6 @@ mod tests { ladder.rungs().iter().map(|rung| rung.size).collect() } - #[test] - fn default_ladder_is_ordered() { - let ladder = Ladder::default(); - assert_eq!(sizes(&ladder), [240, 360, 480, 720, 1080]); - } - /// The operator writes the ladder top-down (or in whatever order), and it /// still resolves to one canonical bottom-up ranking. #[test] From 8617fcf51e1e53c1962119a0e049f88901b6bc93 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 21 Oct 2026 12:04:56 -0700 Subject: [PATCH 5/6] test(moq-net): pin wire code points in one spec table per registry Setup Options, message parameters, message types, roles, and session and stream error codes each check every value against the draft, so a same-parity renumber fails. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/error.rs | 98 +++++++++++----------- rs/moq-net/src/ietf/mod.rs | 36 ++++++++ rs/moq-net/src/ietf/subscribe_namespace.rs | 12 +++ rs/moq-net/src/lite/setup.rs | 10 +++ 4 files changed, 106 insertions(+), 50 deletions(-) diff --git a/rs/moq-net/src/error.rs b/rs/moq-net/src/error.rs index 07c1e567e33..b6dfb3b9790 100644 --- a/rs/moq-net/src/error.rs +++ b/rs/moq-net/src/error.rs @@ -760,33 +760,30 @@ mod tests { #[test] fn session_codes_round_trip() { - // Only the registered codes are a wire contract, so only they round trip. - let registered = [ - SessionError::Cancel, - SessionError::Internal, - SessionError::Unauthorized, - SessionError::Expired, - SessionError::ProtocolViolation, - SessionError::InvalidRequestId, - SessionError::KeyValueFormatting, - SessionError::TooManyRequests, - SessionError::InvalidPath, - SessionError::GoawayTimeout, - SessionError::Timeout, - SessionError::AuthTokenCacheOverflow, - SessionError::Version, - SessionError::UnknownAuthTokenAlias, - SessionError::InvalidAuthority, - SessionError::TooManyRequestUpdates, - SessionError::App(0), - SessionError::App(404), - ]; - for err in registered { - assert_eq!( - SessionError::from_code(err.to_code()), - err, - "{err:?} did not round trip" - ); + // Only the registered codes are a wire contract, so only they round trip, each on + // the value the drafts assign (moq-transport's, where we reuse its code). + for (err, spec) in [ + (SessionError::Cancel, 0x0), + (SessionError::Internal, 0x1), + (SessionError::Unauthorized, 0x2), + (SessionError::ProtocolViolation, 0x3), + (SessionError::InvalidRequestId, 0x4), + (SessionError::KeyValueFormatting, 0x6), + (SessionError::TooManyRequests, 0x7), + (SessionError::InvalidPath, 0x8), + (SessionError::GoawayTimeout, 0x10), + (SessionError::Timeout, 0x11), + (SessionError::AuthTokenCacheOverflow, 0x13), + (SessionError::Version, 0x15), + (SessionError::UnknownAuthTokenAlias, 0x17), + (SessionError::Expired, 0x18), + (SessionError::InvalidAuthority, 0x19), + (SessionError::TooManyRequestUpdates, 0x1B), + (SessionError::App(0), 0x40), + (SessionError::App(404), 0x40 + 404), + ] { + assert_eq!(err.to_code(), spec, "{err:?} moved off its assigned code"); + assert_eq!(SessionError::from_code(spec), err, "{err:?} did not round trip"); } // The reserved 32-47 range, and anything else unregistered, keeps its value instead @@ -810,29 +807,30 @@ mod tests { #[test] fn stream_codes_round_trip() { - // Only the registered codes are a wire contract, so only they round trip. - let registered = [ - StreamError::Internal, - StreamError::Cancel, - StreamError::DeliveryTimeout, - StreamError::ControlTimeout, - StreamError::GoingAway, - StreamError::TooFarBehind, - StreamError::MalformedTrack, - StreamError::GroupTooLarge, - StreamError::NotFound, - StreamError::Old, - StreamError::Evicted, - StreamError::Unroutable, - StreamError::WrongSize, - StreamError::FrameTooLarge, - StreamError::TimestampMismatch, - StreamError::NotFetchable, - StreamError::Unauthorized, - StreamError::App(7), - ]; - for err in registered { - assert_eq!(StreamError::from_code(err.to_code()), err, "{err:?} did not round trip"); + // Only the registered codes are a wire contract, so only they round trip, each on + // the value the draft assigns. + for (err, spec) in [ + (StreamError::Internal, 0x0), + (StreamError::Cancel, 0x1), + (StreamError::DeliveryTimeout, 0x2), + (StreamError::GoingAway, 0x4), + (StreamError::TooFarBehind, 0x5), + (StreamError::MalformedTrack, 0x12), + (StreamError::ControlTimeout, 0x31), + (StreamError::GroupTooLarge, 0x32), + (StreamError::NotFound, 0x33), + (StreamError::Old, 0x34), + (StreamError::Evicted, 0x35), + (StreamError::Unroutable, 0x36), + (StreamError::WrongSize, 0x37), + (StreamError::FrameTooLarge, 0x38), + (StreamError::TimestampMismatch, 0x39), + (StreamError::NotFetchable, 0x3a), + (StreamError::Unauthorized, 0x3b), + (StreamError::App(7), 0x40 + 7), + ] { + assert_eq!(err.to_code(), spec, "{err:?} moved off its assigned code"); + assert_eq!(StreamError::from_code(spec), err, "{err:?} did not round trip"); } // The reserved 32-47 range carries no meaning, so a peer emitting it is not given one. diff --git a/rs/moq-net/src/ietf/mod.rs b/rs/moq-net/src/ietf/mod.rs index 6b08cb6ea84..c057dbafe0b 100644 --- a/rs/moq-net/src/ietf/mod.rs +++ b/rs/moq-net/src/ietf/mod.rs @@ -93,3 +93,39 @@ pub(crate) fn request_history(ids: &[u64]) -> usize { let control = Control::new(None, false); ids.iter().filter(|id| control.accept(RequestId(**id)).is_ok()).count() } + +#[cfg(test)] +mod tests { + use super::*; + + /// Our Setup Options, pinned to the values the extension drafts register. A renumber + /// still round trips against ourselves but breaks every other implementation. + #[test] + fn setup_option_code_points() { + for (name, key, spec) in [ + ("HOP_ID", cluster::HOP_ID, 0x40B54), + ("RELAY_COST", cluster::RELAY_COST, 0x40B56), + ("SOLICIT", solicit::SOLICIT, 0x40B5A), + ("HIDDEN", hidden::HIDDEN, 0x40B5C), + ("AUTH", auth::AUTH, 0x40B60), + ("ACTIVE_COUNT", active_count::ACTIVE_COUNT, 0x40B64), + ("EPOCH", epoch::EPOCH, 0x40B68), + ] { + assert_eq!(key, spec, "{name}"); + } + } + + /// Our message parameters, pinned to the values the extension drafts register. + #[test] + fn message_parameter_code_points() { + for (name, key, spec) in [ + ("HOP_PATH", cluster::HOP_PATH, 0x40B57), + ("ROUTE_COST", cluster::ROUTE_COST, 0x40B58), + ("HIDDEN", hidden::HIDDEN_PARAM, 0x40B5E), + ("ACTIVE_COUNT", active_count::ACTIVE_COUNT_PARAM, 0x40B66), + ("EPOCH", epoch::EPOCH_PARAM, 0x40B69), + ] { + assert_eq!(key, spec, "{name}"); + } + } +} diff --git a/rs/moq-net/src/ietf/subscribe_namespace.rs b/rs/moq-net/src/ietf/subscribe_namespace.rs index 8f05b592c65..b9459b5c30f 100644 --- a/rs/moq-net/src/ietf/subscribe_namespace.rs +++ b/rs/moq-net/src/ietf/subscribe_namespace.rs @@ -627,6 +627,18 @@ mod tests { assert!(crate::coding::decode_buf(&mut buf, Version::Draft18, SubscribeNamespace::decode_msg).is_err()); } + /// SUBSCRIBE_NAMESPACE's message types, pinned to the drafts: 0x11 through draft-17, + /// renumbered to 0x50 in draft-18. + #[test] + fn message_type_code_points() { + for (name, id, spec) in [ + ("SUBSCRIBE_NAMESPACE (draft-17)", SubscribeNamespaceLegacy::ID, 0x11), + ("SUBSCRIBE_NAMESPACE", SubscribeNamespace::ID, 0x50), + ] { + assert_eq!(id, spec, "{name}"); + } + } + #[test] fn draft18_omits_subscribe_options() { // Draft-18 modern body: Request ID (0x00), empty namespace field-count diff --git a/rs/moq-net/src/lite/setup.rs b/rs/moq-net/src/lite/setup.rs index 9f0ca1c4ada..40e7fdba24b 100644 --- a/rs/moq-net/src/lite/setup.rs +++ b/rs/moq-net/src/lite/setup.rs @@ -642,6 +642,16 @@ mod tests { assert_eq!(got.probe, ProbeLevel::Increase); } + /// Roles, pinned to the draft. A swap still round trips against our own decoder but + /// breaks every other implementation. + #[test] + fn role_code_points() { + for (role, spec) in [(Role::Publisher, 1u64), (Role::Subscriber, 2)] { + assert_eq!(role.to_code(), spec, "{role:?}"); + assert_eq!(Role::from_code(spec), Some(role)); + } + } + #[test] fn unknown_role_decodes_as_bidirectional() { // A role value the receiver doesn't recognize (a future extension, or an explicit From ac843a5aa42c2248ed8c9ed12d2e1c9217796147 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 21 Oct 2026 15:53:37 -0700 Subject: [PATCH 6/6] fix(hang): make AudioCodecKind discriminants explicit The deleted discriminant test was the only guard on the append-only as values; explicit discriminants make the type enforce it. Co-Authored-By: Claude Opus 5.5 --- rs/hang/src/catalog/audio/codec.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/rs/hang/src/catalog/audio/codec.rs b/rs/hang/src/catalog/audio/codec.rs index 8ade9caae18..a1361f2fc2d 100644 --- a/rs/hang/src/catalog/audio/codec.rs +++ b/rs/hang/src/catalog/audio/codec.rs @@ -61,25 +61,26 @@ pub enum AudioCodec { } /// Coarse audio codec family, used for tag-only matching. +// Explicit discriminants keep `as` values stable: a new kind takes the next number. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum AudioCodecKind { /// Advanced Audio Coding. - AAC, + AAC = 0, /// Opus. - Opus, + Opus = 1, /// Unknown or unsupported codec. - Unknown, + Unknown = 2, /// Free Lossless Audio Codec. - Flac, + Flac = 3, /// MPEG-1/2 Audio Layer III. - Mp3, + Mp3 = 4, /// Uncompressed interleaved little-endian IEEE-754 binary32 PCM. - Pcm, + Pcm = 5, /// Dolby Digital (AC-3). - Ac3, + Ac3 = 6, /// Dolby Digital Plus (E-AC-3). - Ec3, + Ec3 = 7, } impl AudioCodec {