py-libp2p/tests/network/conftest.py

24 lines
609 B
Python
Raw Normal View History

2019-09-09 16:58:58 +08:00
import asyncio
import pytest
2019-09-14 23:37:01 +08:00
from tests.factories import net_stream_pair_factory, swarm_pair_factory
2019-09-09 16:58:58 +08:00
@pytest.fixture
2019-09-14 23:37:01 +08:00
async def net_stream_pair(is_host_secure):
stream_0, host_0, stream_1, host_1 = await net_stream_pair_factory(is_host_secure)
2019-09-09 16:58:58 +08:00
try:
yield stream_0, stream_1
finally:
await asyncio.gather(*[host_0.close(), host_1.close()])
2019-09-14 23:37:01 +08:00
@pytest.fixture
async def swarm_pair(is_host_secure):
swarm_0, swarm_1 = await swarm_pair_factory(is_host_secure)
try:
yield swarm_0, swarm_1
finally:
await asyncio.gather(*[swarm_0.close(), swarm_1.close()])