test(cli): wait for the listener to be in the room, and keep an early PM

room_listen said its line three seconds after starting the listener and
hoped it had joined by then; a line said before the join never reaches
it. The speaker now waits for the room to announce the listener, which
soulfind only does once it has them in.

message_read sent its message three seconds after starting the reader.
A reader not yet logged in is a name soulfind has never seen, and it
drops a message to such a name. The reader is now registered first, so
a message that beats its login is kept and delivered when it arrives.
This commit is contained in:
Michel de Graaf
2026-09-10 14:35:37 +02:00
parent 8bee7745e1
commit 8854f8d005
+18 -2
View File
@@ -1895,8 +1895,19 @@ fn room_listen_streams_what_is_said_in_the_room() {
.spawn()
.expect("the binary should run");
// Give the listener time to join before saying anything.
std::thread::sleep(Duration::from_secs(3));
// The room announces the listener once the server has it in; a line
// said before that never reaches it.
let deadline = Instant::now() + Duration::from_secs(30);
while !speaker.take_room_events().iter().any(|event| {
matches!(
event,
soulseek_rs::types::RoomEvent::UserJoined { room, username }
if room == "cli_e2e_lobby_b" && username == "cli_e2e_room_reader"
)
}) {
assert!(Instant::now() < deadline, "the listener never joined");
std::thread::sleep(Duration::from_millis(50));
}
speaker
.say_in_room("cli_e2e_lobby_b", "streamed line")
.expect("say");
@@ -1965,6 +1976,11 @@ fn a_private_message_reaches_its_recipient() {
fn message_read_streams_incoming_private_messages() {
let server = server_or_skip!();
let sender = server.client("cli_e2e_pm_sender", Vec::new());
// soulfind drops a message to a name it has never seen but keeps one for
// a known user until they log in, so however long the reader takes to
// get online, the line below reaches it. Registered before the reader's
// own session exists: a later login as them would take its place.
drop(server.client("cli_e2e_pm_reader", Vec::new()));
settle();
let mut args = server.args("cli_e2e_pm_reader");