Revisit Floodsub (#543)
Fixes #525 add coverage to unsubscribeAll and testing
This commit is contained in:
parent
a54e1cc699
commit
03bbdd2261
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
{.used.}
|
{.used.}
|
||||||
|
|
||||||
import unittest, sequtils, options, tables
|
import unittest, sequtils, options, tables, sets
|
||||||
import chronos, stew/byteutils
|
import chronos, stew/byteutils
|
||||||
import utils,
|
import utils,
|
||||||
../../libp2p/[errors,
|
../../libp2p/[errors,
|
||||||
|
@ -363,7 +363,18 @@ suite "FloodSub":
|
||||||
pubs &= nodes[i].publish("foobar", ("Hello!" & $i).toBytes())
|
pubs &= nodes[i].publish("foobar", ("Hello!" & $i).toBytes())
|
||||||
await allFuturesThrowing(pubs)
|
await allFuturesThrowing(pubs)
|
||||||
|
|
||||||
|
# wait the test task
|
||||||
await allFuturesThrowing(futs.mapIt(it[0]))
|
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(
|
await allFuturesThrowing(
|
||||||
nodes.mapIt(
|
nodes.mapIt(
|
||||||
allFutures(
|
allFutures(
|
||||||
|
|
Loading…
Reference in New Issue