Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Split.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5286,7 +5286,7 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TVOS_DEPLOYMENT_TARGET = 15.4;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -5352,7 +5352,7 @@
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TVOS_DEPLOYMENT_TARGET = 15.4;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -5397,7 +5397,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2,3,6";
TVOS_DEPLOYMENT_TARGET = 12.0;
USER_HEADER_SEARCH_PATHS = "";
Expand Down Expand Up @@ -5440,7 +5440,7 @@
SWIFT_INCLUDE_PATHS = "";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 12.0;
USER_HEADER_SEARCH_PATHS = "";
Expand Down Expand Up @@ -5471,7 +5471,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -5498,7 +5498,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -5583,7 +5583,7 @@
SUPPORTED_PLATFORMS = "watchsimulator watchos";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_INCLUDE_PATHS = "";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 4;
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
Expand Down Expand Up @@ -5626,7 +5626,7 @@
SUPPORTED_PLATFORMS = "watchsimulator watchos";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_INCLUDE_PATHS = "";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 4;
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
Expand Down
2 changes: 1 addition & 1 deletion SplitTests/Fake/Network/HttpClientMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
@testable import Split
import XCTest

class HttpClientMock: HttpClient {
class HttpClientMock: HttpClient, @unchecked Sendable {

var throwOnSend = false
var httpDataRequest: HttpDataRequest!
Expand Down
4 changes: 4 additions & 0 deletions SplitTests/Fake/Network/TelemetryProducerStub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class TelemetryStorageStub: TelemetryStorage {
var methodLatencies = [TelemetryMethod: Int]()
var impressions = [TelemetryImpressionsDataType: Int]()
var events = [TelemetryEventsDataType: Int]()

var lock = NSLock()

var isFactoryDataRecorded = Atomic<Bool>(false)

Expand Down Expand Up @@ -148,6 +150,8 @@ class TelemetryStorageStub: TelemetryStorage {
}

func popTags() -> [String] {
lock.lock()
defer { lock.unlock() }
popTagsCallCount+=1
return []
}
Expand Down
2 changes: 1 addition & 1 deletion SplitTests/Fake/Service/NotificationHelperStub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
@testable import Split

class NotificationHelperStub: NotificationHelper {
class NotificationHelperStub: NotificationHelper, @unchecked Sendable {
private let queue = DispatchQueue(label: UUID.init().uuidString, attributes: .concurrent)
private var actions = [String: [ObserverAction]]()

Expand Down
2 changes: 1 addition & 1 deletion SplitTests/Fake/Service/TlsPinCheckerMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
@testable import Split

class PinCheckerMock: TlsPinChecker {
class PinCheckerMock: TlsPinChecker, @unchecked Sendable {
var pinResults = [CredentialValidationResult]()
private var respIndex = -1

Expand Down
7 changes: 6 additions & 1 deletion SplitTests/Fake/Storage/IntegrationCoreDataHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ class IntegrationCoreDataHelper {
}
}

private static var obsCrud = [String: DbRowNotification]()
#if swift(>=6.0)
nonisolated(unsafe) private static var obsCrud = [String: DbRowNotification]()
#else
private static var obsCrud = [String: DbRowNotification]()
#endif


static func getDbExp(count: Int, entity: CoreDataEntity, operation: String) -> XCTestExpectation {
let row = DbRowNotification(expectation: XCTestExpectation(description: "\(operation)_count: \(count)"), triggerCount: count)
Expand Down
4 changes: 4 additions & 0 deletions SplitTests/Fake/Storage/MySegmentsStorageStub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class MySegmentsStorageStub: MySegmentsStorage {
var getCountByKeyCalledCount = 0
var getCountCalledCount = 0
var changeNumber: Int64 = -1

var lock = NSLock()

var keys: Set<String> {
return Set(segments.keys.map { $0 })
Expand Down Expand Up @@ -69,6 +71,8 @@ class MySegmentsStorageStub: MySegmentsStorage {
}

func getCount() -> Int {
lock.lock()
defer { lock.unlock() }
getCountCalledCount+=1
var count = 0
for (_, value) in segments {
Expand Down
12 changes: 6 additions & 6 deletions SplitTests/Helpers/IntegrationHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class IntegrationHelper {
ServiceEndpoints.builder().set(sdkEndpoint: mockEndPoint).set(eventsEndpoint: mockEndPoint).build()
}

static var dummyApiKey = "99049fd8653247c5ea42bc3c1ae2c6a42bc3"
static let dummyApiKey = "99049fd8653247c5ea42bc3c1ae2c6a42bc3"

static var dummyFolderName = "2a1099049fd8653247c5ea42bOIajMRhH0R0FcBwJZM4ca7zj6HAq1ZDS"
static let dummyFolderName = "2a1099049fd8653247c5ea42bOIajMRhH0R0FcBwJZM4ca7zj6HAq1ZDS"

static var dummyUserKey = "CUSTOMER_ID"
static let dummyUserKey = "CUSTOMER_ID"

static var mockEndPoint = "http://localhost:8080"
static let mockEndPoint = "http://localhost:8080"

static var emptyMySegments: String {
"""
Expand All @@ -35,7 +35,7 @@ class IntegrationHelper {
"""
}

static var emptySplitChanges = "{\"ff\": {\"d\":[], \"s\": 9567456937865, \"t\": 9567456937869 }, \"rbs\": {\"d\":[], \"s\": -1, \"t\": -1 }}"
static let emptySplitChanges = "{\"ff\": {\"d\":[], \"s\": 9567456937865, \"t\": 9567456937869 }, \"rbs\": {\"d\":[], \"s\": -1, \"t\": -1 }}"

static func emptySplitChanges(since: Int, till: Int) -> String {
"{\"ff\": {\"d\":[], \"s\": \(since), \"t\": \(till) }, \"rbs\": {\"d\":[], \"s\": \(since), \"t\": \(till) }}"
Expand Down Expand Up @@ -219,7 +219,7 @@ class IntegrationHelper {
}
}

static var dummyCipherKey = String("11F17550-01EA-45").dataBytes!
static let dummyCipherKey = String("11F17550-01EA-45").dataBytes!
}

// MARK: Simplest SDK Factory
Expand Down
2 changes: 1 addition & 1 deletion SplitTests/Helpers/SecurityHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class SecurityHelper {

}

class ChallengeSenderMock: NSObject, URLAuthenticationChallengeSender {
class ChallengeSenderMock: NSObject, URLAuthenticationChallengeSender, @unchecked Sendable {
func use(_ credential: URLCredential, for challenge: URLAuthenticationChallenge) {}
func continueWithoutCredential(for challenge: URLAuthenticationChallenge) {}
func cancel(_ challenge: URLAuthenticationChallenge) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ class HttpRequestManagerTests: XCTestCase {
let manager = createRequestManager()
var notifications = [String]()
var results = [CredentialValidationResult: URLSession.AuthChallengeDisposition]()

let notificationsQueue = DispatchQueue(label: "notifications.queue")

notificationHelper.addObserver(for: .pinnedCredentialValidationFail) { info in
guard let info = info as? String else {
XCTFail()
return
}
notifications.append(info)
notificationsQueue.sync {
notifications.append(info)
}
}

for result in CredentialValidationResult.allCases {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,18 @@ class TelemetryStatsRecorderWorkerTests: XCTestCase {
}
}

let semaphore = DispatchSemaphore(value: 0)
let exp = XCTestExpectation(description: "Waiting for all flushes")

group.notify(queue: queue) {
XCTAssertEqual(6, self.statsRecorder.executeCallCount)
XCTAssertNotNil(self.statsRecorder.statsSent)
XCTAssertEqual(6, self.splitsStorage.getCountCalledCount)
XCTAssertEqual(6, self.mySegmentsStorage.getCountCalledCount)
XCTAssertEqual(6, self.myLargeSegmentsStorage.getCountCalledCount)
XCTAssertEqual(6, self.telemetryStorage.popTagsCallCount)
semaphore.signal()
exp.fulfill()
}

semaphore.wait()
wait(for: [exp], timeout: 4)
}
}
2 changes: 1 addition & 1 deletion SplitTests/SplitEventsManagerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class SplitEventsManagerTest: XCTestCase {
}
}

class TestTask: SplitEventTask {
class TestTask: SplitEventTask, @unchecked Sendable {

var event: SplitEvent = .sdkReady

Expand Down
18 changes: 10 additions & 8 deletions SplitTests/Streaming/SyncManagerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,21 +216,23 @@ class SyncManagerTest: XCTestCase {
.set(telemetryServiceEndpoint: endpoints[3])
.set(eventsEndpoint: endpoints[4])
.build()
splitConfig.serviceEndpoints = epConfig
splitConfig.serviceEndpoints = epConfig
splitConfig.streamingEnabled = true
var exp: XCTestExpectation?
let nHelper = DefaultNotificationHelper.instance
nHelper.addObserver(for: .pinnedCredentialValidationFail) { host in
exp?.fulfill()
}

for (oIndex, oEndpoint) in endpoints.enumerated() {
exp = XCTestExpectation()
let exp = XCTestExpectation(description: "Expectation for \(oEndpoint)")

let nHelper = DefaultNotificationHelper.instance
nHelper.addObserver(for: .pinnedCredentialValidationFail) { host in
exp.fulfill()
}

synchronizer = SynchronizerStub()
pushManager = PushNotificationManagerStub()
syncManager = createSyncManager()
syncManager.start()
nHelper.post(notification: .pinnedCredentialValidationFail, info: oEndpoint as AnyObject)
wait(for: [exp!], timeout: 5.0)
wait(for: [exp], timeout: 5.0)

print("Evaluating: \(oEndpoint)")
switch oIndex {
Expand Down
Loading