Fix races causing flakes in LibSignalChatConnectionTest.

This commit is contained in:
andrew-signal
2025-03-17 07:10:00 -04:00
committed by Cody Henthorne
parent d3f622478f
commit 2a767c1e18

View File

@@ -420,10 +420,8 @@ class LibSignalChatConnectionTest {
var connectionCompletionFuture: CompletableFuture<UnauthenticatedChatConnection>? = null var connectionCompletionFuture: CompletableFuture<UnauthenticatedChatConnection>? = null
every { network.connectUnauthChat(any()) } answers { every { network.connectUnauthChat(any()) } answers {
chatListener = firstArg() chatListener = firstArg()
delay { connectionCompletionFuture = CompletableFuture<UnauthenticatedChatConnection>()
// We do not complete the future, so we stay in the CONNECTING state forever. connectionCompletionFuture!!
connectionCompletionFuture = it
}
} }
sendLatch = CountDownLatch(1) sendLatch = CountDownLatch(1)
@@ -447,9 +445,8 @@ class LibSignalChatConnectionTest {
var connectionCompletionFuture: CompletableFuture<UnauthenticatedChatConnection>? = null var connectionCompletionFuture: CompletableFuture<UnauthenticatedChatConnection>? = null
every { network.connectUnauthChat(any()) } answers { every { network.connectUnauthChat(any()) } answers {
chatListener = firstArg() chatListener = firstArg()
delay { connectionCompletionFuture = CompletableFuture<UnauthenticatedChatConnection>()
connectionCompletionFuture = it connectionCompletionFuture!!
}
} }
sendLatch = CountDownLatch(1) sendLatch = CountDownLatch(1)