chat_identity.rs (1211B)
1 #![cfg(feature = "chat")] 2 use radroots_domain::UnixSeconds; 3 use radroots_protocol::{chat::ChatRumor, command::CapturedChatCommand}; 4 use serde_json::Value; 5 6 #[test] 7 fn distinct_operations_with_identical_text_in_one_second_have_distinct_logical_messages() { 8 let vectors: Value = 9 serde_json::from_str(include_str!("fixtures/chat_commands.v1.json")).unwrap(); 10 let mut source: Value = 11 serde_json::from_str(vectors["vectors"][0]["wire"].as_str().unwrap()).unwrap(); 12 let first = CapturedChatCommand::parse(source.to_string().as_bytes()).unwrap(); 13 source["context"]["operation_id"] = "42".repeat(32).into(); 14 let second = CapturedChatCommand::parse(source.to_string().as_bytes()).unwrap(); 15 assert_ne!(first.digest(), second.digest()); 16 let captured = UnixSeconds::new(1_700_000_000).unwrap(); 17 let original = ChatRumor::from_command(&first, captured).unwrap(); 18 let replay = ChatRumor::from_command(&first, captured).unwrap(); 19 let distinct = ChatRumor::from_command(&second, captured).unwrap(); 20 assert_eq!(original.json(), replay.json()); 21 assert_eq!(original.message_id(), replay.message_id()); 22 assert_ne!(original.message_id(), distinct.message_id()); 23 }