mirror of https://github.com/waku-org/nwaku.git
Begin of waku v2 rpc tests (#210)
This commit is contained in:
parent
a6e94bf171
commit
093efbf736
|
@ -4,4 +4,5 @@ import
|
||||||
# ./v2/test_waku,
|
# ./v2/test_waku,
|
||||||
./v2/test_wakunode,
|
./v2/test_wakunode,
|
||||||
./v2/test_waku_store,
|
./v2/test_waku_store,
|
||||||
./v2/test_waku_filter
|
./v2/test_waku_filter,
|
||||||
|
./v2/test_rpc_waku
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
{.used.}
|
||||||
|
|
||||||
|
import
|
||||||
|
std/[unittest, options, os, strutils],
|
||||||
|
stew/shims/net as stewNet,
|
||||||
|
json_rpc/[rpcserver, rpcclient],
|
||||||
|
libp2p/crypto/crypto,
|
||||||
|
../../waku/node/v2/[waku_types, wakunode2],
|
||||||
|
../../waku/node/v2/rpc/wakurpc,
|
||||||
|
../../waku/protocol/v2/waku_relay,
|
||||||
|
../test_helpers
|
||||||
|
|
||||||
|
template sourceDir*: string = currentSourcePath.rsplit(DirSep, 1)[0]
|
||||||
|
const sigPath = sourceDir / ParDir / ParDir / "waku" / "node" / "v2" / "rpc" / "wakucallsigs.nim"
|
||||||
|
createRpcSigs(RpcHttpClient, sigPath)
|
||||||
|
|
||||||
|
suite "Waku v2 Remote Procedure Calls":
|
||||||
|
# WakuNode setup
|
||||||
|
let
|
||||||
|
rng = crypto.newRng()
|
||||||
|
privkey = crypto.PrivateKey.random(Secp256k1, rng[]).tryGet()
|
||||||
|
bindIp = ValidIpAddress.init("0.0.0.0")
|
||||||
|
extIp = ValidIpAddress.init("127.0.0.1")
|
||||||
|
port = Port(9000)
|
||||||
|
node = WakuNode.init(privkey, bindIp, port, some(extIp), some(port), @["waku"])
|
||||||
|
|
||||||
|
waitFor node.start()
|
||||||
|
|
||||||
|
# RPC server setup
|
||||||
|
let
|
||||||
|
rpcPort = Port(8545)
|
||||||
|
ta = initTAddress(bindIp, rpcPort)
|
||||||
|
server = newRpcHttpServer([ta])
|
||||||
|
|
||||||
|
setupWakuRPC(node, server)
|
||||||
|
server.start()
|
||||||
|
|
||||||
|
asyncTest "waku_info":
|
||||||
|
# RPC client setup
|
||||||
|
let client = newRpcHttpClient()
|
||||||
|
await client.connect("127.0.0.1", rpcPort)
|
||||||
|
|
||||||
|
check await(client.waku_version()) == WakuRelayCodec
|
Loading…
Reference in New Issue