From 362e2b9da1659f1c7884d49e4a73ad7c030e5e2a Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 05:58:27 +0300 Subject: [PATCH] Assert the unique ids and the server's uid in the presence test presence_follows_the_host_until_it_ends showed the clients' names and channels but not what the engine keys contacts and private history by: the unique id of each client (the base32 of a Voelin user's 32 bytes) and the server's unique id in ServerDetails. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/tests/session_fake.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/voelin-core/tests/session_fake.rs b/crates/voelin-core/tests/session_fake.rs index f433382..dd56422 100644 --- a/crates/voelin-core/tests/session_fake.rs +++ b/crates/voelin-core/tests/session_fake.rs @@ -358,6 +358,15 @@ async fn presence_follows_the_host_until_it_ends() { assert_eq!((name.as_str(), info.label().as_str()), ("Fake Host", "Fake 1.2")); // `files` is offered, `mailbox` is not, and no session has streams yet. assert!(caps.file_transfer && !caps.offline_messages && !caps.streams, "{caps:?}"); + // The server's details come with its first presence; its unique id is the + // host's name for it. + let details = h + .next(|e| match e { + Event::ServerDetails { details, .. } => Some(details), + _ => None, + }) + .await; + assert_eq!(details.uid.as_deref(), Some(SERVER_UID)); let shown = h .next(|e| match e { Event::Presence { presence, .. } if presence.clients.len() == 3 => Some(presence), @@ -373,6 +382,11 @@ async fn presence_follows_the_host_until_it_ends() { shown.clients.values().map(|c| (c.id, c.nickname.as_str(), c.channel)).collect(); let (me, alice, bob) = (ME as u16, ALICE as u16, BOB as u16); assert_eq!(clients, [(me, "tester", GAMES), (alice, "alice", GAMES), (bob, "bob", LOBBY)]); + // A Voelin user's unique id is shown as the base32 of its 32 bytes (here the + // user's id, 32 times: `user`). + assert_eq!(h.uid_of(ME), "aeaqcaibaeaqcaibaeaqcaibaeaqcaibaeaqcaibaeaqcaibaeaq"); + assert_eq!(h.uid_of(ALICE), "aibaeaqcaibaeaqcaibaeaqcaibaeaqcaibaeaqcaibaeaqcaiba"); + assert_eq!(h.uid_of(BOB), "ambqgaydambqgaydambqgaydambqgaydambqgaydambqgaydambq"); let state = h.state(|s| s.own_channel == Some(GAMES)).await; assert_eq!(state.voice, VoiceState::Connected); assert_eq!(state.own_client, Some(me));