Skip to content

Commit

Permalink
Replace all maximum timeout values to 60 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Petersson committed Jun 25, 2024
1 parent 9c6c19a commit c365507
Show file tree
Hide file tree
Showing 21 changed files with 135 additions and 78 deletions.
14 changes: 14 additions & 0 deletions ios/MullvadMockData/Extensions/TimeInterval+Timeout.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// TimeInterval+Timeout.swift
// MullvadMockData
//
// Created by Jon Petersson on 2024-06-19.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

extension TimeInterval {
struct UnitTest {
static let timeout: TimeInterval = 60
static let invertedTimeout: TimeInterval = 0.5
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

@testable import MullvadMockData
@testable import MullvadPostQuantum
@testable import MullvadTypes
import NetworkExtension
Expand Down Expand Up @@ -86,6 +87,6 @@ class MullvadPostQuantumTests: XCTestCase {

keyExchangeActor.reset()

wait(for: [negotationCancelledExpectation, unexpectedNegotiationFailure], timeout: 0.5)
wait(for: [negotationCancelledExpectation, unexpectedNegotiationFailure], timeout: .UnitTest.invertedTimeout)
}
}
5 changes: 3 additions & 2 deletions ios/MullvadRESTTests/HeadRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

@testable import MullvadMockData
@testable import MullvadREST
import XCTest

Expand All @@ -21,7 +22,7 @@ class HeadRequestTests: XCTestCase {
}
}

wait(for: [successfulRequestExpectation], timeout: 1)
wait(for: [successfulRequestExpectation], timeout: .UnitTest.timeout)
}

func testRequestWithErrors() throws {
Expand All @@ -35,6 +36,6 @@ class HeadRequestTests: XCTestCase {
}
}

wait(for: [failedRequestExpectation], timeout: 1)
wait(for: [failedRequestExpectation], timeout: .UnitTest.timeout)
}
}
5 changes: 3 additions & 2 deletions ios/MullvadRESTTests/RequestExecutorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//

@testable import MullvadMockData
@testable import MullvadREST
@testable import MullvadTypes
import XCTest
Expand Down Expand Up @@ -42,7 +43,7 @@ final class RequestExecutorTests: XCTestCase {
expectation.fulfill()
}

