2017-09-22 06:31:13 +02:00
|
|
|
//
|
2018-02-13 07:10:29 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-09-22 06:31:13 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "DebugUIStress.h"
|
|
|
|
#import "OWSMessageSender.h"
|
|
|
|
#import "OWSTableViewController.h"
|
2017-12-01 21:17:29 +01:00
|
|
|
#import "SignalApp.h"
|
2017-09-22 06:31:13 +02:00
|
|
|
#import "ThreadUtil.h"
|
2018-09-25 19:09:55 +02:00
|
|
|
#import <SignalCoreKit/Cryptography.h>
|
2018-09-21 21:41:10 +02:00
|
|
|
#import <SignalCoreKit/NSDate+OWS.h>
|
2018-09-25 18:49:02 +02:00
|
|
|
#import <SignalCoreKit/Randomness.h>
|
2017-12-19 03:50:51 +01:00
|
|
|
#import <SignalMessaging/Environment.h>
|
2017-09-22 06:31:13 +02:00
|
|
|
#import <SignalServiceKit/OWSDynamicOutgoingMessage.h>
|
2018-03-05 15:30:58 +01:00
|
|
|
#import <SignalServiceKit/OWSPrimaryStorage.h>
|
2018-08-02 19:43:21 +02:00
|
|
|
#import <SignalServiceKit/SignalServiceKit-Swift.h>
|
2017-09-22 06:31:13 +02:00
|
|
|
#import <SignalServiceKit/TSGroupThread.h>
|
|
|
|
#import <SignalServiceKit/TSThread.h>
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
@implementation DebugUIStress
|
|
|
|
|
|
|
|
#pragma mark - Factory Methods
|
|
|
|
|
|
|
|
- (NSString *)name
|
|
|
|
{
|
|
|
|
return @"Stress";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (nullable OWSTableSection *)sectionForThread:(nullable TSThread *)thread
|
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(thread);
|
2017-09-22 06:31:13 +02:00
|
|
|
|
|
|
|
NSMutableArray<OWSTableItem *> *items = [NSMutableArray new];
|
2018-08-30 16:03:14 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
2017-09-22 06:31:13 +02:00
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send empty message"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress sendStressMessage:thread block:^(SignalRecipient *recipient) {
|
|
|
|
return [NSData new];
|
|
|
|
}];
|
|
|
|
}]];
|
2017-09-22 16:30:35 +02:00
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send random noise message"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
|
|
|
NSUInteger contentLength = arc4random_uniform(32);
|
|
|
|
return [Cryptography generateRandomBytes:contentLength];
|
|
|
|
}];
|
|
|
|
}]];
|
2017-09-22 06:31:13 +02:00
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send no payload message"
|
|
|
|
actionBlock:^{
|
2018-08-02 19:43:21 +02:00
|
|
|
[DebugUIStress sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
|
|
|
SSKProtoContentBuilder *contentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
|
|
|
}];
|
2017-09-22 06:31:13 +02:00
|
|
|
}]];
|
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send empty null message"
|
|
|
|
actionBlock:^{
|
2018-08-02 19:43:21 +02:00
|
|
|
[DebugUIStress sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
|
|
|
SSKProtoContentBuilder *contentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoNullMessageBuilder *nullMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoNullMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
contentBuilder.nullMessage =
|
|
|
|
[nullMessageBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send random null message"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
|
|
|
SSKProtoContentBuilder *contentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoNullMessageBuilder *nullMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoNullMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
NSUInteger contentLength = arc4random_uniform(32);
|
|
|
|
nullMessageBuilder.padding =
|
|
|
|
[Cryptography generateRandomBytes:contentLength];
|
|
|
|
contentBuilder.nullMessage =
|
|
|
|
[nullMessageBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send empty sync message"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
|
|
|
SSKProtoContentBuilder *contentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageBuilder *syncMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
contentBuilder.syncMessage =
|
|
|
|
[syncMessageBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send empty sync sent message"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
|
|
|
SSKProtoContentBuilder *contentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageBuilder *syncMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageSentBuilder *sentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessageSent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
syncMessageBuilder.sent =
|
|
|
|
[sentBuilder buildIgnoringErrors];
|
|
|
|
contentBuilder.syncMessage =
|
|
|
|
[syncMessageBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
|
|
|
}];
|
2017-09-22 06:31:13 +02:00
|
|
|
}]];
|
2017-09-22 16:30:35 +02:00
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send whitespace text data message"
|
2017-09-22 06:31:13 +02:00
|
|
|
actionBlock:^{
|
2017-09-22 16:30:35 +02:00
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoDataMessage builder];
|
2017-09-22 16:30:35 +02:00
|
|
|
dataBuilder.body = @" ";
|
|
|
|
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder
|
|
|
|
thread:thread];
|
2018-08-02 19:43:21 +02:00
|
|
|
contentBuilder.dataMessage =
|
|
|
|
[dataBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
2017-09-22 16:30:35 +02:00
|
|
|
}];
|
|
|
|
}]];
|
2018-08-02 19:43:21 +02:00
|
|
|
[items
|
|
|
|
addObject:[OWSTableItem
|
|
|
|
itemWithTitle:@"Send bad attachment data message"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
|
|
|
SSKProtoDataMessageBuilder *dataBuilder = [SSKProtoDataMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoAttachmentPointerBuilder *attachmentPointer =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoAttachmentPointer
|
|
|
|
builderWithId:arc4random_uniform(32) + 1];
|
2018-08-02 19:43:21 +02:00
|
|
|
[attachmentPointer setContentType:@"1"];
|
|
|
|
[attachmentPointer setSize:arc4random_uniform(32) + 1];
|
|
|
|
[attachmentPointer setDigest:[Cryptography generateRandomBytes:1]];
|
|
|
|
[attachmentPointer setFileName:@" "];
|
|
|
|
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
|
|
|
contentBuilder.dataMessage = [dataBuilder buildIgnoringErrors];
|
|
|
|
return
|
|
|
|
[[contentBuilder buildIgnoringErrors] serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
2017-09-22 16:30:35 +02:00
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send normal text data message"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoDataMessage builder];
|
2017-09-22 16:30:35 +02:00
|
|
|
dataBuilder.body = @"alice";
|
|
|
|
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder
|
|
|
|
thread:thread];
|
2018-08-02 19:43:21 +02:00
|
|
|
contentBuilder.dataMessage =
|
|
|
|
[dataBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
2017-09-22 16:30:35 +02:00
|
|
|
}];
|
|
|
|
}]];
|
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send N text messages with same timestamp"
|
|
|
|
actionBlock:^{
|
|
|
|
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
timestamp:timestamp
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoDataMessage builder];
|
2017-09-22 16:30:35 +02:00
|
|
|
dataBuilder.body = [NSString stringWithFormat:@"%@ %d",
|
|
|
|
[NSUUID UUID].UUIDString,
|
|
|
|
i];
|
|
|
|
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder
|
|
|
|
thread:thread];
|
2018-08-02 19:43:21 +02:00
|
|
|
contentBuilder.dataMessage =
|
|
|
|
[dataBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
2017-09-22 16:30:35 +02:00
|
|
|
}];
|
|
|
|
}
|
2017-09-22 06:31:13 +02:00
|
|
|
}]];
|
2017-09-22 16:30:35 +02:00
|
|
|
[items addObject:[OWSTableItem
|
|
|
|
itemWithTitle:@"Send text message with current timestamp"
|
|
|
|
actionBlock:^{
|
|
|
|
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
timestamp:timestamp
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoDataMessage builder];
|
2017-09-22 16:30:35 +02:00
|
|
|
dataBuilder.body =
|
|
|
|
[[NSUUID UUID].UUIDString stringByAppendingString:@" now"];
|
|
|
|
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
2018-08-02 19:43:21 +02:00
|
|
|
contentBuilder.dataMessage = [dataBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
2017-09-22 16:30:35 +02:00
|
|
|
}];
|
|
|
|
}]];
|
|
|
|
[items addObject:[OWSTableItem
|
|
|
|
itemWithTitle:@"Send text message with future timestamp"
|
|
|
|
actionBlock:^{
|
|
|
|
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
|
|
|
timestamp += kHourInMs;
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
timestamp:timestamp
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoDataMessage builder];
|
2017-09-22 16:30:35 +02:00
|
|
|
dataBuilder.body =
|
|
|
|
[[NSUUID UUID].UUIDString stringByAppendingString:@" now"];
|
|
|
|
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
2018-08-02 19:43:21 +02:00
|
|
|
contentBuilder.dataMessage = [dataBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
2017-09-22 16:30:35 +02:00
|
|
|
}];
|
|
|
|
}]];
|
|
|
|
[items addObject:[OWSTableItem
|
|
|
|
itemWithTitle:@"Send text message with past timestamp"
|
|
|
|
actionBlock:^{
|
|
|
|
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
|
|
|
timestamp -= kHourInMs;
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
timestamp:timestamp
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoDataMessage builder];
|
2017-09-22 16:30:35 +02:00
|
|
|
dataBuilder.body =
|
|
|
|
[[NSUUID UUID].UUIDString stringByAppendingString:@" now"];
|
|
|
|
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
2018-08-02 19:43:21 +02:00
|
|
|
contentBuilder.dataMessage = [dataBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
2017-09-22 16:30:35 +02:00
|
|
|
}];
|
|
|
|
}]];
|
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send N text messages with same timestamp"
|
|
|
|
actionBlock:^{
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
|
|
|
SSKProtoDataMessageBuilder *dataBuilder = [SSKProtoDataMessage builder];
|
2017-09-22 16:30:35 +02:00
|
|
|
dataBuilder.body = @"alice";
|
2018-08-02 19:43:21 +02:00
|
|
|
contentBuilder.dataMessage = [dataBuilder buildIgnoringErrors];
|
2017-09-22 16:30:35 +02:00
|
|
|
[DebugUIStress ensureGroupOfDataBuilder:dataBuilder thread:thread];
|
2018-08-02 19:43:21 +02:00
|
|
|
NSData *data =
|
|
|
|
[[contentBuilder buildIgnoringErrors] serializedDataIgnoringErrors];
|
2017-09-22 16:30:35 +02:00
|
|
|
|
|
|
|
uint64_t timestamp = [NSDate ows_millisecondTimeStamp];
|
2017-09-22 06:31:13 +02:00
|
|
|
|
2017-09-22 16:30:35 +02:00
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
[DebugUIStress sendStressMessage:thread
|
|
|
|
timestamp:timestamp
|
|
|
|
block:^(SignalRecipient *recipient) {
|
|
|
|
return data;
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}]];
|
|
|
|
[items
|
2018-08-02 19:43:21 +02:00
|
|
|
addObject:[OWSTableItem
|
|
|
|
itemWithTitle:@"Send malformed sync sent message 1"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageBuilder *syncMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageSentBuilder *sentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessageSent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
sentBuilder.destination = @"abc";
|
|
|
|
sentBuilder.timestamp = arc4random_uniform(32) + 1;
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder = [SSKProtoDataMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
sentBuilder.message = [dataBuilder buildIgnoringErrors];
|
|
|
|
syncMessageBuilder.sent = [sentBuilder buildIgnoringErrors];
|
|
|
|
contentBuilder.syncMessage = [syncMessageBuilder buildIgnoringErrors];
|
|
|
|
return
|
|
|
|
[[contentBuilder buildIgnoringErrors] serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
2017-09-22 16:30:35 +02:00
|
|
|
[items
|
2018-08-02 19:43:21 +02:00
|
|
|
addObject:[OWSTableItem
|
|
|
|
itemWithTitle:@"Send malformed sync sent message 2"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageBuilder *syncMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageSentBuilder *sentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessageSent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
sentBuilder.destination = @"abc";
|
|
|
|
sentBuilder.timestamp = 0;
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder = [SSKProtoDataMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
sentBuilder.message = [dataBuilder buildIgnoringErrors];
|
|
|
|
syncMessageBuilder.sent = [sentBuilder buildIgnoringErrors];
|
|
|
|
contentBuilder.syncMessage = [syncMessageBuilder buildIgnoringErrors];
|
|
|
|
return
|
|
|
|
[[contentBuilder buildIgnoringErrors] serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
2017-09-22 16:30:35 +02:00
|
|
|
[items
|
2018-08-02 19:43:21 +02:00
|
|
|
addObject:[OWSTableItem
|
|
|
|
itemWithTitle:@"Send malformed sync sent message 3"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageBuilder *syncMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageSentBuilder *sentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessageSent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
sentBuilder.destination = @"abc";
|
|
|
|
sentBuilder.timestamp = 0;
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder = [SSKProtoDataMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
dataBuilder.body = @" ";
|
|
|
|
sentBuilder.message = [dataBuilder buildIgnoringErrors];
|
|
|
|
syncMessageBuilder.sent = [sentBuilder buildIgnoringErrors];
|
|
|
|
contentBuilder.syncMessage = [syncMessageBuilder buildIgnoringErrors];
|
|
|
|
return
|
|
|
|
[[contentBuilder buildIgnoringErrors] serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
2017-09-22 16:30:35 +02:00
|
|
|
[items
|
2018-08-02 19:43:21 +02:00
|
|
|
addObject:[OWSTableItem
|
|
|
|
itemWithTitle:@"Send malformed sync sent message 4"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageBuilder *syncMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageSentBuilder *sentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessageSent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
sentBuilder.destination = @"abc";
|
|
|
|
sentBuilder.timestamp = 0;
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder = [SSKProtoDataMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
dataBuilder.body = @" ";
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoGroupContextBuilder *groupBuilder = [SSKProtoGroupContext
|
|
|
|
builderWithId:[Cryptography generateRandomBytes:1]
|
|
|
|
type:SSKProtoGroupContextTypeDeliver];
|
2018-08-02 19:43:21 +02:00
|
|
|
dataBuilder.group = [groupBuilder buildIgnoringErrors];
|
|
|
|
sentBuilder.message = [dataBuilder buildIgnoringErrors];
|
|
|
|
syncMessageBuilder.sent = [sentBuilder buildIgnoringErrors];
|
|
|
|
contentBuilder.syncMessage = [syncMessageBuilder buildIgnoringErrors];
|
|
|
|
return
|
|
|
|
[[contentBuilder buildIgnoringErrors] serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
2017-09-22 16:30:35 +02:00
|
|
|
[items
|
2018-08-02 19:43:21 +02:00
|
|
|
addObject:[OWSTableItem
|
|
|
|
itemWithTitle:@"Send malformed sync sent message 5"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress
|
|
|
|
sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoContentBuilder *contentBuilder = [SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageBuilder *syncMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageSentBuilder *sentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessageSent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
sentBuilder.destination = @"abc";
|
|
|
|
sentBuilder.timestamp = 0;
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoDataMessageBuilder *dataBuilder = [SSKProtoDataMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
dataBuilder.body = @" ";
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoGroupContextBuilder *groupBuilder = [SSKProtoGroupContext
|
|
|
|
builderWithId:[Cryptography generateRandomBytes:1]
|
|
|
|
type:SSKProtoGroupContextTypeDeliver];
|
2018-08-02 19:43:21 +02:00
|
|
|
dataBuilder.group = [groupBuilder buildIgnoringErrors];
|
|
|
|
sentBuilder.message = [dataBuilder buildIgnoringErrors];
|
|
|
|
syncMessageBuilder.sent = [sentBuilder buildIgnoringErrors];
|
|
|
|
contentBuilder.syncMessage = [syncMessageBuilder buildIgnoringErrors];
|
|
|
|
return
|
|
|
|
[[contentBuilder buildIgnoringErrors] serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Send empty sync sent message 6"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress sendStressMessage:thread
|
|
|
|
block:^(SignalRecipient *recipient) {
|
|
|
|
SSKProtoContentBuilder *contentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoContent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageBuilder *syncMessageBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessage builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
SSKProtoSyncMessageSentBuilder *sentBuilder =
|
2018-09-24 15:26:08 +02:00
|
|
|
[SSKProtoSyncMessageSent builder];
|
2018-08-02 19:43:21 +02:00
|
|
|
sentBuilder.destination = @"abc";
|
|
|
|
syncMessageBuilder.sent =
|
|
|
|
[sentBuilder buildIgnoringErrors];
|
|
|
|
contentBuilder.syncMessage =
|
|
|
|
[syncMessageBuilder buildIgnoringErrors];
|
|
|
|
return [[contentBuilder buildIgnoringErrors]
|
|
|
|
serializedDataIgnoringErrors];
|
|
|
|
}];
|
|
|
|
}]];
|
|
|
|
|
2017-09-22 06:31:13 +02:00
|
|
|
if ([thread isKindOfClass:[TSGroupThread class]]) {
|
|
|
|
TSGroupThread *groupThread = (TSGroupThread *)thread;
|
|
|
|
[items addObject:[OWSTableItem itemWithTitle:@"Hallucinate twin group"
|
|
|
|
actionBlock:^{
|
|
|
|
[DebugUIStress hallucinateTwinGroup:groupThread];
|
|
|
|
}]];
|
|
|
|
}
|
2018-08-30 16:03:14 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2017-09-22 06:31:13 +02:00
|
|
|
return [OWSTableSection sectionWithTitle:self.name items:items];
|
|
|
|
}
|
|
|
|
|
2018-08-30 16:03:14 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
2018-08-02 19:43:21 +02:00
|
|
|
+ (void)ensureGroupOfDataBuilder:(SSKProtoDataMessageBuilder *)dataBuilder thread:(TSThread *)thread
|
2017-09-22 16:30:35 +02:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(dataBuilder);
|
|
|
|
OWSAssertDebug(thread);
|
2017-09-22 16:30:35 +02:00
|
|
|
|
|
|
|
if (![thread isKindOfClass:[TSGroupThread class]]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TSGroupThread *groupThread = (TSGroupThread *)thread;
|
2018-09-24 15:26:08 +02:00
|
|
|
SSKProtoGroupContextBuilder *groupBuilder =
|
|
|
|
[SSKProtoGroupContext builderWithId:groupThread.groupModel.groupId type:SSKProtoGroupContextTypeDeliver];
|
2017-09-22 16:30:35 +02:00
|
|
|
[groupBuilder setId:groupThread.groupModel.groupId];
|
2018-08-02 19:43:21 +02:00
|
|
|
[dataBuilder setGroup:groupBuilder.buildIgnoringErrors];
|
2017-09-22 16:30:35 +02:00
|
|
|
}
|
|
|
|
|
2017-09-22 06:31:13 +02:00
|
|
|
+ (void)sendStressMessage:(TSOutgoingMessage *)message
|
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(message);
|
2017-12-04 16:35:47 +01:00
|
|
|
|
2018-09-17 15:27:58 +02:00
|
|
|
OWSMessageSender *messageSender = SSKEnvironment.shared.messageSender;
|
2017-11-15 19:21:31 +01:00
|
|
|
[messageSender enqueueMessage:message
|
2017-11-08 20:04:51 +01:00
|
|
|
success:^{
|
2018-08-27 18:51:32 +02:00
|
|
|
OWSLogInfo(@"Successfully sent message.");
|
2017-11-08 20:04:51 +01:00
|
|
|
}
|
|
|
|
failure:^(NSError *error) {
|
2018-08-27 18:51:32 +02:00
|
|
|
OWSLogWarn(@"Failed to deliver message with error: %@", error);
|
2017-11-08 20:04:51 +01:00
|
|
|
}];
|
2017-09-22 06:31:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (void)sendStressMessage:(TSThread *)thread
|
|
|
|
block:(DynamicOutgoingMessageBlock)block
|
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(thread);
|
|
|
|
OWSAssertDebug(block);
|
2017-09-22 16:30:35 +02:00
|
|
|
|
2017-09-22 20:21:15 +02:00
|
|
|
OWSDynamicOutgoingMessage *message =
|
|
|
|
[[OWSDynamicOutgoingMessage alloc] initWithPlainTextDataBlock:block thread:thread];
|
2017-09-22 16:30:35 +02:00
|
|
|
|
|
|
|
[self sendStressMessage:message];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (void)sendStressMessage:(TSThread *)thread timestamp:(uint64_t)timestamp block:(DynamicOutgoingMessageBlock)block
|
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(thread);
|
|
|
|
OWSAssertDebug(block);
|
2017-09-22 16:30:35 +02:00
|
|
|
|
|
|
|
OWSDynamicOutgoingMessage *message =
|
2017-09-22 20:21:15 +02:00
|
|
|
[[OWSDynamicOutgoingMessage alloc] initWithPlainTextDataBlock:block timestamp:timestamp thread:thread];
|
2017-09-22 16:30:35 +02:00
|
|
|
|
2017-09-22 06:31:13 +02:00
|
|
|
[self sendStressMessage:message];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Creates a new group (by cloning the current group) without informing the,
|
|
|
|
// other members. This can be used to test "group info requests", etc.
|
|
|
|
+ (void)hallucinateTwinGroup:(TSGroupThread *)groupThread
|
|
|
|
{
|
|
|
|
__block TSGroupThread *thread;
|
2018-03-05 15:30:58 +01:00
|
|
|
[OWSPrimaryStorage.dbReadWriteConnection
|
2017-12-19 03:34:22 +01:00
|
|
|
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
|
|
|
TSGroupModel *groupModel =
|
|
|
|
[[TSGroupModel alloc] initWithTitle:[groupThread.groupModel.groupName stringByAppendingString:@" Copy"]
|
2018-02-13 07:10:29 +01:00
|
|
|
memberIds:groupThread.groupModel.groupMemberIds
|
2017-12-19 03:34:22 +01:00
|
|
|
image:groupThread.groupModel.groupImage
|
2018-07-27 20:40:58 +02:00
|
|
|
groupId:[Randomness generateRandomBytes:16]];
|
2017-12-19 03:34:22 +01:00
|
|
|
thread = [TSGroupThread getOrCreateThreadWithGroupModel:groupModel transaction:transaction];
|
|
|
|
}];
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(thread);
|
2017-12-01 21:17:29 +01:00
|
|
|
|
Faster conversation presentation.
There are multiple places in the codebase we present a conversation.
We used to have some very conservative machinery around how this was done, for
fear of failing to present the call view controller, which would have left a
hidden call in the background. We've since addressed that concern more
thoroughly via the separate calling UIWindow.
As such, the remaining presentation machinery is overly complex and inflexible
for what we need.
Sometimes we want to animate-push the conversation. (tap on home, tap on "send message" in contact card/group members)
Sometimes we want to dismiss a modal, to reveal the conversation behind it (contact picker, group creation)
Sometimes we want to present the conversation with no animation (becoming active from a notification)
We also want to ensure that we're never pushing more than one conversation view
controller, which was previously a problem since we were "pushing" a newly
constructed VC in response to these myriad actions. It turned out there were
certain code paths that caused multiple actions to be fired in rapid succession
which pushed multiple ConversationVC's.
The built-in method: `setViewControllers:animated` easily ensures we only have
one ConversationVC on the stack, while being composable enough to faciliate the
various more efficient animations we desire.
The only thing lost with the complex methods is that the naive
`presentViewController:` can fail, e.g. if another view is already presented.
E.g. if an alert appears *just* before the user taps compose, the contact
picker will fail to present.
Since we no longer depend on this for presenting the CallViewController, this
isn't catostrophic, and in fact, arguable preferable, since we want the user to
read and dismiss any alert explicitly.
// FREEBIE
2018-08-18 22:54:35 +02:00
|
|
|
[SignalApp.sharedApp presentConversationForThread:thread animated:YES];
|
2017-09-22 06:31:13 +02:00
|
|
|
}
|
|
|
|
|
2018-08-30 16:03:14 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-22 06:31:13 +02:00
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|