File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change
1
+ Properly handle ``PersistentConnectionClosedOK `` for ``subscription_manager.handle_subscriptions() ``.
Original file line number Diff line number Diff line change @@ -397,7 +397,7 @@ async def test_async_iterator_pattern_exception_handling_for_subscriptions():
397
397
398
398
399
399
@pytest .mark .asyncio
400
- async def test_connection_closed_ok_breaks_message_iteration ():
400
+ async def test_connection_closed_ok_breaks_process_subscriptions_iteration ():
401
401
with patch (
402
402
"web3.providers.persistent.websocket.connect" ,
403
403
new = lambda * _1 , ** _2 : WebSocketMessageStreamMock (
@@ -409,6 +409,22 @@ async def test_connection_closed_ok_breaks_message_iteration():
409
409
pytest .fail ("Should not reach this point." )
410
410
411
411
412
+ @pytest .mark .asyncio
413
+ async def test_connection_closed_ok_breaks_handle_subscriptions_iteration ():
414
+ with patch (
415
+ "web3.providers.persistent.websocket.connect" ,
416
+ new = lambda * _1 , ** _2 : WebSocketMessageStreamMock (
417
+ raise_exception = ConnectionClosedOK (None , None )
418
+ ),
419
+ ):
420
+ w3 = await AsyncWeb3 (WebSocketProvider ("ws://mocked" ))
421
+ # would fail with a ``TimeoutError`` if the iteration did not break properly
422
+ # on ``ConnectionClosedOK``
423
+ await asyncio .wait_for (
424
+ w3 .subscription_manager .handle_subscriptions (run_forever = True ), timeout = 1
425
+ )
426
+
427
+
412
428
@pytest .mark .asyncio
413
429
async def test_listener_task_breaks_out_of_stream_when_cancelled ():
414
430
with patch (
You can’t perform that action at this time.
0 commit comments