Skip to content

Commit 8759cc5

Browse files
alltheseasclaude
andcommitted
Fix RelayIntegrationTests timeout and error handling issues
- getRelayURL() no longer overrides networkTimeout if already set higher, preserving 60s timeout for throttled tests - connectToRelay() now throws on timeout instead of just XCTFail, preventing cascading failures from unconnected relay - Restore local strfry check for CI environments where Docker works 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ecd5303 commit 8759cc5

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

damusTests/RelayIntegrationTests.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,22 @@ final class RelayIntegrationTests: XCTestCase {
106106
}
107107
}
108108

109-
/// Get relay URL - always uses public relay for reliable testing.
110-
/// Local strfry requires special setup and iOS Simulator can't reach Docker localhost.
109+
/// Get relay URL - uses local strfry if available (CI), otherwise public relay.
110+
/// iOS Simulator can't reach Docker localhost, but CI can.
111111
func getRelayURL() async -> RelayURL {
112-
networkTimeout = 30.0
113-
return Self.publicRelayURL
112+
if await isLocalRelayAvailable() {
113+
return Self.localRelayURL
114+
} else {
115+
// Only increase timeout if not already set higher (e.g., by throttled tests)
116+
if networkTimeout < 30.0 {
117+
networkTimeout = 30.0
118+
}
119+
return Self.publicRelayURL
120+
}
114121
}
115122

116123
/// Connect to relay and wait for connection
124+
/// Throws if connection times out
117125
func connectToRelay(_ url: RelayURL) async throws {
118126
let descriptor = RelayPool.RelayDescriptor(url: url, info: .readWrite)
119127
try await pool.add_relay(descriptor)
@@ -127,7 +135,8 @@ final class RelayIntegrationTests: XCTestCase {
127135
return
128136
}
129137
}
130-
XCTFail("Failed to connect to relay within \(networkTimeout) seconds")
138+
throw NSError(domain: "RelayIntegrationTests", code: 1,
139+
userInfo: [NSLocalizedDescriptionKey: "Failed to connect to relay within \(networkTimeout) seconds"])
131140
}
132141

133142
/// Parse JSON message to extract type (first element)

0 commit comments

Comments
 (0)