mirror of https://github.com/vacp2p/nim-libp2p.git
fix gossipsub mesh test
This commit is contained in:
parent
bb0430e62b
commit
d42833947a
|
@ -7,7 +7,7 @@
|
||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import unittest, sequtils, options, tables, sets, heapqueue
|
import unittest, sequtils, options, tables, sets
|
||||||
import chronos
|
import chronos
|
||||||
import utils, ../../libp2p/[peer,
|
import utils, ../../libp2p/[peer,
|
||||||
peerinfo,
|
peerinfo,
|
||||||
|
@ -391,32 +391,33 @@ suite "GossipSub":
|
||||||
# check:
|
# check:
|
||||||
# waitFor(runTests()) == true
|
# waitFor(runTests()) == true
|
||||||
|
|
||||||
# test "e2e - GossipSub send over mesh A -> B":
|
test "e2e - GossipSub send over mesh A -> B":
|
||||||
# proc runTests(): Future[bool] {.async.} =
|
proc runTests(): Future[bool] {.async.} =
|
||||||
# var passed: Future[bool] = newFuture[bool]()
|
var passed: Future[bool] = newFuture[bool]()
|
||||||
# proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
||||||
# check topic == "foobar"
|
check topic == "foobar"
|
||||||
# passed.complete(true)
|
passed.complete(true)
|
||||||
|
|
||||||
# var nodes = generateNodes(2, true)
|
var nodes = generateNodes(2, true)
|
||||||
# var wait: seq[Future[void]]
|
var wait: seq[Future[void]]
|
||||||
# wait.add(await nodes[0].start())
|
wait.add(await nodes[0].start())
|
||||||
# wait.add(await nodes[1].start())
|
wait.add(await nodes[1].start())
|
||||||
|
|
||||||
# await nodes[0].subscribe("foobar", handler)
|
await subscribeNodes(nodes)
|
||||||
# await nodes[1].subscribe("foobar", handler)
|
await sleepAsync(100.millis)
|
||||||
|
|
||||||
# await nodes[0].subscribeToPeer(nodes[1].peerInfo)
|
await nodes[1].subscribe("foobar", handler)
|
||||||
# await sleepAsync(100.millis)
|
await sleepAsync(100.millis)
|
||||||
|
|
||||||
# await nodes[0].publish("foobar", cast[seq[byte]]("Hello!"))
|
await nodes[0].publish("foobar", cast[seq[byte]]("Hello!"))
|
||||||
# result = await passed
|
result = await passed
|
||||||
# await nodes[1].stop()
|
|
||||||
# await allFutures(wait)
|
|
||||||
|
|
||||||
# check:
|
await nodes[0].stop()
|
||||||
# waitFor(runTests()) == true
|
await nodes[1].stop()
|
||||||
# getGlobalDispatcher().timers.clear()
|
await allFutures(wait)
|
||||||
|
|
||||||
|
check:
|
||||||
|
waitFor(runTests()) == true
|
||||||
|
|
||||||
# test "with multiple peers":
|
# test "with multiple peers":
|
||||||
# proc runTests(): Future[bool] {.async.} =
|
# proc runTests(): Future[bool] {.async.} =
|
||||||
|
|
Loading…
Reference in New Issue