mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
test(android): stabilize saved gateway reconnect proof (#101519)
This commit is contained in:
parent
78399a194c
commit
9cd29dcb9a
1 changed files with 15 additions and 6 deletions
|
|
@ -612,19 +612,17 @@ class GatewayBootstrapAuthTest {
|
|||
),
|
||||
)
|
||||
prefs.gatewayRegistry.setActive(savedEndpoint.stableId)
|
||||
prefs.saveGatewayCredentials(savedEndpoint.stableId, token = "shared-token")
|
||||
prefs.saveGatewayCredentials(savedEndpoint.stableId, token = "initial-token")
|
||||
val runtime = NodeRuntime(app, prefs)
|
||||
|
||||
runtime.connect(
|
||||
GatewayEndpoint.manual(host = "127.0.0.1", port = 18789),
|
||||
NodeRuntime.GatewayConnectAuth(token = "initial-token", bootstrapToken = null, password = null),
|
||||
)
|
||||
waitForDesiredConnection(runtime, "nodeSession")
|
||||
prefs.saveGatewayCredentials(savedEndpoint.stableId, token = "shared-token")
|
||||
runtime.disconnect()
|
||||
assertNull(desiredConnection(runtime, "nodeSession"))
|
||||
|
||||
runtime.refreshGatewayConnection()
|
||||
|
||||
val desired = desiredConnection(runtime, "nodeSession") ?: error("Expected desired node connection")
|
||||
val desired = waitForDesiredConnection(runtime, "nodeSession")
|
||||
val endpoint = readField<GatewayEndpoint>(desired, "endpoint")
|
||||
assertEquals("127.0.0.1", endpoint.host)
|
||||
assertEquals(18789, endpoint.port)
|
||||
|
|
@ -1195,6 +1193,17 @@ class GatewayBootstrapAuthTest {
|
|||
return readField(session, "desired")
|
||||
}
|
||||
|
||||
private fun waitForDesiredConnection(
|
||||
runtime: NodeRuntime,
|
||||
sessionFieldName: String,
|
||||
): Any {
|
||||
repeat(50) {
|
||||
desiredConnection(runtime, sessionFieldName)?.let { return it }
|
||||
Thread.sleep(10)
|
||||
}
|
||||
error("Expected desired connection for $sessionFieldName")
|
||||
}
|
||||
|
||||
private fun invokeMaybeStartOperatorSessionAfterNodeConnect(
|
||||
runtime: NodeRuntime,
|
||||
endpoint: GatewayEndpoint,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue