Skip to content

The agent that grows with you

test(telegram): cover the DoH discovery client in the shared TLS context test

kshitijk4poor4816775c82a9
diff --git a/tests/gateway/test_telegram_closewait_limits.py b/tests/gateway/test_telegram_closewait_limits.py
index a59ad1351df..af16d724ac5 100644
--- a/tests/gateway/test_telegram_closewait_limits.py
+++ b/tests/gateway/test_telegram_closewait_limits.py
@@ -160,6 +160,22 @@ def test_all_ptb_clients_share_the_platform_ssl_context(monkeypatch):
assert transport._transport_kwargs.get("verify") is shared
asyncio.run(transport.aclose())
+ # The DoH discovery client verifies with the same context.
+ from plugins.platforms.telegram import telegram_network as tg_net
+ seen = {}
+
+ def _record_client(**kwargs):
+ seen.update(kwargs)
+ raise _StopConnect
+
+ monkeypatch.setattr(tg_net, "platform_ssl_context", lambda: shared)
+ monkeypatch.setattr(tg_net.httpx, "AsyncClient", _record_client)
+ try:
+ asyncio.run(tg_net.discover_fallback_ips())
+ except _StopConnect:
+ pass
+ assert seen.get("verify") is shared
+
# An SSL_CERT_FILE bundle is honoured (as httpx verify=True did) and still cached once.
import certifi
from agent import ssl_verify