mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-05 19:43:41 +00:00
deploy: c22c1e05bc3fc85fdf9fe119fa43ddb251afdfec
This commit is contained in:
parent
71a901d22a
commit
2449e249a0
@ -568,67 +568,67 @@ procSuite "WakuNode":
|
|||||||
|
|
||||||
await allFutures([node1.stop(), node2.stop()])
|
await allFutures([node1.stop(), node2.stop()])
|
||||||
|
|
||||||
asyncTest "Lightpush message return success":
|
# asyncTest "Lightpush message return success":
|
||||||
let
|
# let
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
# nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node1 = WakuNode.init(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
# node1 = WakuNode.init(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||||
Port(60000))
|
# Port(60000))
|
||||||
nodeKey2 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
# nodeKey2 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node2 = WakuNode.init(nodeKey2, ValidIpAddress.init("0.0.0.0"),
|
# node2 = WakuNode.init(nodeKey2, ValidIpAddress.init("0.0.0.0"),
|
||||||
Port(60002))
|
# Port(60002))
|
||||||
nodeKey3 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
# nodeKey3 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node3 = WakuNode.init(nodeKey3, ValidIpAddress.init("0.0.0.0"),
|
# node3 = WakuNode.init(nodeKey3, ValidIpAddress.init("0.0.0.0"),
|
||||||
Port(60003))
|
# Port(60003))
|
||||||
pubSubTopic = "test"
|
# pubSubTopic = "test"
|
||||||
contentTopic = ContentTopic("/waku/2/default-content/proto")
|
# contentTopic = ContentTopic("/waku/2/default-content/proto")
|
||||||
payload = "hello world".toBytes()
|
# payload = "hello world".toBytes()
|
||||||
message = WakuMessage(payload: payload, contentTopic: contentTopic)
|
# message = WakuMessage(payload: payload, contentTopic: contentTopic)
|
||||||
|
|
||||||
# Light node, only lightpush
|
# # Light node, only lightpush
|
||||||
await node1.start()
|
# await node1.start()
|
||||||
node1.mountLightPush()
|
# node1.mountLightPush()
|
||||||
|
|
||||||
# Intermediate node
|
# # Intermediate node
|
||||||
await node2.start()
|
# await node2.start()
|
||||||
node2.mountRelay(@[pubSubTopic])
|
# node2.mountRelay(@[pubSubTopic])
|
||||||
node2.mountLightPush()
|
# node2.mountLightPush()
|
||||||
|
|
||||||
# Receiving node
|
# # Receiving node
|
||||||
await node3.start()
|
# await node3.start()
|
||||||
node3.mountRelay(@[pubSubTopic])
|
# node3.mountRelay(@[pubSubTopic])
|
||||||
|
|
||||||
discard await node1.peerManager.dialPeer(node2.peerInfo, WakuLightPushCodec)
|
# discard await node1.peerManager.dialPeer(node2.peerInfo, WakuLightPushCodec)
|
||||||
await sleepAsync(5.seconds)
|
# await sleepAsync(5.seconds)
|
||||||
await node3.connectToNodes(@[node2.peerInfo])
|
# await node3.connectToNodes(@[node2.peerInfo])
|
||||||
|
|
||||||
var completionFutLightPush = newFuture[bool]()
|
# var completionFutLightPush = newFuture[bool]()
|
||||||
var completionFutRelay = newFuture[bool]()
|
# var completionFutRelay = newFuture[bool]()
|
||||||
proc relayHandler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
# proc relayHandler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
||||||
let msg = WakuMessage.init(data)
|
# let msg = WakuMessage.init(data)
|
||||||
if msg.isOk():
|
# if msg.isOk():
|
||||||
let val = msg.value()
|
# let val = msg.value()
|
||||||
check:
|
# check:
|
||||||
topic == pubSubTopic
|
# topic == pubSubTopic
|
||||||
val.contentTopic == contentTopic
|
# val.contentTopic == contentTopic
|
||||||
val.payload == payload
|
# val.payload == payload
|
||||||
completionFutRelay.complete(true)
|
# completionFutRelay.complete(true)
|
||||||
|
|
||||||
node3.subscribe(pubSubTopic, relayHandler)
|
# node3.subscribe(pubSubTopic, relayHandler)
|
||||||
await sleepAsync(2000.millis)
|
# await sleepAsync(2000.millis)
|
||||||
|
|
||||||
proc handler(response: PushResponse) {.gcsafe, closure.} =
|
# proc handler(response: PushResponse) {.gcsafe, closure.} =
|
||||||
debug "push response handler, expecting true"
|
# debug "push response handler, expecting true"
|
||||||
check:
|
# check:
|
||||||
response.isSuccess == true
|
# response.isSuccess == true
|
||||||
completionFutLightPush.complete(true)
|
# completionFutLightPush.complete(true)
|
||||||
|
|
||||||
# Publishing with lightpush
|
# # Publishing with lightpush
|
||||||
await node1.lightpush(pubSubTopic, message, handler)
|
# await node1.lightpush(pubSubTopic, message, handler)
|
||||||
await sleepAsync(2000.millis)
|
# await sleepAsync(2000.millis)
|
||||||
|
|
||||||
check:
|
# check:
|
||||||
(await completionFutRelay.withTimeout(5.seconds)) == true
|
# (await completionFutRelay.withTimeout(5.seconds)) == true
|
||||||
(await completionFutLightPush.withTimeout(5.seconds)) == true
|
# (await completionFutLightPush.withTimeout(5.seconds)) == true
|
||||||
await node1.stop()
|
# await node1.stop()
|
||||||
await node2.stop()
|
# await node2.stop()
|
||||||
await node3.stop()
|
# await node3.stop()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# libtool - Provide generalized library-building support services.
|
# libtool - Provide generalized library-building support services.
|
||||||
# Generated automatically by config.status (libbacktrace) version-unused
|
# Generated automatically by config.status (libbacktrace) version-unused
|
||||||
# Libtool was configured on host fv-az231-223:
|
# Libtool was configured on host fv-az132-34:
|
||||||
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
||||||
#
|
#
|
||||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user