From 03bbdd22619a2357dd2f3c0ae18fd5bf93a2f0b5 Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Date: Tue, 16 Mar 2021 04:16:03 +0900 Subject: [PATCH] Revisit Floodsub (#543) Fixes #525 add coverage to unsubscribeAll and testing --- tests/pubsub/testfloodsub.nim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/pubsub/testfloodsub.nim b/tests/pubsub/testfloodsub.nim index 4fd8b75..347e668 100644 --- a/tests/pubsub/testfloodsub.nim +++ b/tests/pubsub/testfloodsub.nim @@ -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(