Skip to content

Commit c20735b

Browse files
author
Jon Petersson
committed
Replace all maximum timeout values to 60 seconds
1 parent bed092a commit c20735b

21 files changed

+147
-78
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// TimeInterval+Timeout.swift
3+
// MullvadMockData
4+
//
5+
// Created by Jon Petersson on 2024-06-19.
6+
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
7+
//
8+
9+
extension TimeInterval {
10+
struct UnitTest {
11+
static let timeout: TimeInterval = 60
12+
static let invertedTimeout: TimeInterval = 0.5
13+
}
14+
}

ios/MullvadPostQuantumTests/PostQuantumKeyExchangeActorTests.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
77
//
88

9+
@testable import MullvadMockData
910
@testable import MullvadPostQuantum
1011
@testable import MullvadTypes
1112
import NetworkExtension
@@ -86,6 +87,6 @@ class MullvadPostQuantumTests: XCTestCase {
8687

8788
keyExchangeActor.reset()
8889

89-
wait(for: [negotationCancelledExpectation, unexpectedNegotiationFailure], timeout: 0.5)
90+
wait(for: [negotationCancelledExpectation, unexpectedNegotiationFailure], timeout: .UnitTest.invertedTimeout)
9091
}
9192
}

ios/MullvadRESTTests/HeadRequestTests.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
77
//
88

9+
@testable import MullvadMockData
910
@testable import MullvadREST
1011
import XCTest
1112

@@ -21,7 +22,7 @@ class HeadRequestTests: XCTestCase {
2122
}
2223
}
2324

24-
wait(for: [successfulRequestExpectation], timeout: 1)
25+
wait(for: [successfulRequestExpectation], timeout: .UnitTest.timeout)
2526
}
2627

2728
func testRequestWithErrors() throws {
@@ -35,6 +36,6 @@ class HeadRequestTests: XCTestCase {
3536
}
3637
}
3738

38-
wait(for: [failedRequestExpectation], timeout: 1)
39+
wait(for: [failedRequestExpectation], timeout: .UnitTest.timeout)
3940
}
4041
}

ios/MullvadRESTTests/RequestExecutorTests.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
77
//
88

9+
@testable import MullvadMockData
910
@testable import MullvadREST
1011
@testable import MullvadTypes
1112
import XCTest
@@ -42,7 +43,7 @@ final class RequestExecutorTests: XCTestCase {
4243
expectation.fulfill()
4344
}
4445

45-
waitForExpectations(timeout: 2)
46+
waitForExpectations(timeout: .UnitTest.timeout)
4647
}
4748

4849
func testCancelAsyncExecution() async throws {
@@ -70,6 +71,6 @@ final class RequestExecutorTests: XCTestCase {
7071

7172
cancellationToken.cancel()
7273

73-
waitForExpectations(timeout: 2)
74+
waitForExpectations(timeout: .UnitTest.timeout)
7475
}
7576
}

ios/MullvadVPN.xcodeproj/project.pbxproj

