Update tests in test_tcp.py

Besides, run `make format`
This commit is contained in:
mhchia
2019-12-01 16:26:16 +08:00
parent 1e600ea7e0
commit 79fcdf3a02
10 changed files with 55 additions and 43 deletions

View File

@ -1,7 +1,7 @@
from typing import TYPE_CHECKING, Any, Awaitable, List, Set, Tuple
import trio
from async_service import Service
import trio
from libp2p.network.connection.net_connection_interface import INetConn
from libp2p.network.stream.net_stream import NetStream

View File

@ -2,7 +2,6 @@ import logging
from typing import Dict, List, Optional
from async_service import Service
from multiaddr import Multiaddr
import trio
@ -205,7 +204,7 @@ class Swarm(INetwork, Service):
logger.debug("successfully opened connection to peer %s", peer_id)
# FIXME: This is a intentional barrier to prevent from the handler exiting and
# closing the connection.
# closing the connection. Probably change to `Service.manager.wait_finished`?
await trio.sleep_forever()
try:
@ -229,16 +228,6 @@ class Swarm(INetwork, Service):
async def close(self) -> None:
# TODO: Prevent from new listeners and conns being added.
# Reference: https://github.com/libp2p/go-libp2p-swarm/blob/8be680aef8dea0a4497283f2f98470c2aeae6b65/swarm.go#L124-L134 # noqa: E501
# Close listeners
# await asyncio.gather(
# *[listener.close() for listener in self.listeners.values()]
# )
# # Close connections
# await asyncio.gather(
# *[connection.close() for connection in self.connections.values()]
# )
await self.manager.stop()
await self.manager.wait_finished()
logger.debug("swarm successfully closed")