Skip to content

Commit

Permalink
fix: iOS streaming 15 second disconnection (#282)
Browse files Browse the repository at this point in the history
* get a test going in iOS that reproduces the streaming issue

* bump the pod

* package resolve
  • Loading branch information
nplasterer authored Mar 13, 2024
1 parent c179116 commit 1747f7b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
.package(url: "https://github.com/1024jp/GzipSwift", from: "5.2.0"),
.package(url: "https://github.com/bufbuild/connect-swift", exact: "0.3.0"),
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"),
.package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.4.3-beta1"),
.package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.4.3-beta2"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
22 changes: 16 additions & 6 deletions Tests/XMTPTests/ConversationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,40 +102,50 @@ class ConversationTests: XCTestCase {
}

func testCanStreamConversationsV2() async throws {
let options = ClientOptions(api: ClientOptions.Api(env: .dev, isSecure: true))
let wallet = try PrivateKey.generate()
let client = try await Client.create(account: wallet, options: options)

let wallet2 = try PrivateKey.generate()
let client2 = try await Client.create(account: wallet2, options: options)
let expectation1 = expectation(description: "got a conversation")
expectation1.expectedFulfillmentCount = 2

Task(priority: .userInitiated) {
for try await conversation in await bobClient.conversations.stream() {
for try await conversation in await client.conversations.stream() {
expectation1.fulfill()
}
}

guard case let .v2(conversation) = try await bobClient.conversations.newConversation(with: alice.walletAddress) else {
guard case let .v2(conversation) = try await client.conversations.newConversation(with: client2.address) else {
XCTFail("Did not create a v2 convo")
return
}
try? await Task.sleep(nanoseconds: 1_000_000_000)

try await conversation.send(content: "hi")

guard case let .v2(conversation) = try await bobClient.conversations.newConversation(with: alice.walletAddress) else {
guard case let .v2(conversation) = try await client.conversations.newConversation(with: client2.address) else {
XCTFail("Did not create a v2 convo")
return
}

try? await Task.sleep(nanoseconds: 15_000_000_000)

try await conversation.send(content: "hi again")

let newWallet = try PrivateKey.generate()
let newClient = try await Client.create(account: newWallet, apiClient: fakeApiClient)
let newClient = try await Client.create(account: newWallet, options: options)

guard case let .v2(conversation2) = try await bobClient.conversations.newConversation(with: newWallet.walletAddress) else {
guard case let .v2(conversation2) = try await client.conversations.newConversation(with: newWallet.walletAddress) else {
XCTFail("Did not create a v2 convo")
return
}
try? await Task.sleep(nanoseconds: 1_000_000_000)

try await conversation2.send(content: "hi from new wallet")

await waitForExpectations(timeout: 5)
await waitForExpectations(timeout: 30)
}

func testCanUseCachedConversation() async throws {
Expand Down
4 changes: 2 additions & 2 deletions XMTP.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "XMTP"
spec.version = "0.9.0"
spec.version = "0.9.1"
spec.summary = "XMTP SDK Cocoapod"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -44,5 +44,5 @@ Pod::Spec.new do |spec|
spec.dependency "web3.swift"
spec.dependency "GzipSwift"
spec.dependency "Connect-Swift", "= 0.3.0"
spec.dependency 'LibXMTP', '= 0.4.3-beta1'
spec.dependency 'LibXMTP', '= 0.4.3-beta2'
end
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/xmtp/libxmtp-swift",
"state" : {
"revision" : "f8c4be0d591671067c8e7772b7c402931f33ed54",
"version" : "0.4.3-beta1"
"revision" : "7e73798d381ef8705776a88f64f44e098ec5480e",
"version" : "0.4.3-beta2"
}
},
{
Expand Down

0 comments on commit 1747f7b

Please sign in to comment.