Skip to content

Commit

Permalink
Try just waiting longer
Browse files Browse the repository at this point in the history
  • Loading branch information
Anderas committed Jul 15, 2022
1 parent 10250c0 commit ac995ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions MatrixSDKTests/MXCrossSigningTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ - (void)testRefreshState
XCTAssertFalse(newAliceSession.crypto.crossSigning.canCrossSign);

// - Let's wait for the magic of gossip to happen
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

// -> Cross-signing should be fully enabled
XCTAssertEqual(newAliceSession.crypto.crossSigning.state, MXCrossSigningStateCanCrossSign);
Expand Down Expand Up @@ -989,7 +989,6 @@ - (void)testTrustChain

NSString *bobUserId = bobSession.myUserId;
NSString *bobDeviceId = bobSession.myDeviceId;


// - Alice self-verifies it with Alice2
// This simulates a self verification and trigger cross-signing behind the shell
Expand All @@ -998,7 +997,7 @@ - (void)testTrustChain
[aliceSession3.crypto setUserVerification:YES forUser:aliceUserId success:^{

// Wait a bit to make background requests for cross-signing happen
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

// -> Alice3 should see all devices in the party as trusted thanks to cross-signing
XCTAssertEqual(aliceSession3.crypto.crossSigning.state, MXCrossSigningStateCanCrossSign);
Expand All @@ -1015,12 +1014,12 @@ - (void)testTrustChain

// -> Alice3 should see Bob as trusted thanks to cross-signing
[aliceSession3.crypto downloadKeys:@[bobUserId] forceDownload:NO success:^(MXUsersDevicesMap<MXDeviceInfo *> *usersDevicesInfoMap, NSDictionary<NSString *,MXCrossSigningInfo *> *crossSigningKeysMap) {

XCTAssertTrue([aliceSession3.crypto trustLevelForUser:bobUserId].isCrossSigningVerified);
XCTAssertTrue([aliceSession3.crypto deviceTrustLevelForDevice:bobDeviceId ofUser:bobUserId].isCrossSigningVerified);

[expectation fulfill];

} failure:^(NSError *error) {
XCTFail(@"Cannot set up intial test conditions - error: %@", error);
[expectation fulfill];
Expand Down
6 changes: 3 additions & 3 deletions MatrixSDKTests/MXCryptoShareTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ - (void)testNominalCase
XCTAssertNotNil([aliceSession2.crypto.store outgoingRoomKeyRequestWithState:MXRoomKeyRequestStateUnsent]);

// Wait a bit
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

// -> After a bit, Alice2 should have received all keys
XCTAssertEqual(aliceSession2.crypto.store.inboundGroupSessions.count, aliceSession1.crypto.store.inboundGroupSessions.count);
Expand Down Expand Up @@ -293,7 +293,7 @@ - (void)testDisableKeyShareRequest
[liveTimeline paginate:10 direction:MXTimelineDirectionBackwards onlyFromStore:NO complete:^{

// Wait a bit
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

// -> Key share requests must be pending
XCTAssertNotNil([aliceSession2.crypto.store outgoingRoomKeyRequestWithState:MXRoomKeyRequestStateUnsent]);
Expand Down Expand Up @@ -723,7 +723,7 @@ - (void)testSharedHistoryPreservedWhenForwardingKeys
[liveTimeline resetPagination];
[liveTimeline paginate:10 direction:MXTimelineDirectionBackwards onlyFromStore:NO complete:^{

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

// Alice2 now has all 3 keys, despite only two of them having shared history
XCTAssertEqual([self numberOfKeysInSession:aliceSession2], 3);
Expand Down

0 comments on commit ac995ed

Please sign in to comment.