fix(#1197): advertise server request capability (#1198)

This commit is contained in:
M57 authored and GitHub committed 2026-09-19 20:08:11 +03:00
1 parent 759d59b9f9
commit c96a5ff4da
3 files changed
+54

No files matched your search

@@ -176,6 +176,51 @@ class HermesWsClientTest {
assertTrue(msg.contains(id))
}
@Test
fun gatewayReadyAdvertisesServerRequestCapability() {
val capabilityLatch = CountDownLatch(1)
var capabilityFrame: String? = null
mockWebServer.enqueue(
MockResponse().withWebSocketUpgrade(
object : WebSocketListener() {
override fun onOpen(
webSocket: WebSocket,
response: okhttp3.Response,
) {
webSocket.send(
"""{"jsonrpc":"2.0","method":"event","params":{"type":"gateway.ready","payload":{}}}""",
)
}
override fun onMessage(
webSocket: WebSocket,
text: String,
) {
val frame = Json.parseToJsonElement(text).jsonObject
if (frame["method"]?.jsonPrimitive?.content == WsMethods.CLIENT_CAPABILITIES) {
capabilityFrame = text
capabilityLatch.countDown()
}
}
},
),
)
HermesWsClient.connect()
assertTrue("Capability advertisement not sent", capabilityLatch.await(5, TimeUnit.SECONDS))
val frame = Json.parseToJsonElement(capabilityFrame ?: "{}").jsonObject
assertEquals(WsMethods.CLIENT_CAPABILITIES, frame["method"]?.jsonPrimitive?.content)
assertTrue(
frame["params"]
?.jsonObject
?.get("server_requests")
?.jsonPrimitive
?.content == "true",
)
}
@Test
fun testOpenRequestsReplayUsesTheLiveServerRequestDispatcher() =
runBlocking {