// The phone's audio tables are the CRATE's, held by a by-path read. // // `MeetingAudioFormats` is a twin of two tables — the containers in // `crates/cotton-core/src/media/meeting_audio.rs` and the types the server // signs an upload for in `crates/cotton-rules/src/media.rs` (where the Worker // reads them too, as WASM) — generated in neither direction, and it has to be a twin: the phone decides what a picker OFFERS // and what a share sheet CLAIMS before it copies a byte, and a picker that // showed a container the server signs no upload for is a picker that lied. The // alternative to a twin is finding out three hours later on a train. // // So this reads the Rust files and holds the two Swift tables to them. It is rule // (b) of the by-path guards — `SourceSweep.mustRead` fails loudly naming the // path and the lane, so a file that MOVES reddens here rather than quietly // making the guard cover nothing. @testable import CottonKit @testable import CottonUI import XCTest final class MeetingAudioContractTests: XCTestCase { private static let formatsPath = "crates/cotton-core/src/media/meeting_audio.rs" /// Where `MEETING_AUDIO_TYPES` is declared: the one upload table the phone's /// core and the Worker both read (c891223a14). private static let typesPath = "crates/cotton-rules/src/media.rs" /// What `meetings.create` ANSWERS, written by the Rust test that runs it. private static let answerPath = "crates/cotton-ffi/src/phone/meetings-create-answer.json" /// Every `("ext", "mime")` pair inside one `&[…]` table in the Rust file. private func rustPairs(_ table: String) throws -> [(String, String)] { let source = try SourceSweep.mustRead( Self.formatsPath, ownedBy: "the Rust core (a meeting's audio containers, `media/meeting_audio.rs`)") guard let start = source.range(of: table), // `= &[` and not `[`: the declaration's own TYPE carries brackets // (`&[&str]`, `&[(&str, &str)]`), so the first `[` after the name is // not the table's. let open = source.range(of: "= &[", range: start.upperBound.. [String] { let source = try SourceSweep.mustRead( Self.typesPath, ownedBy: "the Rust rules (what the server signs an upload for, `cotton-rules/src/media.rs`)") guard let start = source.range(of: table), // `= &[` and not `[`: the declaration's own TYPE carries brackets // (`&[&str]`, `&[(&str, &str)]`), so the first `[` after the name is // not the table's. let open = source.range(of: "= &[", range: start.upperBound..