Skip to content
Draft
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
30 changes: 30 additions & 0 deletions Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,36 @@ class GroupTests: XCTestCase {
XCTAssert(
!(cannotMessage[notOnNetwork.walletAddress.lowercased()] ?? true))
}

func test_CanExhaustConnectionPoolQuickly() async throws {
var clients: [Client] = []
var failedAt: Int? = nil

let key = try Crypto.secureRandomBytes(count: 32)
let clientOptions = ClientOptions(
api: ClientOptions.Api(env: .local, isSecure: false),
dbEncryptionKey: key
)

for i in 1...100 {
do {
let key = try PrivateKey.generate()
let client = try await Client.create(account: key, options: clientOptions)
clients.append(client)
print("✅ Created client \(i)")
} catch {
print("❌ Failed at client \(i): \(error)")
failedAt = i
break
}
}

if let failedAt = failedAt {
print("💥 Pool exhaustion happened at client \(failedAt)")
} else {
print("✅ All clients created without error")
}
}

func testIsActive() async throws {
let fixtures = try await fixtures()
Expand Down
Loading