From 71da3123369e762f5b61d7949b667cdbb9c9cd9b Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 28 Sep 2018 10:56:53 -0400 Subject: [PATCH] Post-SMK ud changes. --- Signal.xcodeproj/project.pbxproj | 2 -- Signal/src/AppDelegate.m | 6 +++++- Signal/src/util/OWSOrphanDataCleaner.m | 4 ++++ Signal/test/util/SearcherTest.swift | 4 ++-- .../SharingThreadPickerViewController.m | 4 ++-- SignalServiceKit/src/Messages/OWSIdentityManager.h | 5 ----- SignalServiceKit/src/Messages/OWSIdentityManager.m | 9 +++++++++ SignalServiceKit/src/Messages/OWSMessageManager.m | 2 +- SignalServiceKit/src/Messages/OWSMessageSender.m | 12 +++++++----- SignalServiceKit/tests/Contacts/ContactSortingTest.m | 4 ++-- 10 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index dee016a60..7072f9334 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -485,7 +485,6 @@ B660F6D41C29868000687D6E /* whisperFake.cer in Resources */ = {isa = PBXBuildFile; fileRef = B660F69F1C29868000687D6E /* whisperFake.cer */; }; B660F6DB1C29868000687D6E /* FunctionalUtilTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B660F6AD1C29868000687D6E /* FunctionalUtilTest.m */; }; B660F6E01C29868000687D6E /* UtilTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B660F6B41C29868000687D6E /* UtilTest.m */; }; - B660F7561C29988E00687D6E /* PushManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B9ECFB198B31BA00C620D3 /* PushManager.m */; }; B66DBF4A19D5BBC8006EA940 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B66DBF4919D5BBC8006EA940 /* Images.xcassets */; }; B67EBF5D19194AC60084CCFD /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = B67EBF5C19194AC60084CCFD /* Settings.bundle */; }; B69CD25119773E79005CE69A /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B69CD25019773E79005CE69A /* XCTest.framework */; }; @@ -3461,7 +3460,6 @@ 3421981C21061D2E00C57195 /* ByteParserTest.swift in Sources */, 34843B26214327C9004DED45 /* OWSOrphanDataCleanerTest.m in Sources */, 45360B901F9527DA00FA666C /* SearcherTest.swift in Sources */, - B660F7561C29988E00687D6E /* PushManager.m in Sources */, 34DB0BED2011548B007B313F /* OWSDatabaseConverterTest.m in Sources */, 34843B2C214FE296004DED45 /* MockEnvironment.m in Sources */, 45360B911F952AA900FA666C /* MarqueeLabel.swift in Sources */, diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index eacb9b06d..5d9437fa1 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -19,7 +19,6 @@ #import "SignalApp.h" #import "SignalsNavigationController.h" #import "ViewControllerUtils.h" -#import #import #import #import @@ -1018,6 +1017,11 @@ static NSTimeInterval launchStartedAt; // it will also run all deferred blocks. [AppReadiness setAppIsReady]; + if (CurrentAppContext().isRunningTests) { + OWSLogVerbose(@"Skipping post-launch logic in tests."); + return; + } + if ([TSAccountManager isRegistered]) { OWSLogInfo(@"localNumber: %@", [TSAccountManager localNumber]); diff --git a/Signal/src/util/OWSOrphanDataCleaner.m b/Signal/src/util/OWSOrphanDataCleaner.m index f7536e7ea..aa9de015b 100644 --- a/Signal/src/util/OWSOrphanDataCleaner.m +++ b/Signal/src/util/OWSOrphanDataCleaner.m @@ -487,6 +487,10 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *); OWSFailDebug(@"can't audit orphan data in app extensions."); return; } + if (CurrentAppContext().isRunningTests) { + OWSLogVerbose(@"Ignoring audit orphan data in tests."); + return; + } // Orphan cleanup has two risks: // diff --git a/Signal/test/util/SearcherTest.swift b/Signal/test/util/SearcherTest.swift index f9caa297c..5c2334246 100644 --- a/Signal/test/util/SearcherTest.swift +++ b/Signal/test/util/SearcherTest.swift @@ -51,8 +51,8 @@ class ConversationSearcherContactsManager: NSObject, ContactsManagerProtocol { } } -let bobRecipientId = "+49030183000" -let aliceRecipientId = "+12345678900" +private let bobRecipientId = "+49030183000" +private let aliceRecipientId = "+12345678900" class ConversationSearcherTest: SignalBaseTest { diff --git a/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m b/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m index 52e7a6094..277332f85 100644 --- a/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m +++ b/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m @@ -497,8 +497,8 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion); } case OWSVerificationStateNoLongerVerified: { OWSLogInfo(@"marked recipient: %@ as default verification status.", recipientId); - NSData *identityKey = - [[OWSIdentityManager sharedManager] identityKeyForRecipientId:recipientId transaction:transaction]; + NSData *identityKey = [[OWSIdentityManager sharedManager] identityKeyForRecipientId:recipientId + protocolContext:transaction]; OWSAssertDebug(identityKey); [[OWSIdentityManager sharedManager] setVerificationState:OWSVerificationStateDefault identityKey:identityKey diff --git a/SignalServiceKit/src/Messages/OWSIdentityManager.h b/SignalServiceKit/src/Messages/OWSIdentityManager.h index 26964853c..77a5bc90b 100644 --- a/SignalServiceKit/src/Messages/OWSIdentityManager.h +++ b/SignalServiceKit/src/Messages/OWSIdentityManager.h @@ -31,11 +31,6 @@ extern const NSUInteger kIdentityKeyLength; - (void)generateNewIdentityKey; -- (nullable NSData *)identityKeyForRecipientId:(NSString *)recipientId; - -- (nullable NSData *)identityKeyForRecipientId:(NSString *)recipientId - transaction:(YapDatabaseReadTransaction *)transaction; - - (void)setVerificationState:(OWSVerificationState)verificationState identityKey:(NSData *)identityKey recipientId:(NSString *)recipientId diff --git a/SignalServiceKit/src/Messages/OWSIdentityManager.m b/SignalServiceKit/src/Messages/OWSIdentityManager.m index 58d2bb461..06ecc7b89 100644 --- a/SignalServiceKit/src/Messages/OWSIdentityManager.m +++ b/SignalServiceKit/src/Messages/OWSIdentityManager.m @@ -129,6 +129,15 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa return result; } +- (nullable NSData *)identityKeyForRecipientId:(NSString *)recipientId protocolContext:(nullable id)protocolContext +{ + OWSAssertDebug([protocolContext isKindOfClass:[YapDatabaseReadTransaction class]]); + + YapDatabaseReadTransaction *transaction = protocolContext; + + return [self identityKeyForRecipientId:recipientId transaction:transaction]; +} + - (nullable NSData *)identityKeyForRecipientId:(NSString *)recipientId transaction:(YapDatabaseReadTransaction *)transaction { diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index a5e793a18..2d167dffb 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -955,7 +955,7 @@ NS_ASSUME_NONNULL_BEGIN } NSData *profileKey = dataMessage.profileKey; if (profileKey.length != kAES256_KeyByteLength) { - OWSFailDebug(@"received profile key of unexpected length:%lu from:%@", + OWSFailDebug(@"received profile key of unexpected length: %lu, from: %@", (unsigned long)profileKey.length, envelopeAddress(envelope)); return; diff --git a/SignalServiceKit/src/Messages/OWSMessageSender.m b/SignalServiceKit/src/Messages/OWSMessageSender.m index 3cf5a3f3d..6b2d42daa 100644 --- a/SignalServiceKit/src/Messages/OWSMessageSender.m +++ b/SignalServiceKit/src/Messages/OWSMessageSender.m @@ -1402,12 +1402,14 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; - (TSWhisperMessageType)messageTypeForCipherMessage:(id)cipherMessage { - if ([cipherMessage isKindOfClass:[PreKeyWhisperMessage class]]) { - return TSPreKeyWhisperMessageType; - } else if ([cipherMessage isKindOfClass:[WhisperMessage class]]) { - return TSEncryptedWhisperMessageType; + switch (cipherMessage.cipherMessageType) { + case CipherMessageType_Whisper: + return TSEncryptedWhisperMessageType; + case CipherMessageType_Prekey: + return TSPreKeyWhisperMessageType; + default: + return TSUnknownMessageType; } - return TSUnknownMessageType; } - (void)saveGroupMessage:(TSOutgoingMessage *)message inThread:(TSThread *)thread diff --git a/SignalServiceKit/tests/Contacts/ContactSortingTest.m b/SignalServiceKit/tests/Contacts/ContactSortingTest.m index c6454d9e2..9340e1866 100644 --- a/SignalServiceKit/tests/Contacts/ContactSortingTest.m +++ b/SignalServiceKit/tests/Contacts/ContactSortingTest.m @@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN Contact *b = resortedContacts[j]; BOOL correct = ([a.firstName isEqualToString:b.firstName] && [a.lastName isEqualToString:b.lastName]); if (!correct) { - XCTAssert(@"Contacts failed to sort names by first, last"); + XCTFail(@"Contacts failed to sort names by first, last"); break; } } @@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN Contact *b = resortedContacts[j]; BOOL correct = ([a.firstName isEqualToString:b.firstName] && [a.lastName isEqualToString:b.lastName]); if (!correct) { - XCTAssert(@"Contacts failed to sort names by last, first"); + XCTFail(@"Contacts failed to sort names by last, first"); break; } }