From faee7e4e14c7971270e20e8c621ae724f5204057 Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Tue, 8 Aug 2023 12:28:44 +0100 Subject: [PATCH] test: fix connection event race condition in present proof test (#620) --- .../test/kotlin/features/connection/ConnectionSteps.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e-tests/src/test/kotlin/features/connection/ConnectionSteps.kt b/tests/e2e-tests/src/test/kotlin/features/connection/ConnectionSteps.kt index 999a51da08..7f4ab7e591 100644 --- a/tests/e2e-tests/src/test/kotlin/features/connection/ConnectionSteps.kt +++ b/tests/e2e-tests/src/test/kotlin/features/connection/ConnectionSteps.kt @@ -101,8 +101,8 @@ class ConnectionSteps { fun inviterReceivesTheConnectionRequest(inviter: Actor) { wait( { - val lastEvent = ListenToEvents.`as`(inviter).connectionEvents.last() - lastEvent.data.thid == inviter.recall("thid") && + val lastEvent = ListenToEvents.`as`(inviter).connectionEvents.lastOrNull() + lastEvent != null && lastEvent.data.thid == inviter.recall("thid") && lastEvent.data.state == ConnectionState.CONNECTION_RESPONSE_SENT }, "Inviter connection didn't reach ${ConnectionState.CONNECTION_RESPONSE_SENT} state", @@ -114,8 +114,8 @@ class ConnectionSteps { // Bob (Holder) receives final connection response wait( { - val lastEvent = ListenToEvents.`as`(invitee).connectionEvents.last() - lastEvent.data.thid == invitee.recall("thid") && + val lastEvent = ListenToEvents.`as`(invitee).connectionEvents.lastOrNull() + lastEvent != null && lastEvent.data.thid == invitee.recall("thid") && lastEvent.data.state == ConnectionState.CONNECTION_RESPONSE_RECEIVED }, "Invitee connection didn't reach ${ConnectionState.CONNECTION_RESPONSE_RECEIVED} state.",