waitForExpectations(timeout: 2)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testCancelAsyncExecution() async throws {
Expand Down Expand Up @@ -70,6 +71,6 @@ final class RequestExecutorTests: XCTestCase {

cancellationToken.cancel()

waitForExpectations(timeout: 2)
waitForExpectations(timeout: .UnitTest.timeout)
}
}
26 changes: 26 additions & 0 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@
7ADCB2DA2B6A730400C88F89 /* IPOverrideRepositoryStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADCB2D92B6A730400C88F89 /* IPOverrideRepositoryStub.swift */; };
7AE044BB2A935726003915D8 /* Routing.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A88DCD02A8FABBE00D2FF0E /* Routing.h */; settings = {ATTRIBUTES = (Public, ); }; };
7AE2414A2C20682B0076CE33 /* FormsheetPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE241482C20682B0076CE33 /* FormsheetPresentationController.swift */; };
7AEBA52C2C22C65B0018BEC5 /* TimeInterval+Timeout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AEBA52B2C22C65B0018BEC5 /* TimeInterval+Timeout.swift */; };
7AED35CC2BD13F60002A67D1 /* ApplicationConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58BFA5CB22A7CE1F00A6173D /* ApplicationConfiguration.swift */; };
7AED35CD2BD13FC4002A67D1 /* ApplicationTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58C76A072A33850E00100D75 /* ApplicationTarget.swift */; };
7AEF7F1A2AD00F52006FE45D /* AppMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AEF7F192AD00F52006FE45D /* AppMessageHandler.swift */; };
Expand Down Expand Up @@ -1201,6 +1202,13 @@
remoteGlobalIDString = 7A88DCCD2A8FABBE00D2FF0E;
remoteInfo = Routing;
};
7AEBA52E2C297E5D0018BEC5 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 58CE5E58224146200008646E /* Project object */;
proxyType = 1;
remoteGlobalIDString = F0ACE3072BE4E478006D5333;
remoteInfo = MullvadMockData;
};
8529692B2B4D9C1F007EAD4C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 58CE5E58224146200008646E /* Project object */;
Expand Down Expand Up @@ -1972,6 +1980,7 @@
7ADCB2D72B6A6EB300C88F89 /* AnyRelay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyRelay.swift; sourceTree = "<group>"; };
7ADCB2D92B6A730400C88F89 /* IPOverrideRepositoryStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPOverrideRepositoryStub.swift; sourceTree = "<group>"; };
7AE241482C20682B0076CE33 /* FormsheetPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormsheetPresentationController.swift; sourceTree = "<group>"; };
7AEBA52B2C22C65B0018BEC5 /* TimeInterval+Timeout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TimeInterval+Timeout.swift"; sourceTree = "<group>"; };
7AEF7F192AD00F52006FE45D /* AppMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppMessageHandler.swift; sourceTree = "<group>"; };
7AF10EB12ADE859200C090B9 /* AlertViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertViewController.swift; sourceTree = "<group>"; };
7AF10EB32ADE85BC00C090B9 /* RelayFilterCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelayFilterCoordinator.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3928,6 +3937,14 @@
path = "Presentation controllers";
sourceTree = "<group>";
};
7AEBA52D2C2310D20018BEC5 /* Extensions */ = {
isa = PBXGroup;
children = (
7AEBA52B2C22C65B0018BEC5 /* TimeInterval+Timeout.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
7AF9BE912A39F47D00DBFEDB /* RelayFilter */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4134,6 +4151,7 @@
isa = PBXGroup;
children = (
F0ACE30A2BE4E478006D5333 /* MullvadMockData.h */,
7AEBA52D2C2310D20018BEC5 /* Extensions */,
F0ACE3172BE4E487006D5333 /* MullvadREST */,
F0ACE32B2BE4E748006D5333 /* MullvadTypes */,
);
Expand Down Expand Up @@ -4474,6 +4492,7 @@
buildRules = (
);
dependencies = (
7AEBA52F2C297E5D0018BEC5 /* PBXTargetDependency */,
);
name = OperationsTests;
productName = OperationsTests;
Expand Down Expand Up @@ -4709,6 +4728,7 @@
buildRules = (
);
dependencies = (
7AEBA5312C2981870018BEC5 /* PBXTargetDependency */,
58FBFBEC291622580020E046 /* PBXTargetDependency */,
);
name = MullvadRESTTests;
Expand Down Expand Up @@ -6243,6 +6263,7 @@
F0ACE31E2BE4E4F2006D5333 /* AccountsProxy+Stubs.swift in Sources */,
F0ACE3202BE4E4F2006D5333 /* AccessTokenManager+Stubs.swift in Sources */,
F0ACE32C2BE4E77E006D5333 /* DeviceMock.swift in Sources */,
7AEBA52C2C22C65B0018BEC5 /* TimeInterval+Timeout.swift in Sources */,
F0ACE3222BE4E4F2006D5333 /* APIProxy+Stubs.swift in Sources */,
F0ACE3332BE516F1006D5333 /* RESTRequestExecutor+Stubs.swift in Sources */,
F0ACE32D2BE4E784006D5333 /* AccountMock.swift in Sources */,
Expand Down Expand Up @@ -6430,6 +6451,11 @@
target = 7A88DCCD2A8FABBE00D2FF0E /* Routing */;
targetProxy = 7ABCA5B52A9349F20044A708 /* PBXContainerItemProxy */;
};
7AEBA5312C2981870018BEC5 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = F0ACE3072BE4E478006D5333 /* MullvadMockData */;
targetProxy = 7AEBA5302C2981870018BEC5 /* PBXContainerItemProxy */;
};
8529692C2B4D9C1F007EAD4C /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 58CE5E5F224146200008646E /* MullvadVPN */;
Expand Down
11 changes: 6 additions & 5 deletions ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//

@testable import MullvadMockData
@testable import MullvadREST
@testable import MullvadSettings
@testable import MullvadTypes
Expand Down Expand Up @@ -38,7 +39,7 @@ final class MigrationManagerTests: XCTestCase {
nothingToMigrateExpectation.fulfill()
}
}
wait(for: [nothingToMigrateExpectation], timeout: 1)
wait(for: [nothingToMigrateExpectation], timeout: .UnitTest.timeout)
}

func testNothingToMigrateWhenSettingsAreNotFound() throws {
Expand All @@ -51,7 +52,7 @@ final class MigrationManagerTests: XCTestCase {
nothingToMigrateExpectation.fulfill()
}
}
wait(for: [nothingToMigrateExpectation], timeout: 1)
wait(for: [nothingToMigrateExpectation], timeout: .UnitTest.timeout)

// Reset the `SettingsManager` unit test store to avoid affecting other tests
// since it's a globally shared instance
Expand All @@ -66,7 +67,7 @@ final class MigrationManagerTests: XCTestCase {
failedMigrationExpectation.fulfill()
}
}
wait(for: [failedMigrationExpectation], timeout: 1)
wait(for: [failedMigrationExpectation], timeout: .UnitTest.timeout)
}

func testFailedMigrationResetsSettings() throws {
Expand Down Expand Up @@ -116,7 +117,7 @@ final class MigrationManagerTests: XCTestCase {
failedMigrationExpectation.fulfill()
}
}
wait(for: [failedMigrationExpectation], timeout: 1)
wait(for: [failedMigrationExpectation], timeout: .UnitTest.timeout)
}

func testSuccessfulMigrationFromV4ToLatest() throws {
Expand Down Expand Up @@ -198,7 +199,7 @@ final class MigrationManagerTests: XCTestCase {
successfulMigrationExpectation.fulfill()
}
}
wait(for: [successfulMigrationExpectation], timeout: 1)
wait(for: [successfulMigrationExpectation], timeout: .UnitTest.timeout)
}

private func write(settings: any TunnelSettings, version: Int, in store: SettingsStore) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by Mojgan on 2023-10-25.
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//

@testable import MullvadMockData
import MullvadREST
import XCTest

Expand Down Expand Up @@ -37,7 +39,7 @@ final class OutgoingConnectionProxyTests: XCTestCase {
if result.ip == IPV4ConnectionData.mock.ip {
iPv4Expectation.fulfill()
}
await fulfillment(of: [iPv4Expectation], timeout: 1)
await fulfillment(of: [iPv4Expectation], timeout: .UnitTest.timeout)
}

func testFailureGettingIPV4() async throws {
Expand All @@ -50,7 +52,7 @@ final class OutgoingConnectionProxyTests: XCTestCase {
await XCTAssertThrowsErrorAsync(try await outgoingConnectionProxy.getIPV4(retryStrategy: .noRetry)) { _ in
noIPv4Expectation.fulfill()
}
await fulfillment(of: [noIPv4Expectation], timeout: 1)
await fulfillment(of: [noIPv4Expectation], timeout: .UnitTest.timeout)
}

func testSuccessGettingIPV6() async throws {
Expand All @@ -65,7 +67,7 @@ final class OutgoingConnectionProxyTests: XCTestCase {
if result.ip == IPV6ConnectionData.mock.ip {
ipv6Expectation.fulfill()
}
await fulfillment(of: [ipv6Expectation], timeout: 1.0)
await fulfillment(of: [ipv6Expectation], timeout: .UnitTest.timeout)
}

func testFailureGettingIPV6() async throws {
Expand All @@ -78,7 +80,7 @@ final class OutgoingConnectionProxyTests: XCTestCase {
await XCTAssertThrowsErrorAsync(try await outgoingConnectionProxy.getIPV6(retryStrategy: .noRetry)) { _ in
noIPv6Expectation.fulfill()
}
await fulfillment(of: [noIPv6Expectation], timeout: 1)
await fulfillment(of: [noIPv6Expectation], timeout: .UnitTest.timeout)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testShouldNotRotateKeyForInvalidAccount() {
Expand Down Expand Up @@ -76,7 +76,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testShouldNotRotateKeyForRevokedDevice() {
Expand Down Expand Up @@ -107,7 +107,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testShouldRotateKeyOnMismatchImmediately() {
Expand Down Expand Up @@ -136,7 +136,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testShouldRespectCooldownWhenAttemptingToRotateImmediately() {
Expand Down Expand Up @@ -165,7 +165,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testShouldNotRotateDeviceKeyWhenServerKeyIsIdentical() {
Expand All @@ -188,7 +188,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testShouldNotRotateKeyBeforeRetryIntervalPassed() {
Expand All @@ -213,7 +213,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testShouldRotateKeyOnceInTwentyFourHours() {
Expand All @@ -238,7 +238,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testShouldReportFailedKeyRotataionAttempt() {
Expand Down Expand Up @@ -268,7 +268,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

func testShouldFailOnKeyRotationRace() {
Expand Down Expand Up @@ -305,7 +305,7 @@ class DeviceCheckOperationTests: XCTestCase {
expect.fulfill()
}

waitForExpectations(timeout: 1)
waitForExpectations(timeout: .UnitTest.timeout)
}

private func startDeviceCheck(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

@testable import MullvadMockData
import MullvadSettings
import Network
import Operations
Expand Down Expand Up @@ -63,7 +64,7 @@ class StartTunnelOperationTests: XCTestCase {
}

operationQueue.addOperation(operation)
wait(for: [expectation], timeout: 1.0)
wait(for: [expectation], timeout: .UnitTest.timeout)
}

func testSetsReconnectIfDisconnecting() {
Expand All @@ -80,7 +81,7 @@ class StartTunnelOperationTests: XCTestCase {
expectation.fulfill()
}
operationQueue.addOperation(operation)
wait(for: [expectation], timeout: 1.0)
wait(for: [expectation], timeout: .UnitTest.timeout)
}

func testStartsTunnelIfDisconnected() {
Expand All @@ -95,6 +96,6 @@ class StartTunnelOperationTests: XCTestCase {
expectation.fulfill()
}
operationQueue.addOperation(operation)
wait(for: [expectation], timeout: 1.0)
wait(for: [expectation], timeout: .UnitTest.timeout)
}
}
Loading

0 comments on commit c365507

Please sign in to comment.