mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-02-20 22:03:11 +00:00
test: initial peer_exchange tester
This commit is contained in:
parent
71946b911f
commit
eae7e23d7c
5
Makefile
5
Makefile
@ -229,7 +229,7 @@ test/%: | build deps librln
|
||||
################
|
||||
## Waku tools ##
|
||||
################
|
||||
.PHONY: tools wakucanary networkmonitor
|
||||
.PHONY: tools wakucanary networkmonitor peerexchangetester
|
||||
|
||||
tools: networkmonitor wakucanary
|
||||
|
||||
@ -241,6 +241,9 @@ networkmonitor: | build deps librln
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim networkmonitor $(NIM_PARAMS) waku.nims
|
||||
|
||||
peer_exchange_tester: | build deps librln
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim peer_exchange_tester $(NIM_PARAMS) waku.nims
|
||||
|
||||
###################
|
||||
## Documentation ##
|
||||
|
||||
0
apps/peer_exchange_tester/README.md
Normal file
0
apps/peer_exchange_tester/README.md
Normal file
4
apps/peer_exchange_tester/nim.cfg
Normal file
4
apps/peer_exchange_tester/nim.cfg
Normal file
@ -0,0 +1,4 @@
|
||||
-d:chronicles_line_numbers
|
||||
-d:chronicles_runtime_filtering:on
|
||||
-d:discv5_protocol_id:d5waku
|
||||
path = "../.."
|
||||
27
apps/peer_exchange_tester/peer_exchange_tester.nim
Normal file
27
apps/peer_exchange_tester/peer_exchange_tester.nim
Normal file
@ -0,0 +1,27 @@
|
||||
import
|
||||
std/[options, sequtils, random],
|
||||
chronos, chronicles, stew/byteutils
|
||||
|
||||
import
|
||||
waku/[waku_peer_exchange, node/peer_manager]
|
||||
|
||||
# import chronicles, chronos, stew/byteutils, results
|
||||
# import waku/[common/logging, node/peer_manager, waku_core, waku_filter_v2/client]
|
||||
|
||||
proc main() {.async.} =
|
||||
let switch = newStandardSwitch()
|
||||
let peerManager = PeerManager.new(switch)
|
||||
let wakuPx = WakuPeerExchange(peerManager: peerManager)
|
||||
|
||||
# Request peers and check if they are live
|
||||
let res = await wakuPx.request(5)
|
||||
if res.isOk:
|
||||
let peers = res.get().peerInfos.mapIt(it.enr)
|
||||
for peer in peers:
|
||||
echo "Peer ENR: ", peer
|
||||
# Add your logic to dial and check if the peer is live
|
||||
else:
|
||||
echo "Error requesting peers: ", res.error
|
||||
|
||||
when isMainModule:
|
||||
waitFor main()
|
||||
@ -111,6 +111,10 @@ task wakucanary, "Build waku-canary tool":
|
||||
let name = "wakucanary"
|
||||
buildBinary name, "apps/wakucanary/"
|
||||
|
||||
task peer_exchange_tester, "Build peer exchange tester tool":
|
||||
let name = "peer_exchange_tester"
|
||||
buildBinary name, "apps/peer_exchange_tester/"
|
||||
|
||||
task networkmonitor, "Build network monitor tool":
|
||||
let name = "networkmonitor"
|
||||
buildBinary name, "apps/networkmonitor/"
|
||||
|
||||
@ -203,4 +203,4 @@ proc new*(
|
||||
let wpx = WakuPeerExchange(peerManager: peerManager, cluster: cluster)
|
||||
wpx.initProtocolHandler()
|
||||
asyncSpawn wpx.updatePxEnrCache()
|
||||
return wpx
|
||||
return wpx
|
||||
Loading…
x
Reference in New Issue
Block a user