Repository navigation
Prove broker-bound Iroh relay round trip - #8488
Conversation
📝 WalkthroughWalkthroughAdds broker-credential detection and live coverage for broker-bound custom relay tokens. Tests register endpoints, perform bidirectional relay exchanges, clean up bindings, log progress, and bound stream round trips with concurrent timeout handling. ChangesBroker relay live tests
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant LiveTest
participant TrustBroker
participant EndpointOne
participant EndpointTwo
participant CustomRelay
LiveTest->>TrustBroker: Register endpoint bindings
TrustBroker-->>LiveTest: Return relay tokens
EndpointOne->>CustomRelay: Connect with first token
EndpointTwo->>CustomRelay: Connect with second token
EndpointOne->>EndpointTwo: Exchange bidirectional stream data
LiveTest->>TrustBroker: Revoke bindings
Possibly related PRs
🚥 Pre-merge checks | ✅ 24 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (24 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| let firstCredentials: [String: String] = Dictionary( | ||
| uniqueKeysWithValues: firstToken.credentials.map { ($0.relayURL, $0.token) } | ||
| ) |
There was a problem hiding this comment.
Dictionary(uniqueKeysWithValues:) crashes on duplicate relay URLs
If the broker ever returns two credentials entries with the same relayURL (e.g., a server-side bug or a future multi-token-per-relay design), Dictionary(uniqueKeysWithValues:) hits a fatal precondition and crashes the process rather than throwing, which bypasses the catch block that revokes disposable bindings. Replace with init(_:uniquingKeysWith:) to keep the latest token per URL and convert a potential crash into a recoverable state.
| private func revokeStaleLiveTestBindings( | ||
| broker: CmxIrohTrustBrokerClient | ||
| ) async throws { | ||
| let staleBindingIDs = try await broker.discover().bindings | ||
| .filter { ["relay-live-first", "relay-live-second"].contains($0.tag) } | ||
| .map(\.bindingID) | ||
| for bindingID in staleBindingIDs { | ||
| try await broker.revoke(bindingID: bindingID) | ||
| } | ||
| } |
There was a problem hiding this comment.
Stale-cleanup tags are not run-isolated
revokeStaleLiveTestBindings filters the account's bindings by the hardcoded tags "relay-live-first" and "relay-live-second". If two live runs execute concurrently against the same staging broker account (different CI runners, parallel developer machines), one run's stale-cleanup step will revoke the other run's in-flight bindings mid-test, producing confusing failures that look like broker or relay errors.
What
Verification
swift test: 408 tests passedTest-only; no app runtime or user-facing strings changed.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Adds a live test that proves a broker-bound Iroh relay can carry a bidirectional stream round trip over a single server-provided relay URL. Tightens timeouts and isolates each run so the gate never hangs.
New Features
Bug Fixes
Written for commit 1b403a7. Summary will update on new commits.
Summary by CodeRabbit