Revisit Floodsub (#543)

Fixes #525

add coverage to unsubscribeAll and testing
This commit is contained in:
Giovanni Petrantoni 2021-03-16 04:16:03 +09:00 committed by GitHub
parent a54e1cc699
commit 03bbdd2261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -9,7 +9,7 @@
{.used.}
import unittest, sequtils, options, tables
import unittest, sequtils, options, tables, sets
import chronos, stew/byteutils
import utils,
../../libp2p/[errors,
@ -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(