mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2025-03-03 17:40:38 +00:00
TC fix
This commit is contained in:
parent
e10e4d058b
commit
89473da8bc
@ -15,18 +15,14 @@ import ../../libp2p/builders
|
|||||||
import ../../libp2p/errors
|
import ../../libp2p/errors
|
||||||
import ../../libp2p/crypto/crypto
|
import ../../libp2p/crypto/crypto
|
||||||
import ../../libp2p/stream/bufferstream
|
import ../../libp2p/stream/bufferstream
|
||||||
|
import ../../libp2p/protocols/pubsub/[pubsub, gossipsub, mcache, mcache, peertable]
|
||||||
|
import ../../libp2p/protocols/pubsub/rpc/[message, messages]
|
||||||
import ../../libp2p/switch
|
import ../../libp2p/switch
|
||||||
import ../../libp2p/muxers/muxer
|
import ../../libp2p/muxers/muxer
|
||||||
import ../../libp2p/protocols/pubsub/rpc/protobuf
|
import ../../libp2p/protocols/pubsub/rpc/protobuf
|
||||||
import utils
|
import utils
|
||||||
import chronos
|
import chronos
|
||||||
import unittest2
|
|
||||||
import ../helpers
|
|
||||||
import chronos/ratelimit
|
|
||||||
import metrics
|
|
||||||
import chronicles
|
|
||||||
|
|
||||||
import ../../libp2p/protocols/pubsub/errors as pubsub_errors
|
|
||||||
import ../helpers
|
import ../helpers
|
||||||
|
|
||||||
proc noop(data: seq[byte]) {.async: (raises: [CancelledError, LPStreamError]).} =
|
proc noop(data: seq[byte]) {.async: (raises: [CancelledError, LPStreamError]).} =
|
||||||
@ -87,28 +83,21 @@ suite "GossipSub Topic Membership Tests":
|
|||||||
let topic = "test-topic"
|
let topic = "test-topic"
|
||||||
let (gossipSub, conns) = setupGossipSub(topic, 5)
|
let (gossipSub, conns) = setupGossipSub(topic, 5)
|
||||||
|
|
||||||
# Check if the topic is added to gossipsub and the peers list is not empty
|
|
||||||
check gossipSub.gossipsub[topic].len() > 0
|
|
||||||
|
|
||||||
# Subscribe to the topic
|
# Subscribe to the topic
|
||||||
subscribeToTopics(gossipSub, @[topic])
|
subscribeToTopics(gossipSub, @[topic])
|
||||||
|
|
||||||
# Check if the topic is present in the list of subscribed topics
|
# Check if the topic is present in the list of subscribed topics
|
||||||
check gossipSub.topics.contains(topic)
|
check gossipSub.topics.contains(topic)
|
||||||
|
|
||||||
|
# Check if the topic is added to gossipsub and the peers list is not empty
|
||||||
|
check gossipSub.gossipsub[topic].len() > 0
|
||||||
|
|
||||||
# Close all peer connections and verify that they are properly cleaned up
|
# Close all peer connections and verify that they are properly cleaned up
|
||||||
await allFuturesThrowing(conns.mapIt(it.close()))
|
await allFuturesThrowing(conns.mapIt(it.close()))
|
||||||
|
|
||||||
# Stop the gossipSub switch and wait for it to stop completely
|
# Stop the gossipSub switch and wait for it to stop completely
|
||||||
await gossipSub.switch.stop()
|
await gossipSub.switch.stop()
|
||||||
|
|
||||||
# Verify that connections have been closed and cleaned up after shutdown
|
|
||||||
for peer in gossipSub.peers.values:
|
|
||||||
check peer.sendConn == nil or peer.sendConn.closed()
|
|
||||||
|
|
||||||
# Ensure that the topic is removed from the mesh after stopping
|
|
||||||
check gossipSub.mesh[topic].len() == 0
|
|
||||||
|
|
||||||
# Simulate an UNSUBSCRIBE to the topic and check if the topic is removed from the relevant data structures but remains in gossipsub
|
# Simulate an UNSUBSCRIBE to the topic and check if the topic is removed from the relevant data structures but remains in gossipsub
|
||||||
asyncTest "handle UNSUBSCRIBE to the topic":
|
asyncTest "handle UNSUBSCRIBE to the topic":
|
||||||
let topic = "test-topic"
|
let topic = "test-topic"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user