* Separate account registration from push token registration
* Provide better errors when validation fails (e.g. numbers don't match, numbers blank)
* More logging during registration
* Call success after setting phone number to avoid any future race condition
This isn't currently causing problems, but it's unexpected that we'd
mutate the state *after* calling a callback which might inuitively rely
on that state.
* Don't throw exception off thread when device keys 404's
* Better async startup handling
- move processing off main thread
- reduce code duplication
- don't wrap it in a transaction in the future case where we want to
further access the DB
// FREEBIE
48 lines
1.3 KiB
Objective-C
48 lines
1.3 KiB
Objective-C
// Copyright (c) 2016 Open Whisper Systems. All rights reserved.
|
|
|
|
#import "SignalRecipient.h"
|
|
#import "TSStorageManager+keyingMaterial.h"
|
|
#import "TSStorageManager.h"
|
|
#import <XCTest/XCTest.h>
|
|
|
|
@interface SignalRecipientTest : XCTestCase
|
|
|
|
@property (nonatomic) NSString *localNumber;
|
|
|
|
@end
|
|
|
|
@implementation SignalRecipientTest
|
|
|
|
- (void)setUp
|
|
{
|
|
[super setUp];
|
|
self.localNumber = @"+13231231234";
|
|
[[TSStorageManager sharedManager] storePhoneNumber:self.localNumber];
|
|
}
|
|
|
|
- (void)testSelfRecipientWithExistingRecord
|
|
{
|
|
// Sanity Check
|
|
XCTAssertNotNil(self.localNumber);
|
|
[[[SignalRecipient alloc] initWithTextSecureIdentifier:self.localNumber relay:nil supportsVoice:YES] save];
|
|
XCTAssertNotNil([SignalRecipient recipientWithTextSecureIdentifier:self.localNumber]);
|
|
|
|
SignalRecipient *me = [SignalRecipient selfRecipient];
|
|
XCTAssert(me);
|
|
XCTAssertEqualObjects(self.localNumber, me.uniqueId);
|
|
}
|
|
|
|
- (void)testSelfRecipientWithoutExistingRecord
|
|
{
|
|
XCTAssertNotNil(self.localNumber);
|
|
[[SignalRecipient fetchObjectWithUniqueID:self.localNumber] remove];
|
|
// Sanity Check that there's no existing user.
|
|
XCTAssertNil([SignalRecipient recipientWithTextSecureIdentifier:self.localNumber]);
|
|
|
|
SignalRecipient *me = [SignalRecipient selfRecipient];
|
|
XCTAssert(me);
|
|
XCTAssertEqualObjects(self.localNumber, me.uniqueId);
|
|
}
|
|
|
|
@end
|