mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-10 23:20:55 +00:00
Rewrite factories, made some of the test running
This commit is contained in:
@ -7,23 +7,13 @@ from libp2p.tools.factories import mplex_conn_pair_factory, mplex_stream_pair_fa
|
||||
|
||||
@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
|
||||
)
|
||||
assert mplex_conn_0.is_initiator
|
||||
assert not mplex_conn_1.is_initiator
|
||||
try:
|
||||
yield mplex_conn_0, mplex_conn_1
|
||||
finally:
|
||||
await asyncio.gather(*[swarm_0.close(), swarm_1.close()])
|
||||
async with mplex_conn_pair_factory(is_host_secure) as mplex_conn_pair:
|
||||
assert mplex_conn_pair[0].is_initiator
|
||||
assert not mplex_conn_pair[1].is_initiator
|
||||
yield mplex_conn_pair[0], mplex_conn_pair[1]
|
||||
|
||||
|
||||
@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()])
|
||||
async with mplex_stream_pair_factory(is_host_secure) as mplex_stream_pair:
|
||||
yield mplex_stream_pair
|
||||
|
||||
Reference in New Issue
Block a user