Match the listener's parameter names; drop commas from test names
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) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
cf75272202
commit
18d229be58
+11
-11
@@ -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.
|
||||
|
||||
+5
-5
@@ -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(""))
|
||||
|
||||
Reference in New Issue
Block a user