2020-04-29 13:54:03 +08:00
|
|
|
import
|
|
|
|
|
os, strformat, chronicles, json_rpc/[rpcclient, rpcserver], nimcrypto/sysrand,
|
|
|
|
|
eth/common as eth_common, eth/keys,
|
2020-05-27 12:25:10 +08:00
|
|
|
options
|
|
|
|
|
#options as what # TODO: Huh? Redefinition?
|
2020-04-29 13:54:03 +08:00
|
|
|
|
|
|
|
|
from os import DirSep
|
|
|
|
|
from strutils import rsplit
|
|
|
|
|
template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0]
|
|
|
|
|
|
|
|
|
|
const sigWakuPath = &"{sourceDir}{DirSep}rpc{DirSep}wakucallsigs.nim"
|
|
|
|
|
createRpcSigs(RpcHttpClient, sigWakuPath)
|
|
|
|
|
|
2020-05-27 12:25:10 +08:00
|
|
|
const topicAmount = 100
|
|
|
|
|
|
2020-04-29 13:54:03 +08:00
|
|
|
let node1 = newRpcHttpClient()
|
2020-05-22 14:25:09 +08:00
|
|
|
let node2 = newRpcHttpClient()
|
2020-05-28 11:52:57 +08:00
|
|
|
let node3 = newRpcHttpClient()
|
|
|
|
|
let node4 = newRpcHttpClient()
|
|
|
|
|
let node5 = newRpcHttpClient()
|
|
|
|
|
let node6 = newRpcHttpClient()
|
2020-04-29 13:54:03 +08:00
|
|
|
|
2020-05-22 12:23:41 +08:00
|
|
|
waitFor node1.connect("localhost", Port(8547))
|
2020-05-22 14:25:09 +08:00
|
|
|
waitFor node2.connect("localhost", Port(8548))
|
2020-05-28 11:52:57 +08:00
|
|
|
waitFor node3.connect("localhost", Port(8549))
|
|
|
|
|
waitFor node4.connect("localhost", Port(8550))
|
|
|
|
|
waitFor node5.connect("localhost", Port(8551))
|
|
|
|
|
waitFor node6.connect("localhost", Port(8552))
|
2020-04-29 13:54:03 +08:00
|
|
|
|
2020-05-28 11:52:57 +08:00
|
|
|
let version = waitFor node6.wakuVersion()
|
|
|
|
|
info "Version is", version
|
2020-04-29 13:54:03 +08:00
|
|
|
|
2020-05-22 15:35:31 +08:00
|
|
|
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
|
|
|
|
debug "Hit handler", topic=topic, data=data
|
|
|
|
|
|
|
|
|
|
# TODO: Implement handler logic
|
2020-05-28 11:52:57 +08:00
|
|
|
# All subscribing to foobar topic
|
|
|
|
|
let res2 = waitFor node2.wakuSubscribe("foobar")
|
|
|
|
|
let res3 = waitFor node3.wakuSubscribe("foobar")
|
|
|
|
|
let res4 = waitFor node4.wakuSubscribe("foobar")
|
|
|
|
|
let res5 = waitFor node5.wakuSubscribe("foobar")
|
|
|
|
|
let res6 = waitFor node6.wakuSubscribe("foobar")
|
2020-05-26 12:02:25 +08:00
|
|
|
os.sleep(2000)
|
2020-05-27 12:25:10 +08:00
|
|
|
|
|
|
|
|
# info "Posting envelopes on all subscribed topics"
|
|
|
|
|
for i in 0..<topicAmount:
|
|
|
|
|
let res2 = waitFor node1.wakuPublish("foobar", "hello world")
|
|
|
|
|
|
2020-05-26 12:02:25 +08:00
|
|
|
os.sleep(2000)
|