Rewrite factories, made some of the test running

This commit is contained in:
mhchia
2019-11-26 19:24:30 +08:00
parent 417b5e7d61
commit ec43c25b45
13 changed files with 260 additions and 282 deletions

View File

@ -4,12 +4,12 @@ import secrets
import pytest
from libp2p.host.ping import ID, PING_LENGTH
from libp2p.tools.factories import pair_of_connected_hosts
from libp2p.tools.factories import host_pair_factory
@pytest.mark.asyncio
async def test_ping_once():
async with pair_of_connected_hosts() as (host_a, host_b):
async with host_pair_factory() as (host_a, host_b):
stream = await host_b.new_stream(host_a.get_id(), (ID,))
some_ping = secrets.token_bytes(PING_LENGTH)
await stream.write(some_ping)
@ -23,7 +23,7 @@ SOME_PING_COUNT = 3
@pytest.mark.asyncio
async def test_ping_several():
async with pair_of_connected_hosts() as (host_a, host_b):
async with host_pair_factory() as (host_a, host_b):
stream = await host_b.new_stream(host_a.get_id(), (ID,))
for _ in range(SOME_PING_COUNT):
some_ping = secrets.token_bytes(PING_LENGTH)