Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/test_github_installs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 15 additions & 3 deletions tests/test_slack_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/")


Expand Down