Skip to content

Commit

Permalink
Added check for createRecoveryKey to include only attached channels.
Browse files Browse the repository at this point in the history
  • Loading branch information
maratal committed Aug 28, 2023
1 parent 57b30e8 commit 94fa158
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Test/Tests/RealtimeClientConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3362,11 +3362,13 @@ class RealtimeClientConnectionTests: XCTestCase {

let firstChannelName = test.uniqueChannelName()
let secondChannelName = test.uniqueChannelName()
let thirdChannelName = test.uniqueChannelName()
var firstChannelSerial: String?
var secondChannelSerial: String?

var thirdChannelSerial: String?

waitUntil(timeout: testTimeout) { done in
let partialDone = AblyTests.splitDone(4, done: done)
let partialDone = AblyTests.splitDone(5, done: done)
client.connection.once(.connected) { stateChange in
let firstChannel = client.channels.get(firstChannelName)
firstChannel.on(.attached) {_ in
Expand All @@ -3382,12 +3384,21 @@ class RealtimeClientConnectionTests: XCTestCase {
}
partialDone()
}
let thirdChannel = client.channels.get(thirdChannelName)
thirdChannel.on(.attached) {_ in
thirdChannelSerial = thirdChannel.internal.serial
partialDone()
}
firstChannel.attach()
secondChannel.attach()
thirdChannel.attach()
partialDone()
}
}


let thirdChannel = client.channels.get(thirdChannelName)
thirdChannel.detach()

guard let recoveryKeyString = client.connection.createRecoveryKey() else {
fail("recoveryKeyString shouldn't be null")
return
Expand All @@ -3398,6 +3409,8 @@ class RealtimeClientConnectionTests: XCTestCase {
expect(recoveryKey.connectionKey).to(equal(client.connection.key))
expect(recoveryKey.channelSerials.count).to(equal(2))

XCTAssertNil(recoveryKey.channelSerials.first(where: { $0.key == thirdChannelSerial }))

recoveryKey.channelSerials.keys.forEach { key in
let serial = recoveryKey.channelSerials[key]
expect(serial).toNot(beNil())
Expand Down

0 comments on commit 94fa158

Please sign in to comment.