Fix test and reduce number of nodes in test_join
This commit is contained in:
parent
c0a3af69e0
commit
0cc8a205fb
|
@ -13,20 +13,20 @@ SUPPORTED_PROTOCOLS = ["/gossipsub/1.0.0"]
|
|||
@pytest.mark.asyncio
|
||||
async def test_join():
|
||||
# Create libp2p hosts
|
||||
num_hosts = 10
|
||||
num_hosts = 4
|
||||
hosts_indices = list(range(num_hosts))
|
||||
libp2p_hosts = await create_libp2p_hosts(num_hosts)
|
||||
|
||||
# Create pubsub, gossipsub instances
|
||||
pubsubs, gossipsubs = create_pubsub_and_gossipsub_instances(libp2p_hosts, \
|
||||
SUPPORTED_PROTOCOLS, \
|
||||
10, 9, 11, 30, 3, 5, 0.5)
|
||||
4, 3, 5, 30, 3, 5, 0.5)
|
||||
|
||||
topic = "test_join"
|
||||
central_node_index = 0
|
||||
# Remove index of central host from the indices
|
||||
hosts_indices.remove(central_node_index)
|
||||
num_subscribed_peer = 6
|
||||
num_subscribed_peer = 2
|
||||
subscribed_peer_indices = random.sample(hosts_indices, num_subscribed_peer)
|
||||
|
||||
# All pubsub except the one of central node subscribe to topic
|
||||
|
@ -57,6 +57,8 @@ async def test_join():
|
|||
# Central node subscribes the topic
|
||||
await pubsubs[central_node_index].subscribe(topic)
|
||||
|
||||
await asyncio.sleep(2)
|
||||
|
||||
# Check that the gossipsub of central node no longer has fanout for the topic
|
||||
assert topic not in gossipsubs[central_node_index].fanout
|
||||
|
||||
|
@ -66,7 +68,7 @@ async def test_join():
|
|||
assert str(libp2p_hosts[central_node_index].get_id()) in gossipsubs[i].mesh[topic]
|
||||
else:
|
||||
assert str(libp2p_hosts[i].get_id()) not in gossipsubs[central_node_index].mesh[topic]
|
||||
assert str(libp2p_hosts[central_node_index].get_id()) not in gossipsubs[i].mesh[topic]
|
||||
assert topic not in gossipsubs[i].mesh
|
||||
|
||||
await cleanup()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user