From 18d229be58e4a407afbf064a4ab6b3851fb6a494 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 31 Jul 2026 22:55:36 -0400 Subject: [PATCH] Match the listener's parameter names; drop commas from test names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Native targets reject a comma inside a backticked name, so five tests that read fine on JVM broke every Kotlin/Native build. Renamed without them. The override parameters now match RelayConnectionListener — pingMillis, compressed, cmdStr, cmd, msg, errorMessage — which silences six warnings and, more to the point, fixes a misreading: onConnected's second and third parameters are the connection's ping and whether it is compressed, and I had them named attempt and success. Both were missed the same way: jvmTest passes without ever compiling the native TEST sources. All five targets now compile, main and test. Co-Authored-By: Claude Opus 5 (1M context) --- .../reachability/RelayObserver.kt | 22 +++++++++---------- .../reachability/RelayObserverTest.kt | 10 ++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip66RelayMonitor/reachability/RelayObserver.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip66RelayMonitor/reachability/RelayObserver.kt index d6e88b8e83..05f869ce32 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip66RelayMonitor/reachability/RelayObserver.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip66RelayMonitor/reachability/RelayObserver.kt @@ -134,8 +134,8 @@ class RelayObserver : RelayConnectionListener { override fun onConnected( relay: IRelayClient, - attempt: Int, - success: Boolean, + pingMillis: Int, + compressed: Boolean, ) { val o = of(relay) o.reachable = true @@ -146,13 +146,13 @@ class RelayObserver : RelayConnectionListener { override fun onCannotConnect( relay: IRelayClient, - error: String, + errorMessage: String, ) { val o = of(relay) // NOT `reachable = false`. A relay that answered an hour ago and is down // now is a different thing from one that never answered at all, and only // the writer decides which record that becomes. - o.error = error.take(MAX_TEXT) + o.error = errorMessage.take(MAX_TEXT) o.touch() } @@ -162,13 +162,13 @@ class RelayObserver : RelayConnectionListener { */ override fun onSent( relay: IRelayClient, - msgStr: String, - command: Command, + cmdStr: String, + cmd: Command, success: Boolean, ) { if (!success) return val o = of(relay) - when (command) { + when (cmd) { is ReqCmd -> if (o.firstReqAt == null) o.firstReqAt = TimeSource.Monotonic.markNow() is EventCmd -> if (o.firstEventAt == null) o.firstEventAt = TimeSource.Monotonic.markNow() else -> Unit @@ -178,10 +178,10 @@ class RelayObserver : RelayConnectionListener { override fun onIncomingMessage( relay: IRelayClient, msgStr: String, - message: Message, + msg: Message, ) { val o = of(relay) - when (message) { + when (msg) { is EoseMessage -> { if (o.rttReadMs == null) { o.firstReqAt?.let { @@ -219,14 +219,14 @@ class RelayObserver : RelayConnectionListener { } is NoticeMessage -> { - val text = message.message.trim().take(NOTICE_KEY) + val text = msg.message.trim().take(NOTICE_KEY) o.notice = text o.touch() if (noticeSamples.size() < MAX_DISTINCT_NOTICES) noticeSamples.merge(text, 1L) { a, b -> a + b } } is ClosedMessage -> { - val reason = prefixOf(message.message) + val reason = prefixOf(msg.message) o.closedReason = reason // NIP-42 refusal, in the shape relays use when the subscription // is what got rejected rather than the connection. diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip66RelayMonitor/reachability/RelayObserverTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip66RelayMonitor/reachability/RelayObserverTest.kt index 65ba639082..f1192871f7 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip66RelayMonitor/reachability/RelayObserverTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip66RelayMonitor/reachability/RelayObserverTest.kt @@ -73,7 +73,7 @@ class RelayObserverTest { // ---- what we measured --------------------------------------------------- @Test - fun `an opened connection is timed, not assumed`() { + fun `an opened connection is timed rather than assumed`() { val o = RelayObserver() o.onConnecting(client(url)) o.onConnected(client(url), 1, true) @@ -156,7 +156,7 @@ class RelayObserverTest { // ---- AUTH, which is why an anonymous crawl finds a relay empty ------------ @Test - fun `a demand for AUTH is recorded, from either shape`() { + fun `a demand for AUTH is recorded from either shape`() { val challenged = RelayObserver() challenged.onIncomingMessage(client(url), "", AuthMessage("challenge")) assertTrue(challenged.only().authRequired) @@ -169,7 +169,7 @@ class RelayObserverTest { } @Test - fun `a CLOSED that is not about auth is categorised, not misread`() { + fun `a CLOSED that is not about auth is categorised rather than misread`() { val o = RelayObserver() o.onIncomingMessage(client(url), "", ClosedMessage("sub", "rate-limited: slow down")) @@ -181,7 +181,7 @@ class RelayObserverTest { // ---- publishing bookkeeping --------------------------------------------- @Test - fun `an unchanged relay is not re-reported, and its measurement survives`() { + fun `an unchanged relay is not re-reported but its measurement survives`() { // Re-writing a record refreshes its freshness window, so a relay nobody // re-measured must be left out. But the measurement itself has to stay: // a long-lived socket fires onConnected once, and if publishing erased @@ -247,7 +247,7 @@ class RelayObserverTest { } @Test - fun `a machine-readable prefix is extracted, or 'other'`() { + fun `a machine-readable prefix is extracted or falls back to other`() { assertEquals("auth-required", RelayObserver.prefixOf("auth-required: come back signed")) assertEquals("other", RelayObserver.prefixOf("just some prose")) assertEquals("other", RelayObserver.prefixOf(""))