File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -293,3 +293,29 @@ async def test_get_payment_info():
293293 assert partial_fee_all_options > partial_fee_no_era
294294 assert partial_fee_all_options > partial_fee_era
295295 print ("test_get_payment_info succeeded" )
296+
297+
298+ @pytest .mark .asyncio
299+ async def test_concurrent_rpc_requests ():
300+ """
301+ Test that multiple concurrent RPC requests on a shared connection work correctly.
302+
303+ This test verifies the fix for the issue where multiple concurrent tasks
304+ re-initializing the WebSocket connection caused requests to hang.
305+ """
306+ print ("Testing test_concurrent_rpc_requests" )
307+
308+ async def concurrent_task (substrate , task_id ):
309+ """Make multiple RPC calls from a single task."""
310+ for i in range (5 ):
311+ result = await substrate .get_block_number (None )
312+ assert isinstance (result , int )
313+ assert result > 0
314+
315+ async with AsyncSubstrateInterface (LATENT_LITE_ENTRYPOINT ) as substrate :
316+ # Run 5 concurrent tasks, each making 5 RPC calls (25 total)
317+ # This tests that the connection is properly shared without re-initialization
318+ tasks = [concurrent_task (substrate , i ) for i in range (5 )]
319+ await asyncio .gather (* tasks )
320+
321+ print ("test_concurrent_rpc_requests succeeded" )
You can’t perform that action at this time.
0 commit comments