Skip to content

Commit

Permalink
Revisit Floodsub (#543)
Browse files Browse the repository at this point in the history
Fixes #525

add coverage to unsubscribeAll and testing
  • Loading branch information
sinkingsugar committed Mar 15, 2021
1 parent a54e1cc commit 03bbdd2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/pubsub/testfloodsub.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{.used.}

import unittest, sequtils, options, tables
import unittest, sequtils, options, tables, sets
import chronos, stew/byteutils
import utils,
../../libp2p/[errors,
Expand Down Expand Up @@ -363,7 +363,18 @@ suite "FloodSub":
pubs &= nodes[i].publish("foobar", ("Hello!" & $i).toBytes())
await allFuturesThrowing(pubs)

# wait the test task
await allFuturesThrowing(futs.mapIt(it[0]))

# test calling unsubscribeAll for coverage
for node in nodes:
node.unsubscribeAll("foobar")
check:
# we keep the peers in table
FloodSub(node).floodsub["foobar"].len == 9
# remove the topic tho
node.topics.len == 0

await allFuturesThrowing(
nodes.mapIt(
allFutures(
Expand Down

0 comments on commit 03bbdd2

Please sign in to comment.