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.",