diff --git a/tests/test_github_installs.py b/tests/test_github_installs.py index 907dd2e6..fd6afc66 100644 --- a/tests/test_github_installs.py +++ b/tests/test_github_installs.py @@ -215,6 +215,13 @@ def _slack_frame(): async def test_one_hub_fans_out_to_both_adapters(monkeypatch): """THE step-3 invariant: slack + github share one relay socket; frames land on their own adapter by provider tag.""" + # Stub name resolution at its chokepoint. A dead port only refuses instantly on + # POSIX; on Windows it takes ~2.0s per call and this frame makes two, blowing the + # 2.0s wait_dispatched budget below. The env var stays as a no-network backstop. + async def _no_slack_api(self, team_id, method, params): + return None + + monkeypatch.setattr(SlackRelayAdapter, "_slack_get", _no_slack_api) monkeypatch.setenv("SLACK_API_URL", "http://127.0.0.1:9/") hub = RelayHub( "wss://relay.test/ws", diff --git a/tests/test_slack_relay.py b/tests/test_slack_relay.py index b05ce807..9894a8c0 100644 --- a/tests/test_slack_relay.py +++ b/tests/test_slack_relay.py @@ -20,9 +20,21 @@ @pytest.fixture(autouse=True) def _no_slack_network(monkeypatch): - """Name/channel resolution is best-effort; unstubbed lookups must fail - instantly at a dead loopback port, never reach slack.com — a slow real - answer was blowing the 2s wait_dispatched window intermittently.""" + """Name/channel resolution is best-effort, so stub it at its single chokepoint. + + A dead loopback port alone is not enough. Refusing a connection is only instant + on POSIX; on Windows it takes ~2.0s, and `_dispatch_slack_event` awaits both + `_display_name` and `_channel_name`, so one frame cost ~4s against the 2.0s + budget and no frame ever dispatched in time. `SLACK_API_URL` still points at a + dead port as a backstop, so an unstubbed path can never reach slack.com. + """ + + async def _no_slack_api(self, team_id, method, params): + return None + + monkeypatch.setattr( + relay_client.SlackRelayAdapter, "_slack_get", _no_slack_api + ) monkeypatch.setenv("SLACK_API_URL", "http://127.0.0.1:9/")