+38
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@
605605
7ADCB2D82B6A6EB300C88F89 /* AnyRelay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADCB2D72B6A6EB300C88F89 /* AnyRelay.swift */; };
606606
7ADCB2DA2B6A730400C88F89 /* IPOverrideRepositoryStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADCB2D92B6A730400C88F89 /* IPOverrideRepositoryStub.swift */; };
607607
7AE044BB2A935726003915D8 /* Routing.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A88DCD02A8FABBE00D2FF0E /* Routing.h */; settings = {ATTRIBUTES = (Public, ); }; };
608+
7AEBA52C2C22C65B0018BEC5 /* TimeInterval+Timeout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AEBA52B2C22C65B0018BEC5 /* TimeInterval+Timeout.swift */; };
608609
7AED35CC2BD13F60002A67D1 /* ApplicationConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58BFA5CB22A7CE1F00A6173D /* ApplicationConfiguration.swift */; };
609610
7AED35CD2BD13FC4002A67D1 /* ApplicationTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58C76A072A33850E00100D75 /* ApplicationTarget.swift */; };
610611
7AEF7F1A2AD00F52006FE45D /* AppMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AEF7F192AD00F52006FE45D /* AppMessageHandler.swift */; };
@@ -1203,6 +1204,20 @@
12031204
remoteGlobalIDString = 7A88DCCD2A8FABBE00D2FF0E;
12041205
remoteInfo = Routing;
12051206
};
1207+
7AEBA52E2C297E5D0018BEC5 /* PBXContainerItemProxy */ = {
1208+
isa = PBXContainerItemProxy;
1209+
containerPortal = 58CE5E58224146200008646E /* Project object */;
1210+
proxyType = 1;
1211+
remoteGlobalIDString = F0ACE3072BE4E478006D5333;
1212+
remoteInfo = MullvadMockData;
1213+
};
1214+
7AEBA5302C2981870018BEC5 /* PBXContainerItemProxy */ = {
1215+
isa = PBXContainerItemProxy;
1216+
containerPortal = 58CE5E58224146200008646E /* Project object */;
1217+
proxyType = 1;
1218+
remoteGlobalIDString = F0ACE3072BE4E478006D5333;
1219+
remoteInfo = MullvadMockData;
1220+
};
12061221
8529692B2B4D9C1F007EAD4C /* PBXContainerItemProxy */ = {
12071222
isa = PBXContainerItemProxy;
12081223
containerPortal = 58CE5E58224146200008646E /* Project object */;
@@ -1976,6 +1991,7 @@
19761991
7AD0AA202AD6CB0000119E10 /* URLRequestProxyStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLRequestProxyStub.swift; sourceTree = "<group>"; };
19771992
7ADCB2D72B6A6EB300C88F89 /* AnyRelay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyRelay.swift; sourceTree = "<group>"; };
19781993
7ADCB2D92B6A730400C88F89 /* IPOverrideRepositoryStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPOverrideRepositoryStub.swift; sourceTree = "<group>"; };
1994+
7AEBA52B2C22C65B0018BEC5 /* TimeInterval+Timeout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TimeInterval+Timeout.swift"; sourceTree = "<group>"; };
19791995
7AEF7F192AD00F52006FE45D /* AppMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppMessageHandler.swift; sourceTree = "<group>"; };
19801996
7AF10EB12ADE859200C090B9 /* AlertViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertViewController.swift; sourceTree = "<group>"; };
19811997
7AF10EB32ADE85BC00C090B9 /* RelayFilterCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelayFilterCoordinator.swift; sourceTree = "<group>"; };
@@ -3934,6 +3950,14 @@
39343950
path = SelectLocation;
39353951
sourceTree = "<group>";
39363952
};
3953+
7AEBA52D2C2310D20018BEC5 /* Extensions */ = {
3954+
isa = PBXGroup;
3955+
children = (
3956+
7AEBA52B2C22C65B0018BEC5 /* TimeInterval+Timeout.swift */,
3957+
);
3958+
path = Extensions;
3959+
sourceTree = "<group>";
3960+
};
39373961
7AF9BE912A39F47D00DBFEDB /* RelayFilter */ = {
39383962
isa = PBXGroup;
39393963
children = (
@@ -4140,6 +4164,7 @@
41404164
isa = PBXGroup;
41414165
children = (
41424166
F0ACE30A2BE4E478006D5333 /* MullvadMockData.h */,
4167+
7AEBA52D2C2310D20018BEC5 /* Extensions */,
41434168
F0ACE3172BE4E487006D5333 /* MullvadREST */,
41444169
F0ACE32B2BE4E748006D5333 /* MullvadTypes */,
41454170
);
@@ -4480,6 +4505,7 @@
44804505
buildRules = (
44814506
);
44824507
dependencies = (
4508+
7AEBA52F2C297E5D0018BEC5 /* PBXTargetDependency */,
44834509
);
44844510
name = OperationsTests;
44854511
productName = OperationsTests;
@@ -4715,6 +4741,7 @@
47154741
buildRules = (
47164742
);
47174743
dependencies = (
4744+
7AEBA5312C2981870018BEC5 /* PBXTargetDependency */,
47184745
58FBFBEC291622580020E046 /* PBXTargetDependency */,
47194746
);
47204747
name = MullvadRESTTests;
@@ -6251,6 +6278,7 @@
62516278
F0ACE31E2BE4E4F2006D5333 /* AccountsProxy+Stubs.swift in Sources */,
62526279
F0ACE3202BE4E4F2006D5333 /* AccessTokenManager+Stubs.swift in Sources */,
62536280
F0ACE32C2BE4E77E006D5333 /* DeviceMock.swift in Sources */,
6281+
7AEBA52C2C22C65B0018BEC5 /* TimeInterval+Timeout.swift in Sources */,
62546282
F0ACE3222BE4E4F2006D5333 /* APIProxy+Stubs.swift in Sources */,
62556283
F0ACE3332BE516F1006D5333 /* RESTRequestExecutor+Stubs.swift in Sources */,
62566284
F0ACE32D2BE4E784006D5333 /* AccountMock.swift in Sources */,
@@ -6438,6 +6466,16 @@
64386466
target = 7A88DCCD2A8FABBE00D2FF0E /* Routing */;
64396467
targetProxy = 7ABCA5B52A9349F20044A708 /* PBXContainerItemProxy */;
64406468
};
6469+
7AEBA52F2C297E5D0018BEC5 /* PBXTargetDependency */ = {
6470+
isa = PBXTargetDependency;
6471+
target = F0ACE3072BE4E478006D5333 /* MullvadMockData */;
6472+
targetProxy = 7AEBA52E2C297E5D0018BEC5 /* PBXContainerItemProxy */;
6473+
};
6474+
7AEBA5312C2981870018BEC5 /* PBXTargetDependency */ = {
6475+
isa = PBXTargetDependency;
6476+
target = F0ACE3072BE4E478006D5333 /* MullvadMockData */;
6477+
targetProxy = 7AEBA5302C2981870018BEC5 /* PBXContainerItemProxy */;
6478+
};
64416479
8529692C2B4D9C1F007EAD4C /* PBXTargetDependency */ = {
64426480
isa = PBXTargetDependency;
64436481
target = 58CE5E5F224146200008646E /* MullvadVPN */;

ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
77
//
88

9+
@testable import MullvadMockData
910
@testable import MullvadREST
1011
@testable import MullvadSettings
1112
@testable import MullvadTypes
@@ -38,7 +39,7 @@ final class MigrationManagerTests: XCTestCase {
3839
nothingToMigrateExpectation.fulfill()
3940
}
4041
}
41-
wait(for: [nothingToMigrateExpectation], timeout: 1)
42+
wait(for: [nothingToMigrateExpectation], timeout: .UnitTest.timeout)
4243
}
4344

4445
func testNothingToMigrateWhenSettingsAreNotFound() throws {
@@ -51,7 +52,7 @@ final class MigrationManagerTests: XCTestCase {
5152
nothingToMigrateExpectation.fulfill()
5253
}
5354
}
54-
wait(for: [nothingToMigrateExpectation], timeout: 1)
55+
wait(for: [nothingToMigrateExpectation], timeout: .UnitTest.timeout)
5556

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

7273
func testFailedMigrationResetsSettings() throws {
@@ -116,7 +117,7 @@ final class MigrationManagerTests: XCTestCase {
116117
failedMigrationExpectation.fulfill()
117118
}
118119
}
119-
wait(for: [failedMigrationExpectation], timeout: 1)
120+
wait(for: [failedMigrationExpectation], timeout: .UnitTest.timeout)
120121
}
121122

