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

chore: update deps #116

Merged
merged 2 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

const WebRTCDirect = require('./src')
const pipe = require('it-pipe')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')

const ma = multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
let listener

const mockUpgrader = {
upgradeInbound: maConn => maConn,
upgradeOutbound: maConn => maConn
}

function boot () {
function before () {
const wd = new WebRTCDirect({ upgrader: mockUpgrader })

listener = wd.createListener((conn) => pipe(conn, conn))
Expand All @@ -23,7 +23,7 @@ function boot () {
return listener.listen(ma)
}

async function shutdown () {
async function after () {
await listener.close()
// TODO: Temporary fix per wrtc issue
// https://github.com/node-webrtc/node-webrtc/issues/636
Expand All @@ -32,7 +32,7 @@ async function shutdown () {

module.exports = {
hooks: {
pre: boot,
post: shutdown
pre: before,
post: after
}
}
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
"release-major": "aegir release --type major --target node --target browser",
"coverage": "nyc --reporter=text --reporter=lcov npm run test:node"
},
"pre-push": [
"lint"
],
"repository": {
"type": "git",
"url": "git+https://github.com/libp2p/js-libp2p-webrtc-direct.git"
Expand All @@ -43,15 +40,14 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-webrtc-direct#readme",
"engines": {
"node": ">=12.0.0",
"npm": ">=6.0.0"
"node": ">=14.0.0"
},
"devDependencies": {
"aegir": "^30.3.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updating to aegir 31+ causes a segmentation fault running the tests. I think this is related to wrtc, but I will create an issue and investigate this separately to avoid blocking the dependencies updates in the bundle

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried updating the test command when upgrading aegir?

npx nyc -s npm run test:node -- --bail

to

npx ageir test -t node --cov --bail

I saw something similar in ipld/js-ipld-ethereum#71 (comment) and this fixed it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this does also happens to me locally not running nyc. Anyway, just tried locally with a single test case:

➜  js-libp2p-webrtc-direct git:(chore/update-deps-12-04-2021) ✗ npx aegir test -t node
Test Node.js
listener started on: /ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct


  dial
    ✓ dial on IPv4 (6109ms)


  1 passing (6s)

Command was killed with SIGSEGV (Segmentation fault): mocha test/node.{js,ts} test/**/*.spec.{js,ts} --ui bdd --timeout=5000

"chai": "^4.2.0",
"chai": "^4.3.4",
"dirty-chai": "^2.0.1",
"it-pipe": "^1.1.0",
"multiaddr": "^8.1.1",
"multiaddr": "^9.0.1",
"streaming-iterables": "^5.0.3",
"webrtcsupport": "^2.2.0"
},
Expand All @@ -63,10 +59,10 @@
"detect-node": "^2.0.4",
"err-code": "^3.0.0",
"libp2p-interfaces": "libp2p/js-interfaces#chore/skip-abort-while-reading-for-webrtc",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed before release

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an old thing that needs to be fixed. This comes from the async refactor: #30

I will create an issue so that we can triage it, but tldr there is a bug in this module when we abort while reading

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"libp2p-utils": "^0.2.3",
"libp2p-utils": "^0.3.0",
"libp2p-webrtc-peer": "^10.0.1",
"mafmt": "^8.0.1",
"multibase": "^3.1.0",
"mafmt": "^9.0.0",
"multibase": "^4.0.4",
"once": "^1.4.0",
"request": "^2.88.0",
"stream-to-it": "^0.2.2",
Expand Down
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const createListener = require('./listener')

function noop () {}

/**
* @typedef {import('multiaddr').Multiaddr} Multiaddr
*/

class WebRTCDirect {
/**
* @class
Expand Down
4 changes: 2 additions & 2 deletions src/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ module.exports = ({ handler, upgrader }, options = {}) => {
})
}

listener.close = () => {
listener.close = async () => {
if (!server.listening) {
return
}

await Promise.all(listener.__connections.map(c => c.close()))
return new Promise((resolve, reject) => {
listener.__connections.forEach(maConn => maConn.close())
server.close((err) => err ? reject(err) : resolve())
})
}
Expand Down
10 changes: 5 additions & 5 deletions test/compliance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict'

const tests = require('libp2p-interfaces/src/transport/tests')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')

const WDirect = require('../src')

Expand All @@ -12,10 +12,10 @@ describe('interface-transport compliance', () => {
const ws = new WDirect({ upgrader })

const addrs = [
multiaddr('/ip4/127.0.0.1/tcp/22222/http/p2p-webrtc-direct'),
multiaddr('/ip4/127.0.0.1/tcp/33333/http/p2p-webrtc-direct'),
multiaddr('/ip4/127.0.0.1/tcp/44444/http/p2p-webrtc-direct'),
multiaddr('/ip4/127.0.0.1/tcp/55555/http/p2p-webrtc-direct')
new Multiaddr('/ip4/127.0.0.1/tcp/22222/http/p2p-webrtc-direct'),
new Multiaddr('/ip4/127.0.0.1/tcp/33333/http/p2p-webrtc-direct'),
new Multiaddr('/ip4/127.0.0.1/tcp/44444/http/p2p-webrtc-direct'),
new Multiaddr('/ip4/127.0.0.1/tcp/55555/http/p2p-webrtc-direct')
]

// Used by the dial tests to simulate a delayed connect
Expand Down
6 changes: 3 additions & 3 deletions test/dial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')

const pipe = require('it-pipe')
const { collect } = require('streaming-iterables')
Expand All @@ -23,7 +23,7 @@ const mockUpgrader = {
describe('dial', function () {
this.timeout(20 * 1000)

const ma = multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
let wd

before(() => {
Expand All @@ -44,7 +44,7 @@ describe('dial', function () {
})

it('dial offline / non-existent node on IPv4, check callback', async () => {
const maOffline = multiaddr('/ip4/127.0.0.1/tcp/55555/http/p2p-webrtc-direct')
const maOffline = new Multiaddr('/ip4/127.0.0.1/tcp/55555/http/p2p-webrtc-direct')

try {
await wd.dial(maOffline, { config: {} })
Expand Down
14 changes: 7 additions & 7 deletions test/filter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')

const WebRTCDirect = require('../src')

Expand All @@ -18,11 +18,11 @@ describe('filter', () => {
it('filters non valid webrtc-direct multiaddrs', () => {
const wd = new WebRTCDirect({ upgrader: mockUpgrader })
const maArr = [
multiaddr('/ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct'),
multiaddr('/ip4/127.0.0.1/tcp/9090/ws'),
multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-webrtc-direct/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2'),
multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'),
multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4' +
new Multiaddr('/ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct'),
new Multiaddr('/ip4/127.0.0.1/tcp/9090/ws'),
new Multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-webrtc-direct/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2'),
new Multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'),
new Multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4' +
'/p2p-circuit/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo5')
]

Expand All @@ -32,7 +32,7 @@ describe('filter', () => {

it('filter a single addr for this transport', () => {
const wd = new WebRTCDirect({ upgrader: mockUpgrader })
const ma = multiaddr('/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct')
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct')

const filtered = wd.filter(ma)
expect(filtered.length).to.equal(1)
Expand Down
8 changes: 4 additions & 4 deletions test/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const pipe = require('it-pipe')

const WebRTCDirect = require('../src')
Expand All @@ -20,7 +20,7 @@ const mockUpgrader = {
describe('listen', () => {
let wd

const ma = multiaddr('/ip4/127.0.0.1/tcp/20123/http/p2p-webrtc-direct')
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/20123/http/p2p-webrtc-direct')

before(() => {
wd = new WebRTCDirect({ upgrader: mockUpgrader })
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('listen', () => {
it('should untrack conn after being closed', async function () {
this.timeout(20e3)

const ma1 = multiaddr('/ip4/127.0.0.1/tcp/12346/http/p2p-webrtc-direct')
const ma1 = new Multiaddr('/ip4/127.0.0.1/tcp/12346/http/p2p-webrtc-direct')

const wd1 = new WebRTCDirect({ upgrader: mockUpgrader })
const listener1 = wd1.createListener((conn) => pipe(conn, conn))
Expand All @@ -104,7 +104,7 @@ describe('listen', () => {
it('should have remoteAddress in listener connection', async function () {
this.timeout(20e3)

const ma1 = multiaddr('/ip4/127.0.0.1/tcp/12346/http/p2p-webrtc-direct')
const ma1 = new Multiaddr('/ip4/127.0.0.1/tcp/12346/http/p2p-webrtc-direct')

const wd1 = new WebRTCDirect({ upgrader: mockUpgrader })
const listener1 = wd1.createListener((conn) => {
Expand Down