Signal-iOS/SignalServiceKit/tests/SSKBaseTestSwift.swift
Jordan Rose a2edd320bb OWSMessageDecrypter should use destinationUuid to choose local stores
Note that on its own this doesn't change behavior of the app;
OWSMessageProcessor still drops non-ACI messages even attempting to
decrypt them.
2022-04-14 16:47:46 -07:00

54 lines
1.2 KiB
Swift

//
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
//
import XCTest
@testable import SignalServiceKit
import CocoaLumberjack
@objc
public class SSKBaseTestSwift: XCTestCase {
@objc
public override func setUp() {
super.setUp()
DDLog.add(DDTTYLogger.sharedInstance!)
ClearCurrentAppContextForTests()
SetCurrentAppContext(TestAppContext())
MockSSKEnvironment.activate()
GroupManager.forceV1Groups()
}
@objc
public override func tearDown() {
AssertIsOnMainThread()
// Spin the main run loop to flush any remaining async work.
var done = false
DispatchQueue.main.async { done = true }
while !done {
CFRunLoopRunInMode(.defaultMode, 0.0, true)
}
super.tearDown()
}
@objc
public func read(_ block: (SDSAnyReadTransaction) -> Void) {
return databaseStorage.read(block: block)
}
public func write<T>(_ block: (SDSAnyWriteTransaction) -> T) -> T {
return databaseStorage.write(block: block)
}
@objc
public func asyncWrite(_ block: @escaping (SDSAnyWriteTransaction) -> Void) {
return databaseStorage.asyncWrite(block: block)
}
}