Skip to content

Commit

Permalink
illustrating hang in repo.find
Browse files Browse the repository at this point in the history
  • Loading branch information
heckj committed May 13, 2024
1 parent 7a48691 commit b78a75d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ final class RepoWebsocketIntegrationTests: XCTestCase {
private static let subsystem = Bundle.main.bundleIdentifier!

static let test = Logger(subsystem: subsystem, category: "WebSocketSyncIntegrationTests")
// let syncDestination = "ws://localhost:3030/"
let syncDestination = "ws://localhost:3030/"
// Switch to the following line to run a test against the public hosted automerge-repo instance
let syncDestination = "wss://sync.automerge.org/"
// let syncDestination = "wss://sync.automerge.org/"

override func setUp() async throws {
let isWebSocketConnectable = await webSocketAvailable(destination: syncDestination)
Expand Down
23 changes: 23 additions & 0 deletions Tests/AutomergeRepoTests/RepoFindTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Automerge
@testable import AutomergeRepo
import AutomergeUtilities
import XCTest

final class RepoFindTest: XCTestCase {
func testRepoFindWithoutNetworkingActive() async throws {
let repo = Repo(sharePolicy: SharePolicy.agreeable)
let websocket = WebSocketProvider(.init(reconnectOnError: false, loggingAt: .tracing))
await repo.addNetworkAdapter(adapter: websocket)

let unavailableExpectation = expectation(description: "find should throw an Unavailable error")
Task {
do {
let handle = try await repo.find(id: DocumentId()) // never completes, never errors
print(handle)
} catch {
unavailableExpectation.fulfill()
}
}
await fulfillment(of: [unavailableExpectation], timeout: 5)
}
}

0 comments on commit b78a75d

Please # to comment.