mirror of
https://github.com/fluencelabs/js-libp2p-tcp
synced 2025-06-09 09:41:36 +00:00
chore: update deps and more non Travis ci
chore: improve test listener closures License: MIT Signed-off-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
commit
c7f695bf4b
52
.travis.yml
52
.travis.yml
@ -1,32 +1,28 @@
|
|||||||
# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
|
|
||||||
sudo: false
|
|
||||||
language: node_js
|
language: node_js
|
||||||
|
cache: npm
|
||||||
|
stages:
|
||||||
|
- check
|
||||||
|
- test
|
||||||
|
- cov
|
||||||
|
|
||||||
matrix:
|
node_js:
|
||||||
|
- '10'
|
||||||
|
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- osx
|
||||||
|
- windows
|
||||||
|
|
||||||
|
script: npx nyc -s npm run test:node
|
||||||
|
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
|
||||||
|
|
||||||
|
jobs:
|
||||||
include:
|
include:
|
||||||
- node_js: 6
|
- stage: check
|
||||||
env: CXX=g++-4.8
|
script:
|
||||||
- node_js: 8
|
- npx aegir commitlint --travis
|
||||||
env: CXX=g++-4.8
|
- npx aegir dep-check
|
||||||
# - node_js: stable
|
- npm run lint
|
||||||
# env: CXX=g++-4.8
|
|
||||||
|
|
||||||
script:
|
notifications:
|
||||||
- npm run lint
|
email: false
|
||||||
- npm run test
|
|
||||||
- npm run coverage
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- export DISPLAY=:99.0
|
|
||||||
- sh -e /etc/init.d/xvfb start
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- npm run coverage-publish
|
|
||||||
|
|
||||||
addons:
|
|
||||||
firefox: 'latest'
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- g++-4.8
|
|
||||||
|
13
README.md
13
README.md
@ -1,13 +1,14 @@
|
|||||||
# js-libp2p-tcp
|
# js-libp2p-tcp
|
||||||
|
|
||||||
[](http://ipn.io)
|
[](http://protocol.ai)
|
||||||
[](http://webchat.freenode.net/?channels=%23ipfs)
|
[](http://libp2p.io/)
|
||||||
[](https://travis-ci.org/libp2p/js-libp2p-tcp)
|
[](http://webchat.freenode.net/?channels=%23libp2p)
|
||||||
[](https://coveralls.io/github/libp2p/js-libp2p-tcp?branch=master)
|
[](https://codecov.io/gh/libp2p/js-libp2p-tcp)
|
||||||
|
[](https://travis-ci.com/libp2p/js-libp2p-tcp)
|
||||||
[](https://david-dm.org/libp2p/js-libp2p-tcp)
|
[](https://david-dm.org/libp2p/js-libp2p-tcp)
|
||||||
[](https://github.com/feross/standard)
|
[](https://github.com/feross/standard)
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
[](https://github.com/libp2p/interface-transport)
|
[](https://github.com/libp2p/interface-transport)
|
||||||
[](https://github.com/libp2p/interface-connection)
|
[](https://github.com/libp2p/interface-connection)
|
||||||
|
29
appveyor.yml
29
appveyor.yml
@ -1,29 +0,0 @@
|
|||||||
# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
|
|
||||||
version: "{build}"
|
|
||||||
|
|
||||||
environment:
|
|
||||||
matrix:
|
|
||||||
- nodejs_version: "6"
|
|
||||||
- nodejs_version: "8"
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
fast_finish: true
|
|
||||||
|
|
||||||
install:
|
|
||||||
# Install Node.js
|
|
||||||
- ps: Install-Product node $env:nodejs_version
|
|
||||||
|
|
||||||
# Upgrade npm
|
|
||||||
- npm install -g npm
|
|
||||||
|
|
||||||
# Output our current versions for debugging
|
|
||||||
- node --version
|
|
||||||
- npm --version
|
|
||||||
|
|
||||||
# Install our package dependencies
|
|
||||||
- npm install
|
|
||||||
|
|
||||||
test_script:
|
|
||||||
- npm run test:node
|
|
||||||
|
|
||||||
build: off
|
|
2
ci/Jenkinsfile
vendored
2
ci/Jenkinsfile
vendored
@ -1,2 +0,0 @@
|
|||||||
// Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
|
|
||||||
javascript()
|
|
15
circle.yml
15
circle.yml
@ -1,15 +0,0 @@
|
|||||||
# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
|
|
||||||
machine:
|
|
||||||
node:
|
|
||||||
version: stable
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
pre:
|
|
||||||
- google-chrome --version
|
|
||||||
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
||||||
- sudo dpkg -i google-chrome.deb || true
|
|
||||||
- sudo apt-get update
|
|
||||||
- sudo apt-get install -f
|
|
||||||
- sudo apt-get install --only-upgrade lsb-base
|
|
||||||
- sudo dpkg -i google-chrome.deb
|
|
||||||
- google-chrome --version
|
|
16
package.json
16
package.json
@ -4,6 +4,10 @@
|
|||||||
"description": "Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces",
|
"description": "Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces",
|
||||||
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"src"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "aegir lint",
|
"lint": "aegir lint",
|
||||||
"test": "aegir test -t node -f test/**/*.js",
|
"test": "aegir test -t node -f test/**/*.js",
|
||||||
@ -35,19 +39,19 @@
|
|||||||
"npm": ">=3.0.0"
|
"npm": ">=3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"aegir": "^17.0.1",
|
"aegir": "^18.2.0",
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"interface-transport": "~0.3.6",
|
"interface-transport": "~0.3.7",
|
||||||
"pull-stream": "^3.6.9"
|
"pull-stream": "^3.6.9"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"class-is": "^1.1.0",
|
"class-is": "^1.1.0",
|
||||||
"debug": "^4.1.0",
|
"debug": "^4.1.1",
|
||||||
"interface-connection": "~0.3.2",
|
"interface-connection": "~0.3.3",
|
||||||
"ip-address": "^5.8.9",
|
"ip-address": "^5.8.9",
|
||||||
"mafmt": "^6.0.2",
|
"mafmt": "^6.0.6",
|
||||||
"multiaddr": "^5.0.2",
|
"multiaddr": "^6.0.5",
|
||||||
"once": "^1.4.0",
|
"once": "^1.4.0",
|
||||||
"stream-to-pull-stream": "^1.7.2"
|
"stream-to-pull-stream": "^1.7.2"
|
||||||
},
|
},
|
||||||
|
@ -14,14 +14,19 @@ const isCI = process.env.CI
|
|||||||
|
|
||||||
describe('listen', () => {
|
describe('listen', () => {
|
||||||
let tcp
|
let tcp
|
||||||
|
let listener
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
tcp = new TCP()
|
tcp = new TCP()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
afterEach((done) => {
|
||||||
|
listener ? listener.close(done) : done()
|
||||||
|
})
|
||||||
|
|
||||||
it('close listener with connections, through timeout', (done) => {
|
it('close listener with connections, through timeout', (done) => {
|
||||||
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
|
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
|
||||||
const listener = tcp.createListener((conn) => {
|
listener = tcp.createListener((conn) => {
|
||||||
pull(conn, conn)
|
pull(conn, conn)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -33,78 +38,70 @@ describe('listen', () => {
|
|||||||
socket1.end()
|
socket1.end()
|
||||||
socket1.on('error', () => {})
|
socket1.on('error', () => {})
|
||||||
socket2.on('error', () => {})
|
socket2.on('error', () => {})
|
||||||
socket1.on('connect', () => {
|
socket1.on('connect', done)
|
||||||
listener.close(done)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('listen on port 0', (done) => {
|
it('listen on port 0', (done) => {
|
||||||
const mh = multiaddr('/ip4/127.0.0.1/tcp/0')
|
const mh = multiaddr('/ip4/127.0.0.1/tcp/0')
|
||||||
const listener = tcp.createListener((conn) => {})
|
listener = tcp.createListener((conn) => {})
|
||||||
listener.listen(mh, () => {
|
listener.listen(mh, done)
|
||||||
listener.close(done)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('listen on IPv6 addr', (done) => {
|
it('listen on IPv6 addr', (done) => {
|
||||||
if (isCI) { return done() }
|
if (isCI) { return done() }
|
||||||
const mh = multiaddr('/ip6/::/tcp/9090')
|
const mh = multiaddr('/ip6/::/tcp/9090')
|
||||||
const listener = tcp.createListener((conn) => {})
|
listener = tcp.createListener((conn) => {})
|
||||||
listener.listen(mh, () => {
|
listener.listen(mh, done)
|
||||||
listener.close(done)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('listen on any Interface', (done) => {
|
it('listen on any Interface', (done) => {
|
||||||
const mh = multiaddr('/ip4/0.0.0.0/tcp/9090')
|
const mh = multiaddr('/ip4/0.0.0.0/tcp/9090')
|
||||||
const listener = tcp.createListener((conn) => {})
|
listener = tcp.createListener((conn) => {})
|
||||||
listener.listen(mh, () => {
|
listener.listen(mh, done)
|
||||||
listener.close(done)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getAddrs', (done) => {
|
it('getAddrs', (done) => {
|
||||||
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090')
|
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090')
|
||||||
const listener = tcp.createListener((conn) => {})
|
listener = tcp.createListener((conn) => {})
|
||||||
listener.listen(mh, () => {
|
listener.listen(mh, () => {
|
||||||
listener.getAddrs((err, multiaddrs) => {
|
listener.getAddrs((err, multiaddrs) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
expect(multiaddrs.length).to.equal(1)
|
expect(multiaddrs.length).to.equal(1)
|
||||||
expect(multiaddrs[0]).to.deep.equal(mh)
|
expect(multiaddrs[0]).to.deep.equal(mh)
|
||||||
listener.close(done)
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getAddrs on port 0 listen', (done) => {
|
it('getAddrs on port 0 listen', (done) => {
|
||||||
const mh = multiaddr('/ip4/127.0.0.1/tcp/0')
|
const mh = multiaddr('/ip4/127.0.0.1/tcp/0')
|
||||||
const listener = tcp.createListener((conn) => {})
|
listener = tcp.createListener((conn) => {})
|
||||||
listener.listen(mh, () => {
|
listener.listen(mh, () => {
|
||||||
listener.getAddrs((err, multiaddrs) => {
|
listener.getAddrs((err, multiaddrs) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
expect(multiaddrs.length).to.equal(1)
|
expect(multiaddrs.length).to.equal(1)
|
||||||
listener.close(done)
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getAddrs from listening on 0.0.0.0', (done) => {
|
it('getAddrs from listening on 0.0.0.0', (done) => {
|
||||||
const mh = multiaddr('/ip4/0.0.0.0/tcp/9090')
|
const mh = multiaddr('/ip4/0.0.0.0/tcp/9090')
|
||||||
const listener = tcp.createListener((conn) => {})
|
listener = tcp.createListener((conn) => {})
|
||||||
listener.listen(mh, () => {
|
listener.listen(mh, () => {
|
||||||
listener.getAddrs((err, multiaddrs) => {
|
listener.getAddrs((err, multiaddrs) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
expect(multiaddrs.length > 0).to.equal(true)
|
expect(multiaddrs.length > 0).to.equal(true)
|
||||||
expect(multiaddrs[0].toString().indexOf('0.0.0.0')).to.equal(-1)
|
expect(multiaddrs[0].toString().indexOf('0.0.0.0')).to.equal(-1)
|
||||||
listener.close(done)
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getAddrs from listening on 0.0.0.0 and port 0', (done) => {
|
it('getAddrs from listening on 0.0.0.0 and port 0', (done) => {
|
||||||
const mh = multiaddr('/ip4/0.0.0.0/tcp/0')
|
const mh = multiaddr('/ip4/0.0.0.0/tcp/0')
|
||||||
const listener = tcp.createListener((conn) => {})
|
listener = tcp.createListener((conn) => {})
|
||||||
listener.listen(mh, () => {
|
listener.listen(mh, () => {
|
||||||
listener.getAddrs((err, multiaddrs) => {
|
listener.getAddrs((err, multiaddrs) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
@ -112,14 +109,14 @@ describe('listen', () => {
|
|||||||
multiaddrs.forEach((m) => {
|
multiaddrs.forEach((m) => {
|
||||||
expect(m.toOptions().host).to.not.eql('0.0.0.0')
|
expect(m.toOptions().host).to.not.eql('0.0.0.0')
|
||||||
})
|
})
|
||||||
listener.close(done)
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getAddrs from listening on ip6 \'::\'', (done) => {
|
it('getAddrs from listening on ip6 \'::\'', (done) => {
|
||||||
const mh = multiaddr('/ip6/::/tcp/9090')
|
const mh = multiaddr('/ip6/::/tcp/9090')
|
||||||
const listener = tcp.createListener((conn) => {})
|
listener = tcp.createListener((conn) => {})
|
||||||
listener.listen(mh, () => {
|
listener.listen(mh, () => {
|
||||||
listener.getAddrs((err, multiaddrs) => {
|
listener.getAddrs((err, multiaddrs) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
@ -127,20 +124,20 @@ describe('listen', () => {
|
|||||||
multiaddrs.forEach((m) => {
|
multiaddrs.forEach((m) => {
|
||||||
expect(m.toOptions().host).to.not.eql('::')
|
expect(m.toOptions().host).to.not.eql('::')
|
||||||
})
|
})
|
||||||
listener.close(done)
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getAddrs preserves IPFS Id', (done) => {
|
it('getAddrs preserves IPFS Id', (done) => {
|
||||||
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
|
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
|
||||||
const listener = tcp.createListener((conn) => {})
|
listener = tcp.createListener((conn) => {})
|
||||||
listener.listen(mh, () => {
|
listener.listen(mh, () => {
|
||||||
listener.getAddrs((err, multiaddrs) => {
|
listener.getAddrs((err, multiaddrs) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
expect(multiaddrs.length).to.equal(1)
|
expect(multiaddrs.length).to.equal(1)
|
||||||
expect(multiaddrs[0]).to.deep.equal(mh)
|
expect(multiaddrs[0]).to.deep.equal(mh)
|
||||||
listener.close(done)
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user