fix: stop unit-test sessions firing RPCs at production#457
Open
raulriera wants to merge 3 commits into
Open
Conversation
Container.mock wires real mainNet gRPC clients, so every test-built Session/SessionContainer fetched profile, flags, balances, and the conversation feed against production with unregistered owners. The server-backed bootstrap is now skipped under unit tests, mirroring the existing startStreaming() guard.
…ch production Container.mock, Client.mock, and FlipClient.mock now build on a new Network.offline case that resolves every host to loopback. This is the structural backstop behind the per-site test guards: no matter which member of a test- or preview-built object graph fires a request, it can never reach the real backend. Also gates chatSpotlightIndexer.start() under unit tests (a CoreSpotlight XPC call the offline network can't cover) and relaxes poller to an optional since it stays nil under tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Investigating simulator log spam ("Failed to load conversation feed error=unknown", dozens per second) showed it wasn't a retry loop — it was the unit-test suite. The shared mock container wires real mainNet gRPC clients, so every test-built session fetched profile, flags, balances, and the conversation feed against production, and opened live streams, all doomed to denials for its unregistered owner.
The fix routes Container.mock, Client.mock, and FlipClient.mock through a new Network.offline case that resolves every host to loopback, so no member of a test- or preview-built object graph can reach the real backend regardless of which call site fires. Per-site guards skip the doomed work in the hottest paths; the offline network is the structural backstop that also covers the paths guards miss. A canary test pins every offline entry point so a revert fails loudly instead of silently resuming production traffic.
Test plan: