pondsocket 0.0.6__tar.gz → 0.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pondsocket-0.0.6 → pondsocket-0.0.7}/PKG-INFO +1 -1
- {pondsocket-0.0.6 → pondsocket-0.0.7}/pyproject.toml +1 -1
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/channel.py +31 -9
- pondsocket-0.0.7/tests/test_pondsocket_channel_lifecycle_adversarial.py +276 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/.gitignore +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/README.md +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/__init__.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/contexts/__init__.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/contexts/connection_context.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/contexts/event_context.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/contexts/join_context.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/contexts/leave_context.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/contexts/outgoing_context.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/distributed/__init__.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/distributed/redis_pubsub.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/distributed_wire.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/endpoint.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/errors.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/heartbeat.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/hooks.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/in_memory_transport.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/lobby.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/middleware.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/parser.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/presence.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/pubsub.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/pubsub_local.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/py.typed +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/server.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/sse_transport.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/store.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/transport.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/typed.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/types.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/src/pondsocket/wire.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_channel.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_distributed_local.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_distributed_protocol.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_errors.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_hooks_integration.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_hooks_unit.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_in_memory_transport.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_integration.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_join_autodecline_adversarial.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_leave_event_adversarial.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_middleware.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_parser.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_presence.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_pubsub.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_redis_pubsub.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_smoke.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_sse_invalid_message_adversarial.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_sse_transport.py +0 -0
- {pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_store.py +0 -0
|
@@ -82,6 +82,7 @@ class Channel:
|
|
|
82
82
|
__slots__ = (
|
|
83
83
|
"_active",
|
|
84
84
|
"_assigns",
|
|
85
|
+
"_close_task",
|
|
85
86
|
"_connections",
|
|
86
87
|
"_dispatch_queue",
|
|
87
88
|
"_dispatch_semaphore",
|
|
@@ -121,6 +122,7 @@ class Channel:
|
|
|
121
122
|
self._on_destroy = opts.on_destroy
|
|
122
123
|
self._active: bool = False
|
|
123
124
|
self._connections: Store[Transport] = Store()
|
|
125
|
+
self._close_task: asyncio.Task[None] | None = None
|
|
124
126
|
self._assigns: Store[PondAssigns] = Store()
|
|
125
127
|
self._presence = PresenceClient(self)
|
|
126
128
|
self._dispatch_queue: asyncio.Queue[_DispatchItem] = asyncio.Queue(
|
|
@@ -133,9 +135,13 @@ class Channel:
|
|
|
133
135
|
self._user_get_waiters: dict[str, asyncio.Future[User | None]] = {}
|
|
134
136
|
|
|
135
137
|
async def start(self) -> None:
|
|
138
|
+
close_task = self._close_task
|
|
139
|
+
if close_task is not None:
|
|
140
|
+
await asyncio.shield(close_task)
|
|
136
141
|
async with self._lifecycle_lock:
|
|
137
142
|
if self._active:
|
|
138
143
|
return
|
|
144
|
+
self._close_task = None
|
|
139
145
|
self._active = True
|
|
140
146
|
self._dispatch_task = asyncio.create_task(self._dispatch_loop())
|
|
141
147
|
await self._subscribe_to_pubsub()
|
|
@@ -145,14 +151,30 @@ class Channel:
|
|
|
145
151
|
|
|
146
152
|
async def close(self) -> None:
|
|
147
153
|
async with self._lifecycle_lock:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
self.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
close_task = self._close_task
|
|
155
|
+
if close_task is None:
|
|
156
|
+
if not self._active:
|
|
157
|
+
return
|
|
158
|
+
self._active = False
|
|
159
|
+
close_task = asyncio.create_task(
|
|
160
|
+
self._finish_close(),
|
|
161
|
+
name=f"pondsocket-channel-close:{self.name}",
|
|
162
|
+
)
|
|
163
|
+
self._close_task = close_task
|
|
164
|
+
|
|
165
|
+
if close_task is asyncio.current_task():
|
|
166
|
+
return
|
|
167
|
+
if self._dispatch_task is asyncio.current_task():
|
|
168
|
+
return
|
|
169
|
+
await asyncio.shield(close_task)
|
|
170
|
+
|
|
171
|
+
async def _finish_close(self) -> None:
|
|
172
|
+
dispatch_task = self._dispatch_task
|
|
173
|
+
self._dispatch_task = None
|
|
174
|
+
if dispatch_task is not None and not dispatch_task.done():
|
|
175
|
+
dispatch_task.cancel()
|
|
176
|
+
with contextlib.suppress(asyncio.CancelledError):
|
|
177
|
+
await dispatch_task
|
|
156
178
|
await self._unsubscribe_from_pubsub()
|
|
157
179
|
self._stop_liveness()
|
|
158
180
|
self._node_users.clear()
|
|
@@ -239,7 +261,7 @@ class Channel:
|
|
|
239
261
|
await self._fire_leave_handler(user, reason)
|
|
240
262
|
|
|
241
263
|
if await self._connections.len() == 0:
|
|
242
|
-
await self.
|
|
264
|
+
await self.close()
|
|
243
265
|
return True
|
|
244
266
|
|
|
245
267
|
async def _fire_leave_handler(self, user: User, reason: str) -> None:
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from collections.abc import Awaitable, Callable
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from pondsocket import (
|
|
10
|
+
ConnectionContext,
|
|
11
|
+
InMemoryTransport,
|
|
12
|
+
JoinContext,
|
|
13
|
+
OutgoingContext,
|
|
14
|
+
PondSocket,
|
|
15
|
+
)
|
|
16
|
+
from pondsocket.channel import Channel, ChannelOptions
|
|
17
|
+
from pondsocket.types import Event, Options, SystemEvents
|
|
18
|
+
from pondsocket_common import ClientActions, IncomingConnection, ServerActions, uuid
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _client_event(action: str, channel: str, event: str) -> Event:
|
|
22
|
+
return Event(
|
|
23
|
+
action=action,
|
|
24
|
+
channel_name=channel,
|
|
25
|
+
request_id=uuid(),
|
|
26
|
+
event=event,
|
|
27
|
+
payload={},
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async def _connect(pond: PondSocket, user_id: str) -> InMemoryTransport:
|
|
32
|
+
match = pond.match_endpoint("/api/socket")
|
|
33
|
+
assert match is not None
|
|
34
|
+
incoming = IncomingConnection(id=user_id, address="127.0.0.1", query={})
|
|
35
|
+
ctx = await match.endpoint.request_connection(incoming, user_id=user_id)
|
|
36
|
+
assert ctx.is_accepted
|
|
37
|
+
transport = InMemoryTransport(ctx.user_id, assigns=ctx.assigns)
|
|
38
|
+
await match.endpoint.register_transport(transport)
|
|
39
|
+
await transport.receive_sent()
|
|
40
|
+
return transport
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
async def _expect_event(transport: InMemoryTransport, event_name: str) -> Event:
|
|
44
|
+
for _ in range(20):
|
|
45
|
+
event = await transport.receive_sent()
|
|
46
|
+
if event.action == ServerActions.SYSTEM.value and event.event == event_name:
|
|
47
|
+
return event
|
|
48
|
+
raise AssertionError(f"did not receive system event {event_name}")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _dispatcher(channel: Channel) -> asyncio.Task[None]:
|
|
52
|
+
task = channel._dispatch_task # type: ignore[attr-defined]
|
|
53
|
+
assert task is not None
|
|
54
|
+
return task
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async def _pond_with_channel(
|
|
58
|
+
on_join: Callable[[JoinContext], Awaitable[None]],
|
|
59
|
+
) -> tuple[PondSocket, Any]:
|
|
60
|
+
pond = PondSocket()
|
|
61
|
+
|
|
62
|
+
async def auth(ctx: ConnectionContext) -> None:
|
|
63
|
+
ctx.accept()
|
|
64
|
+
|
|
65
|
+
endpoint = pond.create_endpoint("/api/socket", auth)
|
|
66
|
+
lobby = endpoint.create_channel("/chat/:room", on_join)
|
|
67
|
+
return pond, lobby
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@pytest.mark.asyncio
|
|
71
|
+
async def test_last_user_removal_completes_dispatcher_and_destroys_once() -> None:
|
|
72
|
+
destroyed = 0
|
|
73
|
+
|
|
74
|
+
async def on_destroy() -> None:
|
|
75
|
+
nonlocal destroyed
|
|
76
|
+
destroyed += 1
|
|
77
|
+
|
|
78
|
+
channel = Channel(
|
|
79
|
+
ChannelOptions(
|
|
80
|
+
name="/chat/1",
|
|
81
|
+
options=Options(),
|
|
82
|
+
on_destroy=on_destroy,
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
await channel.start()
|
|
86
|
+
transport = InMemoryTransport("alice")
|
|
87
|
+
await channel.add_user(transport)
|
|
88
|
+
dispatcher = _dispatcher(channel)
|
|
89
|
+
|
|
90
|
+
assert await channel.remove_user("alice")
|
|
91
|
+
|
|
92
|
+
assert not channel.is_active
|
|
93
|
+
assert dispatcher.done()
|
|
94
|
+
assert channel._dispatch_task is None # type: ignore[attr-defined]
|
|
95
|
+
assert destroyed == 1
|
|
96
|
+
|
|
97
|
+
await asyncio.gather(channel.close(), channel.close())
|
|
98
|
+
assert destroyed == 1
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@pytest.mark.asyncio
|
|
102
|
+
async def test_concurrent_close_and_recursive_destroy_complete_once() -> None:
|
|
103
|
+
destroyed = 0
|
|
104
|
+
channel: Channel
|
|
105
|
+
|
|
106
|
+
async def on_destroy() -> None:
|
|
107
|
+
nonlocal destroyed
|
|
108
|
+
destroyed += 1
|
|
109
|
+
await channel.close()
|
|
110
|
+
|
|
111
|
+
channel = Channel(
|
|
112
|
+
ChannelOptions(
|
|
113
|
+
name="/chat/1",
|
|
114
|
+
options=Options(),
|
|
115
|
+
on_destroy=on_destroy,
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
await channel.start()
|
|
119
|
+
dispatcher = _dispatcher(channel)
|
|
120
|
+
|
|
121
|
+
async with asyncio.timeout(1.0):
|
|
122
|
+
await asyncio.gather(channel.close(), channel.close(), channel.close())
|
|
123
|
+
|
|
124
|
+
assert dispatcher.done()
|
|
125
|
+
assert destroyed == 1
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@pytest.mark.asyncio
|
|
129
|
+
async def test_explicit_leave_completes_channel_dispatcher() -> None:
|
|
130
|
+
channels: list[Channel] = []
|
|
131
|
+
|
|
132
|
+
async def on_join(ctx: JoinContext) -> None:
|
|
133
|
+
channels.append(ctx.channel)
|
|
134
|
+
await ctx.accept()
|
|
135
|
+
|
|
136
|
+
pond, lobby = await _pond_with_channel(on_join)
|
|
137
|
+
transport = await _connect(pond, "alice")
|
|
138
|
+
await transport.push_inbound(_client_event(ClientActions.JOIN_CHANNEL.value, "/chat/1", "join"))
|
|
139
|
+
await _expect_event(transport, SystemEvents.ACKNOWLEDGE.value)
|
|
140
|
+
dispatcher = _dispatcher(channels[0])
|
|
141
|
+
|
|
142
|
+
await transport.push_inbound(
|
|
143
|
+
_client_event(ClientActions.LEAVE_CHANNEL.value, "/chat/1", "leave")
|
|
144
|
+
)
|
|
145
|
+
await _expect_event(transport, SystemEvents.EXIT_ACKNOWLEDGE.value)
|
|
146
|
+
await asyncio.wait_for(asyncio.shield(dispatcher), timeout=1.0)
|
|
147
|
+
|
|
148
|
+
assert not channels[0].is_active
|
|
149
|
+
assert await lobby.get_channel("/chat/1") is None
|
|
150
|
+
await pond.close()
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
@pytest.mark.asyncio
|
|
154
|
+
async def test_abrupt_disconnect_completes_channel_dispatcher() -> None:
|
|
155
|
+
channels: list[Channel] = []
|
|
156
|
+
|
|
157
|
+
async def on_join(ctx: JoinContext) -> None:
|
|
158
|
+
channels.append(ctx.channel)
|
|
159
|
+
await ctx.accept()
|
|
160
|
+
|
|
161
|
+
pond, lobby = await _pond_with_channel(on_join)
|
|
162
|
+
transport = await _connect(pond, "alice")
|
|
163
|
+
await transport.push_inbound(_client_event(ClientActions.JOIN_CHANNEL.value, "/chat/1", "join"))
|
|
164
|
+
await _expect_event(transport, SystemEvents.ACKNOWLEDGE.value)
|
|
165
|
+
dispatcher = _dispatcher(channels[0])
|
|
166
|
+
|
|
167
|
+
await transport.close()
|
|
168
|
+
|
|
169
|
+
assert dispatcher.done()
|
|
170
|
+
assert not channels[0].is_active
|
|
171
|
+
assert await lobby.get_channel("/chat/1") is None
|
|
172
|
+
await pond.close()
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
@pytest.mark.asyncio
|
|
176
|
+
async def test_dispatcher_can_trigger_last_user_close_without_self_await() -> None:
|
|
177
|
+
channels: list[Channel] = []
|
|
178
|
+
|
|
179
|
+
async def on_join(ctx: JoinContext) -> None:
|
|
180
|
+
channels.append(ctx.channel)
|
|
181
|
+
await ctx.accept()
|
|
182
|
+
|
|
183
|
+
pond, lobby = await _pond_with_channel(on_join)
|
|
184
|
+
|
|
185
|
+
async def remove_recipient(ctx: OutgoingContext) -> None:
|
|
186
|
+
await ctx.channel.remove_user(ctx.user.id)
|
|
187
|
+
|
|
188
|
+
lobby.on_outgoing("message", remove_recipient)
|
|
189
|
+
transport = await _connect(pond, "alice")
|
|
190
|
+
await transport.push_inbound(_client_event(ClientActions.JOIN_CHANNEL.value, "/chat/1", "join"))
|
|
191
|
+
await _expect_event(transport, SystemEvents.ACKNOWLEDGE.value)
|
|
192
|
+
channel = channels[0]
|
|
193
|
+
dispatcher = _dispatcher(channel)
|
|
194
|
+
|
|
195
|
+
await channel.broadcast("message", {"text": "close"})
|
|
196
|
+
done, pending = await asyncio.wait({dispatcher}, timeout=1.0)
|
|
197
|
+
assert done == {dispatcher}
|
|
198
|
+
assert not pending
|
|
199
|
+
close_task = channel._close_task # type: ignore[attr-defined]
|
|
200
|
+
assert close_task is not None
|
|
201
|
+
await asyncio.wait_for(asyncio.shield(close_task), timeout=1.0)
|
|
202
|
+
|
|
203
|
+
assert not channel.is_active
|
|
204
|
+
assert await lobby.get_channel("/chat/1") is None
|
|
205
|
+
await pond.close()
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
@pytest.mark.asyncio
|
|
209
|
+
@pytest.mark.parametrize("failure", ["decline", "raise", "no_response"])
|
|
210
|
+
async def test_failed_join_completes_unused_channel_dispatcher(failure: str) -> None:
|
|
211
|
+
channels: list[Channel] = []
|
|
212
|
+
dispatchers: list[asyncio.Task[None]] = []
|
|
213
|
+
|
|
214
|
+
async def on_join(ctx: JoinContext) -> None:
|
|
215
|
+
channels.append(ctx.channel)
|
|
216
|
+
dispatchers.append(_dispatcher(ctx.channel))
|
|
217
|
+
if failure == "decline":
|
|
218
|
+
await ctx.decline(403, "declined")
|
|
219
|
+
elif failure == "raise":
|
|
220
|
+
raise RuntimeError("join failed")
|
|
221
|
+
|
|
222
|
+
pond, lobby = await _pond_with_channel(on_join)
|
|
223
|
+
transport = await _connect(pond, "alice")
|
|
224
|
+
await transport.push_inbound(_client_event(ClientActions.JOIN_CHANNEL.value, "/chat/1", "join"))
|
|
225
|
+
await _expect_event(transport, SystemEvents.UNAUTHORIZED.value)
|
|
226
|
+
await asyncio.wait_for(asyncio.shield(dispatchers[0]), timeout=1.0)
|
|
227
|
+
|
|
228
|
+
assert not channels[0].is_active
|
|
229
|
+
assert await lobby.get_channel("/chat/1") is None
|
|
230
|
+
await pond.close()
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@pytest.mark.asyncio
|
|
234
|
+
async def test_repeated_connect_disconnect_reaps_every_dispatcher() -> None:
|
|
235
|
+
channels: list[Channel] = []
|
|
236
|
+
|
|
237
|
+
async def on_join(ctx: JoinContext) -> None:
|
|
238
|
+
channels.append(ctx.channel)
|
|
239
|
+
await ctx.accept()
|
|
240
|
+
|
|
241
|
+
pond, lobby = await _pond_with_channel(on_join)
|
|
242
|
+
dispatchers: list[asyncio.Task[None]] = []
|
|
243
|
+
|
|
244
|
+
for index in range(10):
|
|
245
|
+
transport = await _connect(pond, f"user-{index}")
|
|
246
|
+
await transport.push_inbound(
|
|
247
|
+
_client_event(ClientActions.JOIN_CHANNEL.value, "/chat/1", "join")
|
|
248
|
+
)
|
|
249
|
+
await _expect_event(transport, SystemEvents.ACKNOWLEDGE.value)
|
|
250
|
+
dispatchers.append(_dispatcher(channels[-1]))
|
|
251
|
+
await transport.close()
|
|
252
|
+
assert dispatchers[-1].done()
|
|
253
|
+
assert await lobby.get_channel("/chat/1") is None
|
|
254
|
+
|
|
255
|
+
assert all(task.done() for task in dispatchers)
|
|
256
|
+
await pond.close()
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@pytest.mark.asyncio
|
|
260
|
+
async def test_pondsocket_close_completes_active_channel_dispatcher() -> None:
|
|
261
|
+
channels: list[Channel] = []
|
|
262
|
+
|
|
263
|
+
async def on_join(ctx: JoinContext) -> None:
|
|
264
|
+
channels.append(ctx.channel)
|
|
265
|
+
await ctx.accept()
|
|
266
|
+
|
|
267
|
+
pond, _ = await _pond_with_channel(on_join)
|
|
268
|
+
transport = await _connect(pond, "alice")
|
|
269
|
+
await transport.push_inbound(_client_event(ClientActions.JOIN_CHANNEL.value, "/chat/1", "join"))
|
|
270
|
+
await _expect_event(transport, SystemEvents.ACKNOWLEDGE.value)
|
|
271
|
+
dispatcher = _dispatcher(channels[0])
|
|
272
|
+
|
|
273
|
+
await pond.close()
|
|
274
|
+
|
|
275
|
+
assert dispatcher.done()
|
|
276
|
+
assert not channels[0].is_active
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pondsocket-0.0.6 → pondsocket-0.0.7}/tests/test_pondsocket_sse_invalid_message_adversarial.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|