Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTN16d #394

Merged
merged 1 commit into from
Apr 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Spec/RealtimeClientConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,39 @@ class RealtimeClientConnection: QuickSpec {

}

// RTN16
context("Connection recovery") {

// RTN16d
it("when a connection is successfully recovered, Connection#id will be identical to the id of the connection that was recovered and Connection#key will always be updated to the ConnectionDetails#connectionKey provided in the first CONNECTED ProtocolMessage") {
let options = AblyTests.commonAppSetup()
let clientOriginal = ARTRealtime(options: options)
defer { clientOriginal.close() }

expect(clientOriginal.connection.state).toEventually(equal(ARTRealtimeConnectionState.Connected), timeout: testTimeout)

let expectedConnectionId = clientOriginal.connection.id

options.recover = clientOriginal.connection.recoveryKey
clientOriginal.onError(AblyTests.newErrorProtocolMessage())

let clientRecover = AblyTests.newRealtime(options)
defer { clientRecover.close() }

waitUntil(timeout: testTimeout) { done in
clientRecover.connection.once(.Connected) { _ in
let transport = clientRecover.transport as! TestProxyTransport
let firstConnectionDetails = transport.protocolMessagesReceived.filter{ $0.action == .Connected }.first!.connectionDetails
expect(firstConnectionDetails!.connectionKey).toNot(beNil())
expect(clientRecover.connection.id).to(equal(expectedConnectionId))
expect(clientRecover.connection.key).to(equal(firstConnectionDetails!.connectionKey))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is right, the connection key can change when the connection is recovered, the only guarantee is that the connection ID remains the same

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is right. It's checking that the connection key is the new one received in the CONNECTED message from the server (firstConnectionDetails), not that it's keeping the old connection key. (Maybe the name firstConnectionDetails is a bit misleading?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be something like recoveredConnectionDetails :/

done()
}
}
}

}

// RTN18
context("state change side effects") {

Expand Down