Re-enable lightpush tests and fix Windows CI failure (#572)

* Enable lightpush test again

- Stop nodes differently
- Bump port numbers to possibly get rid of Windows leaked resources

* Lightpush test mount relay w/o relaying messaging
This commit is contained in:
Oskar Thorén 2021-05-25 16:31:59 +08:00 committed by GitHub
parent e0d8d8f468
commit d99e9251b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 55 additions and 55 deletions

View File

@ -616,67 +616,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(60010))
# 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(60012))
# 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(60013))
# 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.mountRelay(relayMessages=false) # Mount WakuRelay, but do not start or subscribe to any topics
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 node2.stop() await allFutures([node1.stop(), node2.stop(), node3.stop()])
# await node3.stop()