Skip to content

Commit 76ccd17

Browse files
test(android): poll for stale TLS probe cleanup in auth test (#83826)
* test(android): poll for stale TLS probe cleanup in auth test Signed-off-by: NeatGuyCoding <[email protected]> * test(android): await stale TLS probe job Co-authored-by: NeatGuyCoding <[email protected]> --------- Signed-off-by: NeatGuyCoding <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
1 parent 40d4e32 commit 76ccd17

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

apps/android/app/src/test/java/ai/openclaw/app/GatewayBootstrapAuthTest.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import ai.openclaw.app.protocol.OpenClawTalkCommand
1212
import ai.openclaw.app.voice.TalkModeManager
1313
import android.Manifest
1414
import kotlinx.coroutines.CompletableDeferred
15+
import kotlinx.coroutines.CoroutineScope
16+
import kotlinx.coroutines.Job
1517
import kotlinx.coroutines.flow.MutableStateFlow
1618
import kotlinx.coroutines.runBlocking
1719
import org.junit.Assert.assertEquals
@@ -367,16 +369,28 @@ class GatewayBootstrapAuthTest {
367369
probeResult.await()
368370
},
369371
)
372+
val runtimeScope = readField<CoroutineScope>(runtime, "scope")
373+
val existingJobs =
374+
runtimeScope.coroutineContext[Job]
375+
?.children
376+
?.toSet()
377+
.orEmpty()
370378

371379
runtime.connect(
372380
endpoint,
373381
NodeRuntime.GatewayConnectAuth(token = "shared-token", bootstrapToken = null, password = null),
374382
)
375383
probeStarted.await()
384+
val probeJob =
385+
runtimeScope.coroutineContext[Job]
386+
?.children
387+
?.singleOrNull { it !in existingJobs }
388+
?: error("Expected one TLS probe job")
376389

377390
runtime.disconnect()
378391
probeResult.complete(GatewayTlsProbeResult(fingerprintSha256 = "aaaaaaaa"))
379-
Thread.sleep(100)
392+
// Join the owning coroutine so assertions run after its stale-attempt guard.
393+
probeJob.join()
380394

381395
assertNull(runtime.pendingGatewayTrust.value)
382396
assertNull(desiredBootstrapToken(runtime, "nodeSession"))

0 commit comments

Comments
 (0)