Fixed some broken tests and removed remaining remnants of the 'syncExpiries' job

pull/941/head
Morgan Pretty 1 year ago
parent 5e3dd3c731
commit 593acd8e37

@ -51,6 +51,7 @@ public struct Contact: Codable, Identifiable, Equatable, FetchableRecord, Persis
// MARK: - Initialization
public init(
_ db: Database? = nil,
id: String,
isTrusted: Bool = false,
isApproved: Bool = false,
@ -62,7 +63,7 @@ public struct Contact: Codable, Identifiable, Equatable, FetchableRecord, Persis
self.id = id
self.isTrusted = (
isTrusted ||
id == getUserHexEncodedPublicKey() // Always trust ourselves
id == getUserHexEncodedPublicKey(db) // Always trust ourselves
)
self.isApproved = isApproved
self.isBlocked = isBlocked
@ -105,7 +106,7 @@ public extension Contact {
/// **Note:** This method intentionally does **not** save the newly created Contact,
/// it will need to be explicitly saved after calling
static func fetchOrCreate(_ db: Database, id: ID) -> Contact {
return ((try? fetchOne(db, id: id)) ?? Contact(id: id))
return ((try? fetchOne(db, id: id)) ?? Contact(db, id: id))
}
}

@ -234,7 +234,9 @@ class OpenGroupManagerSpec: QuickSpec {
mockGeneralCache.when { $0.encodedPublicKey }.thenReturn("05\(TestConstants.publicKey)")
mockGenericHash.when { $0.hash(message: anyArray(), outputLength: any()) }.thenReturn([])
mockSodium
.when { $0.blindedKeyPair(serverPublicKey: any(), edKeyPair: any(), genericHash: mockGenericHash) }
.when { [mockGenericHash] mock in
mock.blindedKeyPair(serverPublicKey: any(), edKeyPair: any(), genericHash: mockGenericHash!)
}
.thenReturn(
Box.KeyPair(
publicKey: Data.data(fromHex: TestConstants.publicKey)!.bytes,
@ -3568,11 +3570,11 @@ class OpenGroupManagerSpec: QuickSpec {
it("adds the image retrieval promise to the cache") {
class TestNeverReturningApi: OnionRequestAPIType {
static func sendOnionRequest(_ request: URLRequest, to server: String, using version: OnionRequestAPIVersion, with x25519PublicKey: String) -> Promise<(OnionRequestResponseInfoType, Data?)> {
static func sendOnionRequest(_ request: URLRequest, to server: String, using version: OnionRequestAPIVersion, with x25519PublicKey: String, timeout: TimeInterval) -> Promise<(OnionRequestResponseInfoType, Data?)> {
return Promise<(OnionRequestResponseInfoType, Data?)>.pending().promise
}
static func sendOnionRequest(to snode: Snode, invoking method: SnodeAPIEndpoint, with parameters: JSON, associatedWith publicKey: String?) -> Promise<Data> {
static func sendOnionRequest(to snode: Snode, invoking method: SnodeAPIEndpoint, with parameters: JSON, associatedWith publicKey: String?, timeout: TimeInterval) -> Promise<Data> {
return Promise.value(Data())
}
}

@ -34,7 +34,7 @@ class TestOnionRequestAPI: OnionRequestAPIType {
class var mockResponse: Data? { return nil }
static func sendOnionRequest(_ request: URLRequest, to server: String, using version: OnionRequestAPIVersion, with x25519PublicKey: String) -> Promise<(OnionRequestResponseInfoType, Data?)> {
static func sendOnionRequest(_ request: URLRequest, to server: String, using version: OnionRequestAPIVersion, with x25519PublicKey: String, timeout: TimeInterval) -> Promise<(OnionRequestResponseInfoType, Data?)> {
let responseInfo: ResponseInfo = ResponseInfo(
requestData: RequestData(
urlString: request.url?.absoluteString,
@ -54,7 +54,7 @@ class TestOnionRequestAPI: OnionRequestAPIType {
return Promise.value((responseInfo, mockResponse))
}
static func sendOnionRequest(to snode: Snode, invoking method: SnodeAPIEndpoint, with parameters: JSON, associatedWith publicKey: String?) -> Promise<Data> {
static func sendOnionRequest(to snode: Snode, invoking method: SnodeAPIEndpoint, with parameters: JSON, associatedWith publicKey: String?, timeout: TimeInterval) -> Promise<Data> {
return Promise.value(mockResponse!)
}
}

@ -92,7 +92,9 @@ class ThreadDisappearingMessagesViewModelSpec: QuickSpec {
title: "DISAPPEARING_MESSAGES_OFF".localized(),
rightAccessory: .radio(
isSelected: { true }
)
),
accessibilityIdentifier: "Off option",
accessibilityLabel: "Off option"
)
)
)
@ -138,7 +140,9 @@ class ThreadDisappearingMessagesViewModelSpec: QuickSpec {
title: "DISAPPEARING_MESSAGES_OFF".localized(),
rightAccessory: .radio(
isSelected: { false }
)
),
accessibilityIdentifier: "Off option",
accessibilityLabel: "Off option"
)
)
)
@ -173,7 +177,9 @@ class ThreadDisappearingMessagesViewModelSpec: QuickSpec {
title: title,
rightAccessory: .radio(
isSelected: { true }
)
),
accessibilityIdentifier: "Time option",
accessibilityLabel: "Time option"
)
)
)
@ -192,7 +198,7 @@ class ThreadDisappearingMessagesViewModelSpec: QuickSpec {
)
)
expect(footerButtonInfo).to(equal(nil))
expect(footerButtonInfo).to(beNil())
}
context("when changed from the previous setting") {

@ -228,7 +228,7 @@ class ThreadSettingsViewModelSpec: QuickSpec {
ParentType.NavItem(
id: .cancel,
systemItem: .cancel,
accessibilityIdentifier: "Cancel"
accessibilityIdentifier: "Cancel button"
)
]))
expect(viewModel.rightNavItems.firstValue())

@ -106,10 +106,6 @@ public struct Job: Codable, Equatable, Hashable, Identifiable, FetchableRecord,
/// This is a job that runs once whenever the user leaves a group to send a group leaving message, remove group
/// record and group member record
case groupLeaving
/// This is a job that runs once whenever some disappearing messages is read and started the timer to inform
/// linked devices and the network for the change of the messages's ttl
case syncExpires
}
public enum Behaviour: Int, Codable, DatabaseValueConvertible, CaseIterable {

@ -267,7 +267,7 @@ open class Storage {
// after device restart until device is unlocked for the first time. If the app receives a push
// notification, we won't be able to access the keychain to process that notification, so we should
// just terminate by throwing an uncaught exception
if CurrentAppContext().isMainApp || CurrentAppContext().isInBackground() {
if HasAppContext() && (CurrentAppContext().isMainApp || CurrentAppContext().isInBackground()) {
let appState: UIApplication.State = CurrentAppContext().reportedApplicationState
// In this case we should have already detected the situation earlier and exited gracefully (in the

@ -90,14 +90,6 @@ public final class JobRunner {
jobVariants.remove(.attachmentDownload)
].compactMap { $0 }
)
let syncExpiriesQueue: JobQueue = JobQueue(
type: .syncExpiries,
executionType: .concurrent, // Allow as many jobs to run at once as supported by the device
qos: .default,
jobVariants: [
jobVariants.remove(.syncExpires)
].compactMap { $0 }
)
let generalQueue: JobQueue = JobQueue(
type: .general(number: 0),
qos: .utility,
@ -108,7 +100,6 @@ public final class JobRunner {
messageSendQueue,
messageReceiveQueue,
attachmentDownloadQueue,
syncExpiriesQueue,
generalQueue
].reduce(into: [:]) { prev, next in
next.jobVariants.forEach { variant in
@ -417,7 +408,6 @@ private final class JobQueue {
case messageSend
case messageReceive
case attachmentDownload
case syncExpiries
var name: String {
switch self {
@ -426,7 +416,6 @@ private final class JobQueue {
case .messageSend: return "MessageSend"
case .messageReceive: return "MessageReceive"
case .attachmentDownload: return "AttachmentDownload"
case .syncExpiries: return "SyncExpiries"
}
}
}

Loading…
Cancel
Save