2019-12-06 02:16:18 +00:00
|
|
|
## Nim-Libp2p
|
|
|
|
## Copyright (c) 2018 Status Research & Development GmbH
|
|
|
|
## Licensed under either of
|
|
|
|
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
## at your option.
|
|
|
|
## This file may not be copied, modified, or distributed except according to
|
|
|
|
## those terms.
|
|
|
|
|
2020-05-08 20:58:23 +00:00
|
|
|
{.used.}
|
|
|
|
|
2020-07-14 00:02:16 +00:00
|
|
|
import unittest, sequtils, options, tables
|
2020-06-03 02:21:11 +00:00
|
|
|
import chronos, stew/byteutils
|
2019-12-08 21:06:58 +00:00
|
|
|
import utils,
|
2020-04-21 01:24:42 +00:00
|
|
|
../../libp2p/[errors,
|
|
|
|
switch,
|
2020-06-19 17:29:43 +00:00
|
|
|
stream/connection,
|
2020-08-03 05:20:11 +00:00
|
|
|
stream/bufferstream,
|
2019-12-17 05:24:03 +00:00
|
|
|
crypto/crypto,
|
2020-08-03 05:20:11 +00:00
|
|
|
protocols/pubsub/pubsubpeer,
|
2019-12-17 05:24:03 +00:00
|
|
|
protocols/pubsub/pubsub,
|
2020-04-21 01:24:42 +00:00
|
|
|
protocols/pubsub/floodsub,
|
2020-07-15 19:18:55 +00:00
|
|
|
protocols/pubsub/rpc/messages,
|
|
|
|
protocols/pubsub/peertable]
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-05-08 20:10:06 +00:00
|
|
|
import ../helpers
|
2020-04-21 01:24:42 +00:00
|
|
|
|
|
|
|
proc waitSub(sender, receiver: auto; key: string) {.async, gcsafe.} =
|
|
|
|
# turn things deterministic
|
|
|
|
# this is for testing purposes only
|
|
|
|
var ceil = 15
|
2020-08-12 00:05:49 +00:00
|
|
|
let fsub = cast[FloodSub](sender)
|
2020-04-21 01:24:42 +00:00
|
|
|
while not fsub.floodsub.hasKey(key) or
|
2020-08-12 00:05:49 +00:00
|
|
|
not fsub.floodsub.hasPeerID(key, receiver.peerInfo.peerId):
|
2020-04-21 01:24:42 +00:00
|
|
|
await sleepAsync(100.millis)
|
|
|
|
dec ceil
|
|
|
|
doAssert(ceil > 0, "waitSub timeout!")
|
|
|
|
|
2019-12-06 02:16:18 +00:00
|
|
|
suite "FloodSub":
|
2020-04-21 01:24:42 +00:00
|
|
|
teardown:
|
2020-05-08 20:10:06 +00:00
|
|
|
for tracker in testTrackers():
|
2020-05-18 13:49:49 +00:00
|
|
|
# echo tracker.dump()
|
2020-05-08 20:10:06 +00:00
|
|
|
check tracker.isLeaked() == false
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2019-12-06 02:16:18 +00:00
|
|
|
test "FloodSub basic publish/subscribe A -> B":
|
2020-08-12 00:05:49 +00:00
|
|
|
proc runTests() {.async.} =
|
2019-12-06 02:16:18 +00:00
|
|
|
var completionFut = newFuture[bool]()
|
|
|
|
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
|
|
|
check topic == "foobar"
|
|
|
|
completionFut.complete(true)
|
|
|
|
|
2020-04-21 01:24:42 +00:00
|
|
|
let
|
|
|
|
nodes = generateNodes(2)
|
2020-08-12 00:05:49 +00:00
|
|
|
|
|
|
|
# start switches
|
2020-06-02 23:53:38 +00:00
|
|
|
nodesFut = await allFinished(
|
2020-08-12 00:05:49 +00:00
|
|
|
nodes[0].switch.start(),
|
|
|
|
nodes[1].switch.start(),
|
2020-04-21 01:24:42 +00:00
|
|
|
)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
# start pubsub
|
|
|
|
await allFuturesThrowing(
|
|
|
|
allFinished(
|
|
|
|
nodes[0].start(),
|
|
|
|
nodes[1].start(),
|
|
|
|
))
|
|
|
|
|
|
|
|
await subscribeNodes(nodes)
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2019-12-06 02:16:18 +00:00
|
|
|
await nodes[1].subscribe("foobar", handler)
|
2020-04-21 01:24:42 +00:00
|
|
|
await waitSub(nodes[0], nodes[1], "foobar")
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-07-08 00:33:05 +00:00
|
|
|
check (await nodes[0].publish("foobar", "Hello!".toBytes())) > 0
|
2020-08-12 00:05:49 +00:00
|
|
|
check (await completionFut.wait(5.seconds)) == true
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes[0].switch.stop(),
|
|
|
|
nodes[1].switch.stop()
|
|
|
|
)
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(
|
2020-04-21 01:24:42 +00:00
|
|
|
nodes[0].stop(),
|
|
|
|
nodes[1].stop()
|
|
|
|
)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(nodesFut.concat())
|
2020-05-23 17:14:22 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
waitFor(runTests())
|
2019-12-06 02:16:18 +00:00
|
|
|
|
|
|
|
test "FloodSub basic publish/subscribe B -> A":
|
2020-08-12 00:05:49 +00:00
|
|
|
proc runTests() {.async.} =
|
2019-12-06 02:16:18 +00:00
|
|
|
var completionFut = newFuture[bool]()
|
|
|
|
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
|
|
|
check topic == "foobar"
|
|
|
|
completionFut.complete(true)
|
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
let
|
|
|
|
nodes = generateNodes(2)
|
|
|
|
|
|
|
|
# start switches
|
|
|
|
nodesFut = await allFinished(
|
|
|
|
nodes[0].switch.start(),
|
|
|
|
nodes[1].switch.start(),
|
|
|
|
)
|
|
|
|
|
|
|
|
# start pubsubcon
|
|
|
|
await allFuturesThrowing(
|
|
|
|
allFinished(
|
|
|
|
nodes[0].start(),
|
|
|
|
nodes[1].start(),
|
|
|
|
))
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await subscribeNodes(nodes)
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2019-12-06 02:16:18 +00:00
|
|
|
await nodes[0].subscribe("foobar", handler)
|
2020-04-21 01:24:42 +00:00
|
|
|
await waitSub(nodes[1], nodes[0], "foobar")
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-07-08 00:33:05 +00:00
|
|
|
check (await nodes[1].publish("foobar", "Hello!".toBytes())) > 0
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
check (await completionFut.wait(5.seconds)) == true
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes[0].switch.stop(),
|
|
|
|
nodes[1].switch.stop()
|
|
|
|
)
|
|
|
|
|
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes[0].stop(),
|
|
|
|
nodes[1].stop()
|
|
|
|
)
|
2020-07-27 19:33:51 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(nodesFut)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
waitFor(runTests())
|
2019-12-17 05:24:03 +00:00
|
|
|
|
|
|
|
test "FloodSub validation should succeed":
|
2020-08-12 00:05:49 +00:00
|
|
|
proc runTests() {.async.} =
|
2019-12-17 05:24:03 +00:00
|
|
|
var handlerFut = newFuture[bool]()
|
|
|
|
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
|
|
|
check topic == "foobar"
|
|
|
|
handlerFut.complete(true)
|
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
let
|
|
|
|
nodes = generateNodes(2)
|
|
|
|
|
|
|
|
# start switches
|
|
|
|
nodesFut = await allFinished(
|
|
|
|
nodes[0].switch.start(),
|
|
|
|
nodes[1].switch.start(),
|
|
|
|
)
|
|
|
|
|
|
|
|
# start pubsubcon
|
|
|
|
await allFuturesThrowing(
|
|
|
|
allFinished(
|
|
|
|
nodes[0].start(),
|
|
|
|
nodes[1].start(),
|
|
|
|
))
|
|
|
|
|
|
|
|
await subscribeNodes(nodes)
|
2019-12-17 05:24:03 +00:00
|
|
|
|
|
|
|
await nodes[1].subscribe("foobar", handler)
|
2020-04-21 01:24:42 +00:00
|
|
|
await waitSub(nodes[0], nodes[1], "foobar")
|
2019-12-17 05:24:03 +00:00
|
|
|
|
|
|
|
var validatorFut = newFuture[bool]()
|
|
|
|
proc validator(topic: string,
|
|
|
|
message: Message): Future[bool] {.async.} =
|
|
|
|
check topic == "foobar"
|
|
|
|
validatorFut.complete(true)
|
|
|
|
result = true
|
|
|
|
|
|
|
|
nodes[1].addValidator("foobar", validator)
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-07-08 00:33:05 +00:00
|
|
|
check (await nodes[0].publish("foobar", "Hello!".toBytes())) > 0
|
2020-05-23 17:14:22 +00:00
|
|
|
check (await handlerFut) == true
|
2020-08-12 00:05:49 +00:00
|
|
|
|
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes[0].switch.stop(),
|
|
|
|
nodes[1].switch.stop()
|
|
|
|
)
|
|
|
|
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes[0].stop(),
|
2020-08-12 00:05:49 +00:00
|
|
|
nodes[1].stop()
|
|
|
|
)
|
2020-07-27 19:33:51 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(nodesFut)
|
2020-02-12 14:43:42 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
waitFor(runTests())
|
2019-12-17 05:24:03 +00:00
|
|
|
|
|
|
|
test "FloodSub validation should fail":
|
2020-08-12 00:05:49 +00:00
|
|
|
proc runTests() {.async.} =
|
2019-12-17 05:24:03 +00:00
|
|
|
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
|
|
|
check false # if we get here, it should fail
|
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
let
|
|
|
|
nodes = generateNodes(2)
|
|
|
|
|
|
|
|
# start switches
|
|
|
|
nodesFut = await allFinished(
|
|
|
|
nodes[0].switch.start(),
|
|
|
|
nodes[1].switch.start(),
|
|
|
|
)
|
|
|
|
|
|
|
|
# start pubsubcon
|
|
|
|
await allFuturesThrowing(
|
|
|
|
allFinished(
|
|
|
|
nodes[0].start(),
|
|
|
|
nodes[1].start(),
|
|
|
|
))
|
2019-12-17 05:24:03 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await subscribeNodes(nodes)
|
2019-12-17 05:24:03 +00:00
|
|
|
await nodes[1].subscribe("foobar", handler)
|
2020-04-21 01:24:42 +00:00
|
|
|
await waitSub(nodes[0], nodes[1], "foobar")
|
2019-12-17 05:24:03 +00:00
|
|
|
|
|
|
|
var validatorFut = newFuture[bool]()
|
|
|
|
proc validator(topic: string,
|
|
|
|
message: Message): Future[bool] {.async.} =
|
|
|
|
validatorFut.complete(true)
|
|
|
|
result = false
|
|
|
|
|
|
|
|
nodes[1].addValidator("foobar", validator)
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-07-08 00:33:05 +00:00
|
|
|
discard await nodes[0].publish("foobar", "Hello!".toBytes())
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes[0].switch.stop(),
|
|
|
|
nodes[1].switch.stop()
|
|
|
|
)
|
|
|
|
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes[0].stop(),
|
2020-08-12 00:05:49 +00:00
|
|
|
nodes[1].stop()
|
|
|
|
)
|
2020-07-27 19:33:51 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(nodesFut)
|
2019-12-17 05:24:03 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
waitFor(runTests())
|
2019-12-17 05:24:03 +00:00
|
|
|
|
|
|
|
test "FloodSub validation one fails and one succeeds":
|
2020-08-12 00:05:49 +00:00
|
|
|
proc runTests() {.async.} =
|
2019-12-17 05:24:03 +00:00
|
|
|
var handlerFut = newFuture[bool]()
|
|
|
|
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
|
|
|
check topic == "foo"
|
|
|
|
handlerFut.complete(true)
|
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
let
|
|
|
|
nodes = generateNodes(2)
|
|
|
|
|
|
|
|
# start switches
|
|
|
|
nodesFut = await allFinished(
|
|
|
|
nodes[0].switch.start(),
|
|
|
|
nodes[1].switch.start(),
|
|
|
|
)
|
|
|
|
|
|
|
|
# start pubsubcon
|
|
|
|
await allFuturesThrowing(
|
|
|
|
allFinished(
|
|
|
|
nodes[0].start(),
|
|
|
|
nodes[1].start(),
|
|
|
|
))
|
2019-12-17 05:24:03 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await subscribeNodes(nodes)
|
2019-12-17 05:24:03 +00:00
|
|
|
await nodes[1].subscribe("foo", handler)
|
2020-04-21 01:24:42 +00:00
|
|
|
await waitSub(nodes[0], nodes[1], "foo")
|
2019-12-17 05:24:03 +00:00
|
|
|
await nodes[1].subscribe("bar", handler)
|
2020-04-21 01:24:42 +00:00
|
|
|
await waitSub(nodes[0], nodes[1], "bar")
|
2019-12-17 05:24:03 +00:00
|
|
|
|
|
|
|
proc validator(topic: string,
|
|
|
|
message: Message): Future[bool] {.async.} =
|
|
|
|
if topic == "foo":
|
|
|
|
result = true
|
|
|
|
else:
|
|
|
|
result = false
|
|
|
|
|
|
|
|
nodes[1].addValidator("foo", "bar", validator)
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-07-08 00:33:05 +00:00
|
|
|
check (await nodes[0].publish("foo", "Hello!".toBytes())) > 0
|
|
|
|
check (await nodes[0].publish("bar", "Hello!".toBytes())) > 0
|
2019-12-17 05:24:03 +00:00
|
|
|
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(
|
2020-08-12 00:05:49 +00:00
|
|
|
nodes[0].switch.stop(),
|
|
|
|
nodes[1].switch.stop()
|
|
|
|
)
|
2020-08-03 05:20:11 +00:00
|
|
|
|
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes[0].stop(),
|
2020-08-12 00:05:49 +00:00
|
|
|
nodes[1].stop()
|
|
|
|
)
|
2020-08-03 05:20:11 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(nodesFut)
|
2020-08-03 05:20:11 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
waitFor(runTests())
|
2020-08-03 05:20:11 +00:00
|
|
|
|
2019-12-06 02:16:18 +00:00
|
|
|
test "FloodSub multiple peers, no self trigger":
|
2020-08-12 00:05:49 +00:00
|
|
|
proc runTests() {.async.} =
|
2020-05-21 20:24:20 +00:00
|
|
|
var runs = 10
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-05-21 20:24:20 +00:00
|
|
|
var futs = newSeq[(Future[void], TopicHandler, ref int)](runs)
|
|
|
|
for i in 0..<runs:
|
2020-04-21 01:24:42 +00:00
|
|
|
closureScope:
|
|
|
|
var
|
|
|
|
fut = newFuture[void]()
|
|
|
|
counter = new int
|
|
|
|
futs[i] = (
|
|
|
|
fut,
|
|
|
|
(proc(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
|
|
|
check topic == "foobar"
|
|
|
|
inc counter[]
|
2020-05-23 17:14:22 +00:00
|
|
|
if counter[] == runs - 1:
|
2020-04-21 01:24:42 +00:00
|
|
|
fut.complete()),
|
|
|
|
counter
|
|
|
|
)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
let
|
|
|
|
nodes = generateNodes(runs, triggerSelf = false)
|
|
|
|
nodesFut = nodes.mapIt(it.switch.start())
|
2020-05-08 20:10:06 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(nodes.mapIt(it.start()))
|
|
|
|
await subscribeNodes(nodes)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-05-21 20:24:20 +00:00
|
|
|
for i in 0..<runs:
|
2020-04-21 01:24:42 +00:00
|
|
|
await nodes[i].subscribe("foobar", futs[i][1])
|
2020-02-12 14:43:42 +00:00
|
|
|
|
2020-04-21 01:24:42 +00:00
|
|
|
var subs: seq[Future[void]]
|
2020-05-21 20:24:20 +00:00
|
|
|
for i in 0..<runs:
|
|
|
|
for y in 0..<runs:
|
2020-04-21 01:24:42 +00:00
|
|
|
if y != i:
|
|
|
|
subs &= waitSub(nodes[i], nodes[y], "foobar")
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(subs)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-07-08 00:33:05 +00:00
|
|
|
var pubs: seq[Future[int]]
|
2020-05-21 20:24:20 +00:00
|
|
|
for i in 0..<runs:
|
2020-06-03 02:21:11 +00:00
|
|
|
pubs &= nodes[i].publish("foobar", "Hello!".toBytes())
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(pubs)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(futs.mapIt(it[0]))
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes.mapIt(
|
|
|
|
allFutures(
|
|
|
|
it.stop(),
|
|
|
|
it.switch.stop())))
|
2020-07-27 19:33:51 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(nodesFut)
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
waitFor(runTests())
|
2019-12-06 02:16:18 +00:00
|
|
|
|
|
|
|
test "FloodSub multiple peers, with self trigger":
|
2020-08-12 00:05:49 +00:00
|
|
|
proc runTests() {.async.} =
|
2020-05-21 20:24:20 +00:00
|
|
|
var runs = 10
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-05-21 20:24:20 +00:00
|
|
|
var futs = newSeq[(Future[void], TopicHandler, ref int)](runs)
|
|
|
|
for i in 0..<runs:
|
2020-04-21 01:24:42 +00:00
|
|
|
closureScope:
|
|
|
|
var
|
|
|
|
fut = newFuture[void]()
|
|
|
|
counter = new int
|
|
|
|
futs[i] = (
|
|
|
|
fut,
|
|
|
|
(proc(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
|
|
|
check topic == "foobar"
|
|
|
|
inc counter[]
|
2020-08-12 00:05:49 +00:00
|
|
|
if counter[] == runs - 1:
|
2020-04-21 01:24:42 +00:00
|
|
|
fut.complete()),
|
|
|
|
counter
|
|
|
|
)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
let
|
|
|
|
nodes = generateNodes(runs, triggerSelf = true)
|
|
|
|
nodesFut = nodes.mapIt(it.switch.start())
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(nodes.mapIt(it.start()))
|
|
|
|
await subscribeNodes(nodes)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-05-21 20:24:20 +00:00
|
|
|
for i in 0..<runs:
|
2020-04-21 01:24:42 +00:00
|
|
|
await nodes[i].subscribe("foobar", futs[i][1])
|
2020-02-12 14:43:42 +00:00
|
|
|
|
2020-04-21 01:24:42 +00:00
|
|
|
var subs: seq[Future[void]]
|
2020-05-21 20:24:20 +00:00
|
|
|
for i in 0..<runs:
|
|
|
|
for y in 0..<runs:
|
2020-04-21 01:24:42 +00:00
|
|
|
if y != i:
|
|
|
|
subs &= waitSub(nodes[i], nodes[y], "foobar")
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(subs)
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-07-08 00:33:05 +00:00
|
|
|
var pubs: seq[Future[int]]
|
2020-05-21 20:24:20 +00:00
|
|
|
for i in 0..<runs:
|
2020-06-03 02:21:11 +00:00
|
|
|
pubs &= nodes[i].publish("foobar", "Hello!".toBytes())
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(pubs)
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-06-02 23:53:38 +00:00
|
|
|
await allFuturesThrowing(futs.mapIt(it[0]))
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(
|
|
|
|
nodes.mapIt(
|
|
|
|
allFutures(
|
|
|
|
it.stop(),
|
|
|
|
it.switch.stop())))
|
2019-12-06 02:16:18 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
await allFuturesThrowing(nodesFut)
|
2020-05-21 20:24:20 +00:00
|
|
|
|
2020-08-12 00:05:49 +00:00
|
|
|
waitFor(runTests())
|