122123
func testSuccessfulMigrationFromV4ToLatest() throws {
@@ -198,7 +199,7 @@ final class MigrationManagerTests: XCTestCase {
198199
successfulMigrationExpectation.fulfill()
199200
}
200201
}
201-
wait(for: [successfulMigrationExpectation], timeout: 1)
202+
wait(for: [successfulMigrationExpectation], timeout: .UnitTest.timeout)
202203
}
203204

204205
private func write(settings: any TunnelSettings, version: Int, in store: SettingsStore) throws {

ios/MullvadVPNTests/MullvadVPN/GeneralAPIs/OutgoingConnectionProxyTests.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Created by Mojgan on 2023-10-25.
66
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
77
//
8+
9+
@testable import MullvadMockData
810
import MullvadREST
911
import XCTest
1012

@@ -37,7 +39,7 @@ final class OutgoingConnectionProxyTests: XCTestCase {
3739
if result.ip == IPV4ConnectionData.mock.ip {
3840
iPv4Expectation.fulfill()
3941
}
40-
await fulfillment(of: [iPv4Expectation], timeout: 1)
42+
await fulfillment(of: [iPv4Expectation], timeout: .UnitTest.timeout)
4143
}
4244

4345
func testFailureGettingIPV4() async throws {
@@ -50,7 +52,7 @@ final class OutgoingConnectionProxyTests: XCTestCase {
5052
await XCTAssertThrowsErrorAsync(try await outgoingConnectionProxy.getIPV4(retryStrategy: .noRetry)) { _ in
5153
noIPv4Expectation.fulfill()
5254
}
53-
await fulfillment(of: [noIPv4Expectation], timeout: 1)
55+
await fulfillment(of: [noIPv4Expectation], timeout: .UnitTest.timeout)
5456
}
5557

5658
func testSuccessGettingIPV6() async throws {
@@ -65,7 +67,7 @@ final class OutgoingConnectionProxyTests: XCTestCase {
6567
if result.ip == IPV6ConnectionData.mock.ip {
6668
ipv6Expectation.fulfill()
6769
}
68-
await fulfillment(of: [ipv6Expectation], timeout: 1.0)
70+
await fulfillment(of: [ipv6Expectation], timeout: .UnitTest.timeout)
6971
}
7072

7173
func testFailureGettingIPV6() async throws {
@@ -78,7 +80,7 @@ final class OutgoingConnectionProxyTests: XCTestCase {
7880
await XCTAssertThrowsErrorAsync(try await outgoingConnectionProxy.getIPV6(retryStrategy: .noRetry)) { _ in
7981
noIPv6Expectation.fulfill()
8082
}
81-
await fulfillment(of: [noIPv6Expectation], timeout: 1)
83+
await fulfillment(of: [noIPv6Expectation], timeout: .UnitTest.timeout)
8284
}
8385
}
8486

ios/MullvadVPNTests/MullvadVPN/PacketTunnel/DeviceCheck/DeviceCheckOperationTests.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DeviceCheckOperationTests: XCTestCase {
4545
expect.fulfill()
4646
}
4747

48-
waitForExpectations(timeout: 1)
48+
waitForExpectations(timeout: .UnitTest.timeout)
4949
}
5050

5151
func testShouldNotRotateKeyForInvalidAccount() {
@@ -76,7 +76,7 @@ class DeviceCheckOperationTests: XCTestCase {
7676
expect.fulfill()
7777
}
7878

79-
waitForExpectations(timeout: 1)
79+
waitForExpectations(timeout: .UnitTest.timeout)
8080
}
8181

8282
func testShouldNotRotateKeyForRevokedDevice() {
@@ -107,7 +107,7 @@ class DeviceCheckOperationTests: XCTestCase {
107107
expect.fulfill()
108108
}
109109

110-
waitForExpectations(timeout: 1)
110+
waitForExpectations(timeout: .UnitTest.timeout)
111111
}
112112

113113
func testShouldRotateKeyOnMismatchImmediately() {
@@ -136,7 +136,7 @@ class DeviceCheckOperationTests: XCTestCase {
136136
expect.fulfill()
137137
}
138138

139-
waitForExpectations(timeout: 1)
139+
waitForExpectations(timeout: .UnitTest.timeout)
140140
}
141141

142142
func testShouldRespectCooldownWhenAttemptingToRotateImmediately() {
@@ -165,7 +165,7 @@ class DeviceCheckOperationTests: XCTestCase {
165165
expect.fulfill()
166166
}
167167

168-
waitForExpectations(timeout: 1)
168+
waitForExpectations(timeout: .UnitTest.timeout)
169169
}
170170

171171
func testShouldNotRotateDeviceKeyWhenServerKeyIsIdentical() {
@@ -188,7 +188,7 @@ class DeviceCheckOperationTests: XCTestCase {
188188
expect.fulfill()
189189
}
190190

191-
waitForExpectations(timeout: 1)
191+
waitForExpectations(timeout: .UnitTest.timeout)
192192
}
193193

194194
func testShouldNotRotateKeyBeforeRetryIntervalPassed() {
@@ -213,7 +213,7 @@ class DeviceCheckOperationTests: XCTestCase {
213213
expect.fulfill()
214214
}
215215

216-
waitForExpectations(timeout: 1)
216+
waitForExpectations(timeout: .UnitTest.timeout)
217217
}
218218

219219
func testShouldRotateKeyOnceInTwentyFourHours() {
@@ -238,7 +238,7 @@ class DeviceCheckOperationTests: XCTestCase {
238238
expect.fulfill()
239239
}
240240

241-
waitForExpectations(timeout: 1)
241+
waitForExpectations(timeout: .UnitTest.timeout)
242242
}
243243

244244
func testShouldReportFailedKeyRotataionAttempt() {
@@ -268,7 +268,7 @@ class DeviceCheckOperationTests: XCTestCase {
268268
expect.fulfill()
269269
}
270270

271-
waitForExpectations(timeout: 1)
271+
waitForExpectations(timeout: .UnitTest.timeout)
272272
}
273273

274274
func testShouldFailOnKeyRotationRace() {
@@ -305,7 +305,7 @@ class DeviceCheckOperationTests: XCTestCase {
305305
expect.fulfill()
306306
}
307307

308-
waitForExpectations(timeout: 1)
308+
waitForExpectations(timeout: .UnitTest.timeout)
309309
}
310310

311311
private func startDeviceCheck(

0 commit comments

Comments
 (0)