Some finishing touches

This commit is contained in:
Ludovic Chenut 2022-12-20 14:54:53 +01:00
parent eaa55abe48
commit cd2e30f6dd
No known key found for this signature in database
GPG Key ID: D9A59B1907F1D50C
2 changed files with 4 additions and 6 deletions

View File

@ -13,8 +13,8 @@ else:
{.push raises: [].}
import chronos, chronicles, times, tables, sequtils, options
import ../../switch,
relay/[client, utils]
import ../switch,
../protocols/connectivity/relay/[client, utils]
logScope:
topics = "libp2p autorelay"
@ -66,6 +66,7 @@ method setup*(self: AutoRelayService, switch: Switch): Future[bool] {.async, gcs
future[].cancel()
switch.addPeerEventHandler(handlePeerJoined, Joined)
switch.addPeerEventHandler(handlePeerLeft, Left)
await self.run(switch)
return hasBeenSetUp
proc manageBackedOff(self: AutoRelayService, pid: PeerId) {.async.} =

View File

@ -6,7 +6,7 @@ import ../libp2p/[protocols/connectivity/relay/relay,
protocols/connectivity/relay/messages,
protocols/connectivity/relay/utils,
protocols/connectivity/relay/client,
protocols/connectivity/autorelay]
services/autorelayservice]
import ./helpers
import stew/byteutils
@ -55,7 +55,6 @@ suite "Autorelay":
switchClient = createSwitch(relayClient, autorelay)
await allFutures(switchClient.start(), switchRelay.start())
await switchClient.connect(switchRelay.peerInfo.peerId, switchRelay.peerInfo.addrs)
discard autorelay.run(switchClient)
await fut.wait(1.seconds)
let addresses = autorelay.getAddresses()
check:
@ -73,7 +72,6 @@ suite "Autorelay":
let autorelay = AutoRelayService.new(3, relayClient, checkMA, newRng())
switchClient = createSwitch(relayClient, autorelay)
await allFutures(switchClient.start(), switchRelay.start())
discard autorelay.run(switchClient)
await sleepAsync(500.millis)
await switchClient.connect(switchRelay.peerInfo.peerId, switchRelay.peerInfo.addrs)
await fut.wait(1.seconds)
@ -114,7 +112,6 @@ suite "Autorelay":
switchClient = createSwitch(relayClient, autorelay)
await allFutures(switchClient.start(), rel1.start(), rel2.start(), rel3.start())
await switchClient.connect(rel1.peerInfo.peerId, rel1.peerInfo.addrs)
discard autorelay.run(switchClient)
await sleepAsync(500.millis)
await switchClient.connect(rel2.peerInfo.peerId, rel2.peerInfo.addrs)
await switchClient.connect(rel3.peerInfo.peerId, rel3.peerInfo.addrs)