Skip to content

Commit

Permalink
Make the actor reconnect reason explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
buggmagnet committed Jun 4, 2024
1 parent 66336ae commit 476afec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
3 changes: 2 additions & 1 deletion ios/PacketTunnelCoreTests/Mocks/SettingsReaderStub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ios/PacketTunnelCoreTests/PacketTunnelActorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ final class PacketTunnelActorTests: XCTestCase {
reconnectingStateExpectation.fulfill()
}

actor.reconnect(to: .random)
actor.reconnect(to: .random, reconnectReason: .userInitiated)

await fulfillment(
of: [reconnectingStateExpectation],
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 476afec

Please sign in to comment.