Skip to content

Commit

Permalink
TC fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankshampi committed Oct 5, 2024
1 parent e10e4d0 commit 89473da
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions tests/pubsub/testgossipmembership.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@ import ../../libp2p/builders
import ../../libp2p/errors
import ../../libp2p/crypto/crypto
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/muxers/muxer
import ../../libp2p/protocols/pubsub/rpc/protobuf
import utils
import chronos
import unittest2
import ../helpers
import chronos/ratelimit
import metrics
import chronicles

import ../../libp2p/protocols/pubsub/errors as pubsub_errors
import ../helpers

proc noop(data: seq[byte]) {.async: (raises: [CancelledError, LPStreamError]).} =
Expand Down Expand Up @@ -87,28 +83,21 @@ suite "GossipSub Topic Membership Tests":
let topic = "test-topic"
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
subscribeToTopics(gossipSub, @[topic])

# Check if the topic is present in the list of subscribed topics
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
await allFuturesThrowing(conns.mapIt(it.close()))

# Stop the gossipSub switch and wait for it to stop completely
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
asyncTest "handle UNSUBSCRIBE to the topic":
let topic = "test-topic"
Expand Down

0 comments on commit 89473da

Please sign in to comment.