mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Noise: add noise option in the factories and tests
This commit is contained in:
@ -8,18 +8,22 @@ from libp2p.tools.factories import (
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def net_stream_pair(is_host_secure):
|
||||
async with net_stream_pair_factory(is_host_secure) as net_stream_pair:
|
||||
async def net_stream_pair(security_protocol):
|
||||
async with net_stream_pair_factory(
|
||||
security_protocol=security_protocol
|
||||
) as net_stream_pair:
|
||||
yield net_stream_pair
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def swarm_pair(is_host_secure):
|
||||
async with swarm_pair_factory(is_host_secure) as swarms:
|
||||
async def swarm_pair(security_protocol):
|
||||
async with swarm_pair_factory(security_protocol=security_protocol) as swarms:
|
||||
yield swarms
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def swarm_conn_pair(is_host_secure):
|
||||
async with swarm_conn_pair_factory(is_host_secure) as swarm_conn_pair:
|
||||
async def swarm_conn_pair(security_protocol):
|
||||
async with swarm_conn_pair_factory(
|
||||
security_protocol=security_protocol
|
||||
) as swarm_conn_pair:
|
||||
yield swarm_conn_pair
|
||||
|
||||
@ -55,8 +55,8 @@ class MyNotifee(INotifee):
|
||||
|
||||
|
||||
@pytest.mark.trio
|
||||
async def test_notify(is_host_secure):
|
||||
swarms = [SwarmFactory(is_secure=is_host_secure) for _ in range(2)]
|
||||
async def test_notify(security_protocol):
|
||||
swarms = [SwarmFactory(security_protocol=security_protocol) for _ in range(2)]
|
||||
|
||||
events_0_0 = []
|
||||
events_1_0 = []
|
||||
|
||||
@ -9,8 +9,10 @@ from libp2p.tools.utils import connect_swarm
|
||||
|
||||
|
||||
@pytest.mark.trio
|
||||
async def test_swarm_dial_peer(is_host_secure):
|
||||
async with SwarmFactory.create_batch_and_listen(is_host_secure, 3) as swarms:
|
||||
async def test_swarm_dial_peer(security_protocol):
|
||||
async with SwarmFactory.create_batch_and_listen(
|
||||
3, security_protocol=security_protocol
|
||||
) as swarms:
|
||||
# Test: No addr found.
|
||||
with pytest.raises(SwarmException):
|
||||
await swarms[0].dial_peer(swarms[1].get_peer_id())
|
||||
@ -38,8 +40,10 @@ async def test_swarm_dial_peer(is_host_secure):
|
||||
|
||||
|
||||
@pytest.mark.trio
|
||||
async def test_swarm_close_peer(is_host_secure):
|
||||
async with SwarmFactory.create_batch_and_listen(is_host_secure, 3) as swarms:
|
||||
async def test_swarm_close_peer(security_protocol):
|
||||
async with SwarmFactory.create_batch_and_listen(
|
||||
3, security_protocol=security_protocol
|
||||
) as swarms:
|
||||
# 0 <> 1 <> 2
|
||||
await connect_swarm(swarms[0], swarms[1])
|
||||
await connect_swarm(swarms[1], swarms[2])
|
||||
@ -90,8 +94,10 @@ async def test_swarm_remove_conn(swarm_pair):
|
||||
|
||||
|
||||
@pytest.mark.trio
|
||||
async def test_swarm_multiaddr(is_host_secure):
|
||||
async with SwarmFactory.create_batch_and_listen(is_host_secure, 3) as swarms:
|
||||
async def test_swarm_multiaddr(security_protocol):
|
||||
async with SwarmFactory.create_batch_and_listen(
|
||||
3, security_protocol=security_protocol
|
||||
) as swarms:
|
||||
|
||||
def clear():
|
||||
swarms[0].peerstore.clear_addrs(swarms[1].get_peer_id())
|
||||
|
||||
Reference in New Issue
Block a user