2023-02-10 09:43:16 +00:00
|
|
|
{.used.}
|
|
|
|
|
|
|
|
import
|
|
|
|
std/options,
|
|
|
|
stew/shims/net as stewNet,
|
|
|
|
testutils/unittests,
|
|
|
|
chronicles,
|
|
|
|
chronos,
|
|
|
|
libp2p/crypto/crypto,
|
|
|
|
json_rpc/[rpcserver, rpcclient]
|
|
|
|
import
|
2023-08-09 17:11:50 +00:00
|
|
|
../../../waku/node/peer_manager,
|
|
|
|
../../../waku/waku_node,
|
2023-09-22 13:36:46 +00:00
|
|
|
../../../waku/waku_api/jsonrpc/debug/handlers as debug_api,
|
|
|
|
../../../waku/waku_api/jsonrpc/debug/client as debug_api_client,
|
2023-04-05 14:01:51 +00:00
|
|
|
../testlib/common,
|
|
|
|
../testlib/wakucore,
|
|
|
|
../testlib/wakunode
|
2023-02-10 09:43:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
procSuite "Waku v2 JSON-RPC API - Debug":
|
|
|
|
let
|
2023-02-13 10:43:49 +00:00
|
|
|
privkey = generateSecp256k1Key()
|
2023-02-10 09:43:16 +00:00
|
|
|
bindIp = ValidIpAddress.init("0.0.0.0")
|
|
|
|
extIp = ValidIpAddress.init("127.0.0.1")
|
2023-02-13 11:27:49 +00:00
|
|
|
port = Port(0)
|
2023-04-05 14:01:51 +00:00
|
|
|
node = newTestWakuNode(privkey, bindIp, port, some(extIp), some(port))
|
2023-02-10 09:43:16 +00:00
|
|
|
|
|
|
|
asyncTest "get node info":
|
|
|
|
await node.start()
|
|
|
|
|
|
|
|
await node.mountRelay()
|
|
|
|
|
|
|
|
# RPC server setup
|
|
|
|
let
|
|
|
|
rpcPort = Port(8546)
|
|
|
|
ta = initTAddress(bindIp, rpcPort)
|
|
|
|
server = newRpcHttpServer([ta])
|
|
|
|
|
|
|
|
installDebugApiHandlers(node, server)
|
|
|
|
server.start()
|
|
|
|
|
|
|
|
let client = newRpcHttpClient()
|
|
|
|
await client.connect("127.0.0.1", rpcPort, false)
|
|
|
|
|
|
|
|
let response = await client.get_waku_v2_debug_v1_info()
|
|
|
|
|
|
|
|
check:
|
|
|
|
response.listenAddresses == @[$node.switch.peerInfo.addrs[^1] & "/p2p/" & $node.switch.peerInfo.peerId]
|
|
|
|
|
|
|
|
await server.stop()
|
|
|
|
await server.closeWait()
|
|
|
|
|
|
|
|
await node.stop()
|