mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
implement trio queue interface
This commit is contained in:
19
tests/test_utils.py
Normal file
19
tests/test_utils.py
Normal file
@ -0,0 +1,19 @@
|
||||
import trio
|
||||
import pytest
|
||||
from libp2p.utils import TrioQueue
|
||||
|
||||
|
||||
@pytest.mark.trio
|
||||
async def test_trio_queue():
|
||||
queue = TrioQueue()
|
||||
|
||||
async def queue_get(task_status=None):
|
||||
result = await queue.get()
|
||||
task_status.started(result)
|
||||
|
||||
async with trio.open_nursery() as nursery:
|
||||
nursery.start_soon(queue.put, 123)
|
||||
result = await nursery.start(queue_get)
|
||||
|
||||
assert result == 123
|
||||
|
||||
Reference in New Issue
Block a user