diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdd3961 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Generated and compared byte-for-byte by `daemon::openrpc::document_is_current`, +# which builds its expectation with `\n`. A CRLF checkout would fail that test on +# Windows. +docs/openrpc.json text eol=lf diff --git a/soulseek-rs/tests/daemon_protocol_e2e.rs b/soulseek-rs/tests/daemon_protocol_e2e.rs index cd1fbc4..917f9a1 100644 --- a/soulseek-rs/tests/daemon_protocol_e2e.rs +++ b/soulseek-rs/tests/daemon_protocol_e2e.rs @@ -158,9 +158,21 @@ impl Connection { } /// Send one line and read the reply, `None` if the daemon hung up first. + /// + /// Events share the socket with replies, so a subscribed connection can + /// have a notification land between the request and its answer. Only a + /// reply carries an `id`; skip everything that does not. fn call(&mut self, line: &str) -> Option { self.send(line)?; - self.read() + loop { + let reply = self.read()?; + let is_notification = + serde_json::from_str::(&reply) + .is_ok_and(|parsed| parsed.get("id").is_none()); + if !is_notification { + return Some(reply); + } + } } fn send(&mut self, line: &str) -> Option<()> {