Skip to content

Commit

Permalink
chore: update the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
darshankabariya committed Aug 8, 2024
1 parent 09af224 commit faa79f8
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions apps/peer_exchange_tester/peer_exchange_tester.nim
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
# import random, strutils, asyncdispatch, chronos, chronicles, stew/byteutils, waku/[waku_peer_exchange, node/peer_manager], tests/testlib/wakucore
import random, chronos, chronicles, stew/byteutils, os
import waku/[waku_peer_exchange, node/peer_manager]
import tests/testlib/wakucore

proc createSwitch(): Switch =
echo "switch created"
let addrs = MultiAddress.init("/ip4/0.0.0.0/tcp/0").tryGet()
return newStandardSwitch(addrs = addrs)

proc connectToPeer(sw: Switch, peerAddr: string) {.async.} =
let ma = MultiAddress.init(peerAddr).tryGet()
let str = "16Uiu2HAkykgaECHswi3YKJ5dMLbq2kPVCo89fcyTd38UcQD6ej5W"
let peerIdData = cast[seq[byte]](str)
let peerId = PeerId(data: peerIdData)
echo "trying to connect with peer"
# await sw.connect(peerId, @[ma])
# discard sw.dial(peerId, "/vac/waku/peer-exchange/2.0.0-alpha1")
echo "2) ---------------> trying to connect with peer"
await sw.connect(peerId, @[ma])
# discard sw.dial(peerId, @[ma], "/vac/waku/peer-exchange/2.0.0-alpha1")
echo "Connected to peer with address: ", peerAddr

proc main() {.async.} =
echo "main started"
let addrs = "/ip4/178.128.141.171/tcp/30303"
let switch = createSwitch()
let addrs =
"/ip4/178.128.141.171/tcp/30303/16Uiu2HAkykgaECHswi3YKJ5dMLbq2kPVCo89fcyTd38UcQD6ej5W"
let switch = newStandardSwitch()
discard switch.start()

await connectToPeer(switch, addrs)
if len(switch.connectedPeers(Direction.Out)) > 0:
sleep(10000)
echo "Successfully out connected with Waku test fleet"
elif len(switch.connectedPeers(Direction.In)) > 0:
sleep(10000)
echo "Successfully in connected with Waku test fleet"
else:
sleep(10000)
echo "Not connected to any peers"

let peerManager = PeerManager.new(switch)
let wakuPx = WakuPeerExchange(peerManager: peerManager)

for i in 1 .. 20:
sleep(1000000)
let response = await wakuPx.request(5)
# check how many peerid arn't stale

when isMainModule:
waitFor main()
waitFor main()

0 comments on commit faa79f8

Please sign in to comment.