From 3c2109e69873f24b5736ce6f095933471514e6fd Mon Sep 17 00:00:00 2001 From: gmbnt Date: Fri, 3 Apr 2020 15:05:57 +1100 Subject: [PATCH] Minor refactoring --- SignalServiceKit/src/Loki/API/HTTP/HTTP.swift | 6 +++++- .../Loki/API/Onion Requests/OnionRequestAPITests.swift | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/SignalServiceKit/src/Loki/API/HTTP/HTTP.swift b/SignalServiceKit/src/Loki/API/HTTP/HTTP.swift index 47126029e..1a9aea185 100644 --- a/SignalServiceKit/src/Loki/API/HTTP/HTTP.swift +++ b/SignalServiceKit/src/Loki/API/HTTP/HTTP.swift @@ -56,7 +56,11 @@ internal enum HTTP { request.timeoutInterval = timeout let task = urlSession.dataTask(with: request) { data, response, error in guard let data = data, let response = response as? HTTPURLResponse else { - print("[Loki] \(verb.rawValue) request to \(url) failed.") + if let error = error { + print("[Loki] \(verb.rawValue) request to \(url) failed due to error: \(error).") + } else { + print("[Loki] \(verb.rawValue) request to \(url) failed.") + } return seal.reject(error ?? Error.generic) } if let error = error { diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPITests.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPITests.swift index d5c62d8f4..04b540baf 100644 --- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPITests.swift +++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPITests.swift @@ -25,19 +25,19 @@ class OnionRequestAPITests : XCTestCase { seal.fulfill(()) }.catch(on: OnionRequestAPI.workQueue) { error in if case GCM.Error.fail = error { - print("[Loki] [Onion Request API] Onion request failed due a decryption error.") + print("[Loki] [Onion Request API] Onion request failed due to a decryption error.") } else { print("[Loki] [Onion Request API] Onion request failed due to error: \(error).") } seal.reject(error) }.finally(on: OnionRequestAPI.workQueue) { - let currentSuccessRate = min((100 * Double(successCount))/Double(testCount), 100) - print("[Loki] [Onion Request API] Current onion request succes rate: \(String(format: "%.1f", currentSuccessRate))%.") + let currentSuccessRate = min((100 * Double(successCount)) / Double(testCount), 100) + print("[Loki] [Onion Request API] Current onion request success rate: \(String(format: "%.1f", currentSuccessRate))%.") } return promise } when(resolved: promises).done(on: OnionRequestAPI.workQueue) { _ in - totalSuccessRate = min((100 * Double(successCount))/Double(testCount), 100) + totalSuccessRate = min((100 * Double(successCount)) / Double(testCount), 100) semaphore.signal() } }.catch(on: OnionRequestAPI.workQueue) { error in @@ -45,7 +45,7 @@ class OnionRequestAPITests : XCTestCase { semaphore.signal() } semaphore.wait() - print("[Loki] [Onion Request API] Total onion request succes rate: \(String(format: "%.1f", totalSuccessRate))%.") + print("[Loki] [Onion Request API] Total onion request success rate: \(String(format: "%.1f", totalSuccessRate))%.") XCTAssert(totalSuccessRate >= 90) }