mirror of https://github.com/vacp2p/nim-libp2p.git
readding commented out tests
This commit is contained in:
parent
2066e81658
commit
f9f75254af
|
@ -67,53 +67,53 @@ proc subscribeNodes*(nodes: seq[Switch]) {.async.} =
|
|||
await allFutures(pending)
|
||||
|
||||
suite "PubSub":
|
||||
# test "FloodSub basic publish/subscribe A -> B":
|
||||
# proc testBasicPubSub(): Future[bool] {.async.} =
|
||||
# var passed: bool
|
||||
# proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
||||
# check topic == "foobar"
|
||||
# passed = true
|
||||
test "FloodSub basic publish/subscribe A -> B":
|
||||
proc testBasicPubSub(): Future[bool] {.async.} =
|
||||
var passed: bool
|
||||
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
||||
check topic == "foobar"
|
||||
passed = true
|
||||
|
||||
# var nodes = generateNodes(2)
|
||||
# var wait = await nodes[1].start()
|
||||
var nodes = generateNodes(2)
|
||||
var wait = await nodes[1].start()
|
||||
|
||||
# await nodes[0].subscribeToPeer(nodes[1].peerInfo)
|
||||
await nodes[0].subscribeToPeer(nodes[1].peerInfo)
|
||||
|
||||
# await nodes[1].subscribe("foobar", handler)
|
||||
# await sleepAsync(100.millis)
|
||||
await nodes[1].subscribe("foobar", handler)
|
||||
await sleepAsync(100.millis)
|
||||
|
||||
# await nodes[0].publish("foobar", cast[seq[byte]]("Hello!"))
|
||||
# await sleepAsync(100.millis)
|
||||
await nodes[0].publish("foobar", cast[seq[byte]]("Hello!"))
|
||||
await sleepAsync(100.millis)
|
||||
|
||||
# await nodes[1].stop()
|
||||
# await allFutures(wait)
|
||||
# result = passed
|
||||
await nodes[1].stop()
|
||||
await allFutures(wait)
|
||||
result = passed
|
||||
|
||||
# check:
|
||||
# waitFor(testBasicPubSub()) == true
|
||||
check:
|
||||
waitFor(testBasicPubSub()) == true
|
||||
|
||||
# test "FloodSub basic publish/subscribe B -> A":
|
||||
# proc testBasicPubSub(): Future[bool] {.async.} =
|
||||
# proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
||||
# check topic == "foobar"
|
||||
test "FloodSub basic publish/subscribe B -> A":
|
||||
proc testBasicPubSub(): Future[bool] {.async.} =
|
||||
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
||||
check topic == "foobar"
|
||||
|
||||
# var nodes = generateNodes(2)
|
||||
# var wait = await nodes[1].start()
|
||||
var nodes = generateNodes(2)
|
||||
var wait = await nodes[1].start()
|
||||
|
||||
# await nodes[0].subscribeToPeer(nodes[1].peerInfo)
|
||||
await nodes[0].subscribeToPeer(nodes[1].peerInfo)
|
||||
|
||||
# await nodes[0].subscribe("foobar", handler)
|
||||
# await sleepAsync(10.millis)
|
||||
await nodes[0].subscribe("foobar", handler)
|
||||
await sleepAsync(10.millis)
|
||||
|
||||
# await nodes[1].publish("foobar", cast[seq[byte]]("Hello!"))
|
||||
# await sleepAsync(10.millis)
|
||||
await nodes[1].publish("foobar", cast[seq[byte]]("Hello!"))
|
||||
await sleepAsync(10.millis)
|
||||
|
||||
# await nodes[1].stop()
|
||||
# await allFutures(wait)
|
||||
# result = true
|
||||
await nodes[1].stop()
|
||||
await allFutures(wait)
|
||||
result = true
|
||||
|
||||
# check:
|
||||
# waitFor(testBasicPubSub()) == true
|
||||
check:
|
||||
waitFor(testBasicPubSub()) == true
|
||||
|
||||
test "FloodSub multiple peers, no self trigger":
|
||||
proc testBasicFloodSub(): Future[bool] {.async.} =
|
||||
|
|
Loading…
Reference in New Issue