Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
chore: update deps (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos authored Apr 13, 2021
1 parent ddcc10b commit b8c7bf3
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 68 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir lint
- run: npx aegir dep-check
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [14, 15]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npx aegir test -t node --bail --cov
- uses: codecov/codecov-action@v1
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"release-major": "aegir release --type major -t node --no-build",
"coverage-publish": "aegir coverage publish"
},
"pre-push": [
"lint"
],
"repository": {
"type": "git",
"url": "https://github.com/libp2p/js-libp2p-mdns.git"
Expand All @@ -34,15 +31,15 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-mdns",
"devDependencies": {
"aegir": "^25.0.0",
"aegir": "^33.0.0",
"delay": "^4.3.0",
"libp2p-interfaces": "^0.4.0",
"libp2p-interfaces": "^0.10.0",
"p-defer": "^3.0.0",
"p-wait-for": "^3.1.0"
},
"dependencies": {
"debug": "^4.1.1",
"multiaddr": "^8.0.0",
"debug": "^4.3.1",
"multiaddr": "^9.0.1",
"multicast-dns": "^7.2.0",
"peer-id": "^0.14.0"
},
Expand Down
8 changes: 4 additions & 4 deletions src/compat/querier.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const EE = require('events')
const MDNS = require('multicast-dns')
const Multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const PeerId = require('peer-id')
const debug = require('debug')
const log = debug('libp2p:mdns:compat:querier')
Expand Down Expand Up @@ -127,10 +127,10 @@ module.exports = Querier
* running it again. `fn` must return an object with a stop function, which is
* called when the period expires.
*
* @param {Function} fn function to run
* @param {Function} fn - function to run
* @param {Object} [options]
* @param {Object} [options.period] Period in ms to run the function for
* @param {Object} [options.interval] Interval in ms between runs
* @param {Object} [options.period] - Period in ms to run the function for
* @param {Object} [options.interval] - Interval in ms between runs
* @returns {Object} handle that can be used to stop execution
*/
function periodically (fn, options) {
Expand Down
4 changes: 2 additions & 2 deletions src/compat/responder.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ class Responder {
})

addresses.forEach((ma) => {
if (['ipv4', 'ipv6'].includes(ma.family)) {
if ([4, 6].includes(ma.family)) {
answers.push({
name: OS.hostname(),
type: ma.family === 'ipv4' ? 'A' : 'AAAA',
type: ma.family === 4 ? 'A' : 'AAAA',
class: 'IN',
ttl: 120,
data: ma.host
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MulticastDNS extends EventEmitter {
}

_onPeer (peerData) {
this.emit('peer', peerData)
this.mdns && this.emit('peer', peerData)
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const os = require('os')
const debug = require('debug')
const log = debug('libp2p:mdns')
log.error = debug('libp2p:mdns:error')
const Multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const Id = require('peer-id')

module.exports = {
Expand Down Expand Up @@ -132,10 +132,10 @@ module.exports = {
})

addresses.forEach((addr) => {
if (['ipv4', 'ipv6'].includes(addr.family)) {
if ([4, 6].includes(addr.family)) {
answers.push({
name: os.hostname(),
type: addr.family === 'ipv4' ? 'A' : 'AAAA',
type: addr.family === 4 ? 'A' : 'AAAA',
class: 'IN',
ttl: 120,
data: addr.host
Expand Down
11 changes: 8 additions & 3 deletions test/compat/go-multicast-dns.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
'use strict'

const { expect } = require('aegir/utils/chai')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const PeerId = require('peer-id')
const pDefer = require('p-defer')

const GoMulticastDNS = require('../../src/compat')

describe('GoMulticastDNS', () => {
const peerAddrs = [
multiaddr('/ip4/127.0.0.1/tcp/20001'),
multiaddr('/ip4/127.0.0.1/tcp/20002')
new Multiaddr('/ip4/127.0.0.1/tcp/20001'),
new Multiaddr('/ip4/127.0.0.1/tcp/20002')
]
let peerIds

Expand Down Expand Up @@ -77,5 +77,10 @@ describe('GoMulticastDNS', () => {
])

await defer.promise

await Promise.all([
mdnsA.stop(),
mdnsB.stop()
])
})
})
6 changes: 4 additions & 2 deletions test/compat/querier.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ describe('Querier', () => {

/**
* Ensure peerIds[1] are emitted from `querier`
* @param {Function} getResponse Given a query, construct a response to test the querier
*
* @param {Function} getResponse - Given a query, construct a response to test the querier
*/
async function ensurePeer (getResponse) {
querier = new Querier({ peerId: peerIds[0] })
Expand All @@ -264,7 +265,8 @@ describe('Querier', () => {

/**
* Ensure none of peerIds are emitted from `querier`
* @param {Function} getResponse Given a query, construct a response to test the querier
*
* @param {Function} getResponse - Given a query, construct a response to test the querier
*/
async function ensureNoPeer (getResponse) {
querier = new Querier({ peerId: peerIds[0] })
Expand Down
6 changes: 3 additions & 3 deletions test/compat/responder.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict'

const { expect } = require('aegir/utils/chai')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const PeerId = require('peer-id')
const MDNS = require('multicast-dns')
const delay = require('delay')
Expand All @@ -14,8 +14,8 @@ const { SERVICE_TAG_LOCAL, MULTICAST_IP, MULTICAST_PORT } = require('../../src/c
describe('Responder', () => {
let responder, mdns
const peerAddrs = [
multiaddr('/ip4/127.0.0.1/tcp/20001'),
multiaddr('/ip4/127.0.0.1/tcp/20002')
new Multiaddr('/ip4/127.0.0.1/tcp/20001'),
new Multiaddr('/ip4/127.0.0.1/tcp/20002')
]
let peerIds

Expand Down
17 changes: 14 additions & 3 deletions test/compliance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@

const tests = require('libp2p-interfaces/src/peer-discovery/tests')

const { Multiaddr } = require('multiaddr')
const PeerId = require('peer-id')
const MulticastDNS = require('../src')
let mdns

describe('compliance tests', () => {
let intervalId
tests({
async setup () {
const peerId = await PeerId.create()
const peerId1 = await PeerId.create()
const peerId2 = await PeerId.create()

mdns = new MulticastDNS({
peerId: peerId,
peerId: peerId1,
libp2p: {
multiaddrs: []
},
Expand All @@ -22,10 +26,17 @@ describe('compliance tests', () => {
compat: true
})

// Trigger discovery
const maStr = '/ip4/127.0.0.1/tcp/15555/ws/p2p-webrtc-star/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2d'
intervalId = setInterval(() => mdns._onPeer({
id: peerId2,
multiaddrs: [new Multiaddr(maStr)]
}), 1000)

return mdns
},
async teardown () {
// clearInterval(intervalId)
clearInterval(intervalId)
await new Promise(resolve => setTimeout(resolve, 10))
}
})
Expand Down
26 changes: 14 additions & 12 deletions test/multicast-dns.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict'

const { expect } = require('aegir/utils/chai')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const PeerId = require('peer-id')
const pWaitFor = require('p-wait-for')

Expand All @@ -25,25 +25,25 @@ describe('MulticastDNS', () => {
])

aMultiaddrs = [
multiaddr('/ip4/127.0.0.1/tcp/20001'),
multiaddr('/dns4/webrtc-star.discovery.libp2p.io/tcp/443/wss/p2p-webrtc-star'),
multiaddr('/dns4/discovery.libp2p.io/tcp/8443')
new Multiaddr('/ip4/127.0.0.1/tcp/20001'),
new Multiaddr('/dns4/webrtc-star.discovery.libp2p.io/tcp/443/wss/p2p-webrtc-star'),
new Multiaddr('/dns4/discovery.libp2p.io/tcp/8443')
]

bMultiaddrs = [
multiaddr('/ip4/127.0.0.1/tcp/20002'),
multiaddr('/ip6/::1/tcp/20002'),
multiaddr('/dnsaddr/discovery.libp2p.io')
new Multiaddr('/ip4/127.0.0.1/tcp/20002'),
new Multiaddr('/ip6/::1/tcp/20002'),
new Multiaddr('/dnsaddr/discovery.libp2p.io')
]

cMultiaddrs = [
multiaddr('/ip4/127.0.0.1/tcp/20003'),
multiaddr('/ip4/127.0.0.1/tcp/30003/ws'),
multiaddr('/dns4/discovery.libp2p.io')
new Multiaddr('/ip4/127.0.0.1/tcp/20003'),
new Multiaddr('/ip4/127.0.0.1/tcp/30003/ws'),
new Multiaddr('/dns4/discovery.libp2p.io')
]

dMultiaddrs = [
multiaddr('/ip4/127.0.0.1/tcp/30003/ws')
new Multiaddr('/ip4/127.0.0.1/tcp/30003/ws')
]
})

Expand Down Expand Up @@ -220,7 +220,7 @@ describe('MulticastDNS', () => {
})
await mdns.start()

return new Promise((resolve, reject) => {
await new Promise((resolve, reject) => {
mdns.on('peer', (peerData) => {
if (!peerData) {
reject(new Error('peerData was not set'))
Expand All @@ -245,5 +245,7 @@ describe('MulticastDNS', () => {
}]
})
})

await mdns.stop()
})
})

0 comments on commit b8c7bf3

Please sign in to comment.