mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 16:10:57 +00:00
Reorganize factories
This commit is contained in:
@ -3,16 +3,13 @@ import asyncio
|
||||
import pytest
|
||||
|
||||
from libp2p.network.exceptions import SwarmException
|
||||
from tests.factories import ListeningSwarmFactory
|
||||
from tests.factories import SwarmFactory
|
||||
from tests.utils import connect_swarm
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_swarm_dial_peer(is_host_secure):
|
||||
swarms_and_keys = await ListeningSwarmFactory.create_batch_and_listen(
|
||||
is_host_secure, 3
|
||||
)
|
||||
swarms = tuple(swarm for swarm, _key_pair in swarms_and_keys)
|
||||
swarms = await SwarmFactory.create_batch_and_listen(is_host_secure, 3)
|
||||
# Test: No addr found.
|
||||
with pytest.raises(SwarmException):
|
||||
await swarms[0].dial_peer(swarms[1].get_peer_id())
|
||||
@ -44,10 +41,7 @@ async def test_swarm_dial_peer(is_host_secure):
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_swarm_close_peer(is_host_secure):
|
||||
swarms_and_keys = await ListeningSwarmFactory.create_batch_and_listen(
|
||||
is_host_secure, 3
|
||||
)
|
||||
swarms = tuple(swarm for swarm, _key_pair in swarms_and_keys)
|
||||
swarms = await SwarmFactory.create_batch_and_listen(is_host_secure, 3)
|
||||
# 0 <> 1 <> 2
|
||||
await connect_swarm(swarms[0], swarms[1])
|
||||
await connect_swarm(swarms[1], swarms[2])
|
||||
|
||||
Reference in New Issue
Block a user