chore: update deps

This commit is contained in:
Vasco Santos
2021-04-09 10:19:09 +02:00
parent d39ad01e96
commit 578276bd40
8 changed files with 67 additions and 52 deletions

View File

@ -3,7 +3,7 @@
const sinon = require('sinon')
const tests = require('libp2p-interfaces/src/transport/tests')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const net = require('net')
const TCP = require('../src')
@ -12,9 +12,9 @@ describe('interface-transport compliance', () => {
setup ({ upgrader }) {
const tcp = new TCP({ upgrader })
const addrs = [
multiaddr('/ip4/127.0.0.1/tcp/9091'),
multiaddr('/ip4/127.0.0.1/tcp/9092'),
multiaddr('/ip4/127.0.0.1/tcp/9093')
new Multiaddr('/ip4/127.0.0.1/tcp/9091'),
new Multiaddr('/ip4/127.0.0.1/tcp/9092'),
new Multiaddr('/ip4/127.0.0.1/tcp/9093')
]
// Used by the dial tests to simulate a delayed connect

View File

@ -3,7 +3,7 @@
const { expect } = require('aegir/utils/chai')
const TCP = require('../src')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
describe('valid localAddr and remoteAddr', () => {
let tcp
@ -17,7 +17,7 @@ describe('valid localAddr and remoteAddr', () => {
tcp = new TCP({ upgrader: mockUpgrader })
})
const ma = multiaddr('/ip4/127.0.0.1/tcp/0')
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/0')
it('should resolve port 0', async () => {
// Create a Promise that resolves when a connection is handled
@ -73,7 +73,7 @@ describe('valid localAddr and remoteAddr', () => {
// Wait for the incoming dial to be handled
await handlerPromise
// Close the listener with two simultaneous calls to `close`
// Close the dialer with two simultaneous calls to `close`
await Promise.race([
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Timed out waiting for connection close')), 500)),
await Promise.all([
@ -81,5 +81,7 @@ describe('valid localAddr and remoteAddr', () => {
dialerConn.close()
])
])
await listener.close()
})
})

View File

@ -3,7 +3,7 @@
const { expect } = require('aegir/utils/chai')
const TCP = require('../src')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
describe('filter addrs', () => {
const base = '/ip4/127.0.0.1'
@ -16,14 +16,14 @@ describe('filter addrs', () => {
})
it('filter valid addrs for this transport', () => {
const ma1 = multiaddr(base + '/tcp/9090')
const ma2 = multiaddr(base + '/udp/9090')
const ma3 = multiaddr(base + '/tcp/9090/http')
const ma4 = multiaddr(base + '/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const ma5 = multiaddr(base + '/tcp/9090/http' + ipfs)
const ma6 = multiaddr('/ip4/127.0.0.1/tcp/9090/p2p-circuit' + ipfs)
const ma7 = multiaddr('/dns4/libp2p.io/tcp/9090')
const ma8 = multiaddr('/dnsaddr/libp2p.io/tcp/9090')
const ma1 = new Multiaddr(base + '/tcp/9090')
const ma2 = new Multiaddr(base + '/udp/9090')
const ma3 = new Multiaddr(base + '/tcp/9090/http')
const ma4 = new Multiaddr(base + '/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const ma5 = new Multiaddr(base + '/tcp/9090/http' + ipfs)
const ma6 = new Multiaddr('/ip4/127.0.0.1/tcp/9090/p2p-circuit' + ipfs)
const ma7 = new Multiaddr('/dns4/libp2p.io/tcp/9090')
const ma8 = new Multiaddr('/dnsaddr/libp2p.io/tcp/9090')
const valid = tcp.filter([ma1, ma2, ma3, ma4, ma5, ma6, ma7, ma8])
expect(valid.length).to.equal(4)
@ -32,7 +32,7 @@ describe('filter addrs', () => {
})
it('filter a single addr for this transport', () => {
const ma1 = multiaddr(base + '/tcp/9090')
const ma1 = new Multiaddr(base + '/tcp/9090')
const valid = tcp.filter(ma1)
expect(valid.length).to.equal(1)

View File

@ -6,7 +6,7 @@ const TCP = require('../src')
const net = require('net')
const os = require('os')
const path = require('path')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const pipe = require('it-pipe')
const { collect, map } = require('streaming-iterables')
const isCI = process.env.CI
@ -37,7 +37,7 @@ describe('listen', () => {
})
it('close listener with connections, through timeout', async () => {
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const mh = new Multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
listener = tcp.createListener((conn) => {
pipe(conn, conn)
})
@ -62,14 +62,14 @@ describe('listen', () => {
// Windows doesn't support unix paths
skipOnWindows('listen on path', async () => {
const mh = multiaddr(`/unix${path.resolve(os.tmpdir(), '/tmp/p2pd.sock')}`)
const mh = new Multiaddr(`/unix${path.resolve(os.tmpdir(), '/tmp/p2pd.sock')}`)
listener = tcp.createListener((conn) => {})
await listener.listen(mh)
})
it('listen on port 0', async () => {
const mh = multiaddr('/ip4/127.0.0.1/tcp/0')
const mh = new Multiaddr('/ip4/127.0.0.1/tcp/0')
listener = tcp.createListener((conn) => {})
await listener.listen(mh)
})
@ -78,19 +78,19 @@ describe('listen', () => {
if (isCI) {
return
}
const mh = multiaddr('/ip6/::/tcp/9090')
const mh = new Multiaddr('/ip6/::/tcp/9090')
listener = tcp.createListener((conn) => {})
await listener.listen(mh)
})
it('listen on any Interface', async () => {
const mh = multiaddr('/ip4/0.0.0.0/tcp/9090')
const mh = new Multiaddr('/ip4/0.0.0.0/tcp/9090')
listener = tcp.createListener((conn) => {})
await listener.listen(mh)
})
it('getAddrs', async () => {
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090')
const mh = new Multiaddr('/ip4/127.0.0.1/tcp/9090')
listener = tcp.createListener((conn) => {})
await listener.listen(mh)
@ -100,7 +100,7 @@ describe('listen', () => {
})
it('getAddrs on port 0 listen', async () => {
const mh = multiaddr('/ip4/127.0.0.1/tcp/0')
const mh = new Multiaddr('/ip4/127.0.0.1/tcp/0')
listener = tcp.createListener((conn) => {})
await listener.listen(mh)
@ -109,7 +109,7 @@ describe('listen', () => {
})
it('getAddrs from listening on 0.0.0.0', async () => {
const mh = multiaddr('/ip4/0.0.0.0/tcp/9090')
const mh = new Multiaddr('/ip4/0.0.0.0/tcp/9090')
listener = tcp.createListener((conn) => {})
await listener.listen(mh)
@ -119,7 +119,7 @@ describe('listen', () => {
})
it('getAddrs from listening on 0.0.0.0 and port 0', async () => {
const mh = multiaddr('/ip4/0.0.0.0/tcp/0')
const mh = new Multiaddr('/ip4/0.0.0.0/tcp/0')
listener = tcp.createListener((conn) => {})
await listener.listen(mh)
@ -129,7 +129,7 @@ describe('listen', () => {
})
it('getAddrs preserves IPFS Id', async () => {
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const mh = new Multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
listener = tcp.createListener((conn) => {})
await listener.listen(mh)
@ -142,7 +142,7 @@ describe('listen', () => {
describe('dial', () => {
let tcp
let listener
const ma = multiaddr('/ip4/127.0.0.1/tcp/9090')
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/9090')
beforeEach(async () => {
tcp = new TCP({
@ -177,7 +177,7 @@ describe('dial', () => {
return
}
const ma = multiaddr('/ip6/::/tcp/9066')
const ma = new Multiaddr('/ip6/::/tcp/9066')
const listener = tcp.createListener((conn) => {
pipe(conn, conn)
})
@ -195,7 +195,7 @@ describe('dial', () => {
// Windows doesn't support unix paths
skipOnWindows('dial on path', async () => {
const ma = multiaddr(`/unix${path.resolve(os.tmpdir(), '/tmp/p2pd.sock')}`)
const ma = new Multiaddr(`/unix${path.resolve(os.tmpdir(), '/tmp/p2pd.sock')}`)
const listener = tcp.createListener((conn) => {
pipe(conn, conn)
@ -220,7 +220,7 @@ describe('dial', () => {
handled = resolve
})
const ma = multiaddr('/ip6/::/tcp/0')
const ma = new Multiaddr('/ip6/::/tcp/0')
const listener = tcp.createListener(async (conn) => {
await pipe(
@ -248,7 +248,7 @@ describe('dial', () => {
handled = resolve
})
const ma = multiaddr('/ip6/::/tcp/0')
const ma = new Multiaddr('/ip6/::/tcp/0')
const listener = tcp.createListener(async (conn) => {
// pull(conn, pull.onEnd(destroyed))
@ -265,7 +265,7 @@ describe('dial', () => {
})
it('dial on IPv4 with IPFS Id', async () => {
const ma = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
const conn = await tcp.dial(ma)
const res = await pipe(