Skip to content

Commit

Permalink
chore: handle same relay with multiple addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Nov 7, 2024
1 parent 4cd2517 commit 66b48be
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/integration-tests/test/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,20 @@ export async function hasRelay (node: Libp2p, opts?: PWaitForOptions<PeerId>): P

// Wait for peer to be used as a relay
await pWaitFor(() => {
const relayAddrs = node.getMultiaddrs().filter(addr => addr.protoNames().includes('p2p-circuit'))
const relayHosts = new Set<string>()

const relayAddrs = node.getMultiaddrs().filter(addr => {
const options = addr.toOptions()
relayHosts.add(options.host)

return addr.protoNames().includes('p2p-circuit')
})

if (relayAddrs.length === 0) {
return false
}

if (relayAddrs.length !== 1) {
if (relayHosts.size !== 1) {
throw new Error(`node listening on too many relays - ${relayAddrs.length}`)
}

Expand Down

0 comments on commit 66b48be

Please sign in to comment.