From 1747f7b8b4846b1ad37019c2b74781a525e86c7b Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 13 Mar 2024 11:08:51 -0700 Subject: [PATCH] fix: iOS streaming 15 second disconnection (#282) * get a test going in iOS that reproduces the streaming issue * bump the pod * package resolve --- Package.swift | 2 +- Tests/XMTPTests/ConversationTests.swift | 22 ++++++++++++++----- XMTP.podspec | 4 ++-- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Package.swift b/Package.swift index 83f80e15..547935f9 100644 --- a/Package.swift +++ b/Package.swift @@ -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. diff --git a/Tests/XMTPTests/ConversationTests.swift b/Tests/XMTPTests/ConversationTests.swift index 973c0615..0ecce2cc 100644 --- a/Tests/XMTPTests/ConversationTests.swift +++ b/Tests/XMTPTests/ConversationTests.swift @@ -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 { diff --git a/XMTP.podspec b/XMTP.podspec index bb3bb5aa..b938c261 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -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. @@ -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 diff --git a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6981820b..f689a8f6 100644 --- a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -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" } }, {