diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift index 344cceb0c..4f69b6f4e 100644 --- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift +++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift @@ -123,7 +123,9 @@ internal enum OnionRequestAPI { } /// Returns a `Path` to be used for building an onion request. Builds new paths as needed. - private static func getPath(excluding snode: LokiAPITarget) -> Promise { + /// + /// - Note: Exposed for testing purposes. + internal static func getPath(excluding snode: LokiAPITarget) -> Promise { guard pathSize >= 1 else { preconditionFailure("Cannot build path of size zero.") } // randomElement() uses the system's default random generator, which is cryptographically secure if paths.count >= pathCount { @@ -199,10 +201,8 @@ internal enum OnionRequestAPI { let gcm = GCM(iv: iv.bytes, tagLength: Int(gcmTagSize), mode: .combined) let aes = try AES(key: targetSnodeSymmetricKey.bytes, blockMode: gcm, padding: .pkcs7) let result = try aes.decrypt(ciphertext.bytes) - print("[Loki] [Onion Request API] Succeeded with result: \(String(data: Data(bytes: result), encoding: .utf8)!).") seal.fulfill(Data(bytes: result)) } catch (let error) { - print("[Loki] [Onion Request API] Decryption failed.") seal.reject(error) } }.catch(on: workQueue) { error in diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPITests.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPITests.swift index 3620ae028..e8ce2f31e 100644 --- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPITests.swift +++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPITests.swift @@ -9,7 +9,7 @@ class OnionRequestAPITests : XCTestCase { func testOnionRequestSending() { let semaphore = DispatchSemaphore(value: 0) LokiAPI.getRandomSnode().then(on: OnionRequestAPI.workQueue) { snode -> Promise in - return OnionRequestAPI.getPath().map(on: OnionRequestAPI.workQueue) { _ in snode } + return OnionRequestAPI.getPath(excluding: snode).map(on: OnionRequestAPI.workQueue) { _ in snode } }.done(on: OnionRequestAPI.workQueue) { snode in var successCount = 0 var failureCount = 0