Fix Swift/Obj-C interop

pull/182/head
nielsandriesse 4 years ago
parent 6fca0779e5
commit 2190c98ba1

@ -13,7 +13,7 @@ class FriendRequestProtocolTests : XCTestCase {
override func setUp() {
super.setUp()
LokiTestUtilities.setupMockEnvironment()
LokiTestUtilities.setUpMockEnvironment()
}
// MARK: - Helpers

@ -261,8 +261,9 @@ public final class MultiDeviceProtocol : NSObject {
}
}
// MARK: - General
@objc public static func isSlaveThread(_ thread: TSThread) -> Bool {
guard let thread = thread as? TSContactThread else { return false; }
guard let thread = thread as? TSContactThread else { return false }
var isSlaveThread = false
Storage.read { transaction in
isSlaveThread = storage.getMasterHexEncodedPublicKey(for: thread.contactIdentifier(), in: transaction) != nil

@ -9,7 +9,7 @@ class SyncMessagesProtocolTests : XCTestCase {
override func setUp() {
super.setUp()
LokiTestUtilities.setupMockEnvironment()
LokiTestUtilities.setUpMockEnvironment()
}
func testContactSyncMessageHandling() {

@ -2,14 +2,14 @@ import Foundation
import SignalServiceKit
import Curve25519Kit
@objc(LKTestUtilities)
class LokiTestUtilities : NSObject {
enum LokiTestUtilities {
@objc public static func setupMockEnvironment() {
public static func setUpMockEnvironment() {
// Activate the mock Signal environment
ClearCurrentAppContextForTests()
SetCurrentAppContext(TestAppContext())
MockSSKEnvironment.activate()
// Register a mock user
let identityManager = OWSIdentityManager.shared()
let seed = Randomness.generateRandomBytes(16)!
let keyPair = Curve25519.generateKeyPair(fromSeed: seed + seed)
@ -19,29 +19,25 @@ class LokiTestUtilities : NSObject {
TSAccountManager.sharedInstance().didRegister()
}
@objc public static func generateKeyPair() -> ECKeyPair {
public static func generateKeyPair() -> ECKeyPair {
return Curve25519.generateKeyPair()
}
@objc public static func generateHexEncodedPublicKey() -> String {
public static func generateHexEncodedPublicKey() -> String {
return generateKeyPair().hexEncodedPublicKey
}
@objc(getDeviceForHexEncodedPublicKey:)
public static func getDevice(for hexEncodedPublicKey: String) -> DeviceLink.Device? {
guard let signature = Data.getSecureRandomData(ofSize: 64) else { return nil }
return DeviceLink.Device(hexEncodedPublicKey: hexEncodedPublicKey, signature: signature)
}
@objc(createContactThreadForHexEncodedPublicKey:)
public static func createContactThread(for hexEncodedPublicKey: String) -> TSContactThread {
return TSContactThread.getOrCreateThread(contactId: hexEncodedPublicKey)
}
@objc(createGroupThreadWithGroupType:)
public static func createGroupThread(groupType: GroupType) -> TSGroupThread? {
let hexEncodedGroupID = Randomness.generateRandomBytes(kGroupIdLength)!.toHexString()
let groupID: Data
switch groupType {
case .closedGroup: groupID = LKGroupUtilities.getEncodedClosedGroupIDAsData(hexEncodedGroupID)
@ -49,7 +45,6 @@ class LokiTestUtilities : NSObject {
case .rssFeed: groupID = LKGroupUtilities.getEncodedRSSFeedIDAsData(hexEncodedGroupID)
default: return nil
}
return TSGroupThread.getOrCreateThread(withGroupId: groupID, groupType: groupType)
}
}
Loading…
Cancel
Save