From 476afeca15373c82a2349ce72a6996b74964a7b0 Mon Sep 17 00:00:00 2001 From: Bug Magnet Date: Tue, 4 Jun 2024 12:58:40 +0200 Subject: [PATCH] Make the actor reconnect reason explicit --- ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift | 2 +- ios/PacketTunnelCoreTests/Mocks/SettingsReaderStub.swift | 3 ++- ios/PacketTunnelCoreTests/PacketTunnelActorTests.swift | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift index aaafa317fe5a..5ba42a0bd203 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift @@ -38,7 +38,7 @@ extension PacketTunnelActor { - Parameter nextRelay: next relay to connect to. */ - public nonisolated func reconnect(to nextRelay: NextRelay, reconnectReason: ActorReconnectReason = .userInitiated) { + public nonisolated func reconnect(to nextRelay: NextRelay, reconnectReason: ActorReconnectReason) { eventChannel.send(.reconnect(nextRelay, reason: reconnectReason)) } diff --git a/ios/PacketTunnelCoreTests/Mocks/SettingsReaderStub.swift b/ios/PacketTunnelCoreTests/Mocks/SettingsReaderStub.swift index b334cdac65b9..e202ad04e319 100644 --- a/ios/PacketTunnelCoreTests/Mocks/SettingsReaderStub.swift +++ b/ios/PacketTunnelCoreTests/Mocks/SettingsReaderStub.swift @@ -46,7 +46,8 @@ extension SettingsReaderStub { relayConstraints: RelayConstraints(), dnsServers: .gateway, obfuscation: WireGuardObfuscationSettings(state: .off, port: .automatic), - quantumResistance: .on + quantumResistance: .on, + multihopState: .off ) return SettingsReaderStub { return staticSettings diff --git a/ios/PacketTunnelCoreTests/PacketTunnelActorTests.swift b/ios/PacketTunnelCoreTests/PacketTunnelActorTests.swift index 33d6657801be..539aee36c468 100644 --- a/ios/PacketTunnelCoreTests/PacketTunnelActorTests.swift +++ b/ios/PacketTunnelCoreTests/PacketTunnelActorTests.swift @@ -383,7 +383,7 @@ final class PacketTunnelActorTests: XCTestCase { reconnectingStateExpectation.fulfill() } - actor.reconnect(to: .random) + actor.reconnect(to: .random, reconnectReason: .userInitiated) await fulfillment( of: [reconnectingStateExpectation], @@ -414,7 +414,7 @@ final class PacketTunnelActorTests: XCTestCase { let reconnectingState: (ObservedState) -> Bool = { if case .reconnecting = $0 { true } else { false } } await expect(reconnectingState, on: actor) { reconnectingStateExpectation.fulfill() } - actor.reconnect(to: .random) + actor.reconnect(to: .random, reconnectReason: .userInitiated) await fulfillment( of: [reconnectingStateExpectation], timeout: Duration.milliseconds(100).timeInterval @@ -445,7 +445,7 @@ final class PacketTunnelActorTests: XCTestCase { // Cancel the state sink to avoid overfulfilling the connected expectation stateSink?.cancel() - actor.reconnect(to: .random) + actor.reconnect(to: .random, reconnectReason: .userInitiated) await fulfillment(of: [stopMonitorExpectation], timeout: 1) } }