2019-09-18 15:44:45 +08:00
|
|
|
import asyncio
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2019-11-21 11:47:54 +08:00
|
|
|
from libp2p.tools.factories import mplex_conn_pair_factory, mplex_stream_pair_factory
|
2019-09-18 15:44:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
async def mplex_conn_pair(is_host_secure):
|
|
|
|
mplex_conn_0, swarm_0, mplex_conn_1, swarm_1 = await mplex_conn_pair_factory(
|
|
|
|
is_host_secure
|
|
|
|
)
|
2019-10-25 01:25:51 +08:00
|
|
|
assert mplex_conn_0.is_initiator
|
|
|
|
assert not mplex_conn_1.is_initiator
|
2019-09-18 15:44:45 +08:00
|
|
|
try:
|
|
|
|
yield mplex_conn_0, mplex_conn_1
|
|
|
|
finally:
|
|
|
|
await asyncio.gather(*[swarm_0.close(), swarm_1.close()])
|
2019-09-18 21:51:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
async def mplex_stream_pair(is_host_secure):
|
|
|
|
mplex_stream_0, swarm_0, mplex_stream_1, swarm_1 = await mplex_stream_pair_factory(
|
|
|
|
is_host_secure
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
yield mplex_stream_0, mplex_stream_1
|
|
|
|
finally:
|
|
|
|
await asyncio.gather(*[swarm_0.close(), swarm_1.close()])
|