Add test for host connect and disconnect

This commit is contained in:
mhchia
2019-09-02 17:32:15 +08:00
parent dfd9ebdc5e
commit 56ef0b962c
7 changed files with 126 additions and 76 deletions

View File

@ -1,8 +1,11 @@
import asyncio
import sys
import pexpect
import pytest
from .daemon import make_p2pd
@pytest.fixture
def proc_factory():
@ -22,3 +25,19 @@ def proc_factory():
finally:
for proc in procs:
proc.close()
@pytest.fixture
def num_p2pds():
return 1
@pytest.fixture
async def p2pds(num_p2pds, is_host_secure, unused_tcp_port_factory):
p2pds = await asyncio.gather(
*[make_p2pd(unused_tcp_port_factory, is_host_secure) for _ in range(num_p2pds)]
)
try:
yield p2pds
finally:
await asyncio.gather(*[p2pd.close() for p2pd in p2pds])