Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(web_chat): cover typed voice media matching its note reference

Steven Enamakel2e7d23a0fe10
diff --git a/crates/openhuman-core/src/web_chat/voice_notes_tests.rs b/crates/openhuman-core/src/web_chat/voice_notes_tests.rs
index 60d987d88e..e6393746b3 100644
--- a/crates/openhuman-core/src/web_chat/voice_notes_tests.rs
+++ b/crates/openhuman-core/src/web_chat/voice_notes_tests.rs
@@ -97,6 +97,29 @@ fn rpc_round_trip_and_bad_base64() {
assert!(store_from_rpc(tmp.path(), "bad", "audio/webm", "!!!").is_err());
}
+#[test]
+fn typed_voice_media_must_match_its_durable_note_reference() {
+ use base64::Engine as _;
+
+ let tmp = tempfile::tempdir().unwrap();
+ store_note(tmp.path(), "note-typed", "audio/wav", &[0, 1, 2]).unwrap();
+ let media = |note_id: &str, bytes: &[u8]| tinychannels_bus::MediaReference {
+ opaque_id: Some(note_id.into()),
+ url: Some(format!(
+ "data:audio/wav;base64,{}",
+ base64::engine::general_purpose::STANDARD.encode(bytes)
+ )),
+ content_type: Some("audio/wav".into()),
+ kind: tinychannels_bus::MediaKind::Audio,
+ ..Default::default()
+ };
+
+ assert!(validate_typed_media(tmp.path(), "note-typed", &media("note-typed", &[0, 1, 2])).is_ok());
+ assert!(validate_typed_media(tmp.path(), "note-typed", &media("other-note", &[0, 1, 2])).is_err());
+ assert!(validate_typed_media(tmp.path(), "note-typed", &media("note-typed", &[9])).is_err());
+ assert!(validate_typed_media(tmp.path(), "missing", &media("missing", &[0])).is_err());
+}
+
#[test]
fn synthesized_reply_is_stored_only_with_decodable_audio() {
let tmp = tempfile::tempdir().unwrap();