From cad173e3bdb7c0f57f68d89a237e37fe0b988044 Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 3 Sep 2017 14:39:55 +0100 Subject: [PATCH] feat: p2p addrs situation (#119) * chore: update gitignore and CI * chore: update deps * test: update tests to use p2p-webrtc-star --- .gitignore | 26 ++++++++------- .travis.yml | 14 ++++---- README.md | 2 +- package.json | 32 +++++++++---------- test/browser-bundle/webrtc-star-only.js | 8 ++--- test/nodejs-bundle/discovery.js | 4 +-- .../tcp+websockets+webrtc-star.js | 4 +-- 7 files changed, 46 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 310423768b..e4c5b0e314 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,13 @@ -**/package-lock.json -**/node_modules +**/node_modules/ +**/*.log +test/repo-tests* +**/bundle.js # Logs logs *.log -npm-debug.log* + +coverage # Runtime data pids @@ -23,16 +26,17 @@ coverage # node-waf configuration .lock-wscript -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release +build # Dependency directory +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git node_modules -# Optional npm cache directory -.npm - -# Optional REPL history -.node_repl_history - +lib dist +test/test-data/go-ipfs-repo/LOCK +test/test-data/go-ipfs-repo/LOG +test/test-data/go-ipfs-repo/LOG.old + +# while testing npm5 +package-lock.json diff --git a/.travis.yml b/.travis.yml index 2f70adb29b..584f308f81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,20 @@ sudo: false language: node_js + matrix: include: - - node_js: 4 - env: CXX=g++-4.8 - node_js: 6 env: CXX=g++-4.8 - - node_js: stable + - node_js: 8 env: CXX=g++-4.8 - -# Make sure we have new NPM. -before_install: - - npm install -g npm@4 + # - node_js: stable + # env: CXX=g++-4.8 script: - npm run lint - - npm test + - npm run test - npm run coverage + - make test before_script: - export DISPLAY=:99.0 diff --git a/README.md b/README.md index 00c62934f2..0baea3b5be 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ - +

diff --git a/package.json b/package.json index 01af41fa1c..c80bc4f0d6 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "IPFS" ], "engines": { - "node": ">=4.0.0", + "node": ">=6.0.0", "npm": ">=3.0.0" }, "pre-commit": [ @@ -38,27 +38,27 @@ "homepage": "https://github.com/libp2p/js-libp2p", "dependencies": { "async": "^2.5.0", - "libp2p-ping": "~0.5.0", - "libp2p-swarm": "~0.31.0", - "mafmt": "^2.1.8", - "multiaddr": "^2.3.0", + "libp2p-ping": "~0.6.0", + "libp2p-swarm": "~0.32.0", + "mafmt": "^3.0.0", + "multiaddr": "^3.0.0", "peer-book": "~0.5.0", - "peer-id": "~0.9.0", - "peer-info": "~0.10.0" + "peer-id": "~0.10.0", + "peer-info": "~0.11.0" }, "devDependencies": { "aegir": "^11.0.2", - "chai": "^4.1.1", + "chai": "^4.1.2", "dirty-chai": "^2.0.1", "cids": "~0.5.1", - "libp2p-kad-dht": "~0.4.1", - "libp2p-mdns": "~0.8.0", - "libp2p-multiplex": "~0.4.4", - "libp2p-railing": "~0.6.1", - "libp2p-secio": "~0.7.1", - "libp2p-spdy": "~0.10.6", - "libp2p-tcp": "~0.10.2", - "libp2p-webrtc-star": "~0.12.0", + "libp2p-kad-dht": "~0.5.0", + "libp2p-mdns": "~0.9.0", + "libp2p-multiplex": "~0.5.0", + "libp2p-railing": "~0.7.0", + "libp2p-secio": "~0.8.0", + "libp2p-spdy": "~0.11.0", + "libp2p-tcp": "~0.11.0", + "libp2p-webrtc-star": "~0.13.0", "libp2p-websockets": "~0.10.1", "lodash.times": "^4.3.2", "pre-commit": "^1.2.2", diff --git a/test/browser-bundle/webrtc-star-only.js b/test/browser-bundle/webrtc-star-only.js index 6fbe112f84..6697507f03 100644 --- a/test/browser-bundle/webrtc-star-only.js +++ b/test/browser-bundle/webrtc-star-only.js @@ -25,11 +25,11 @@ describe('libp2p-ipfs-browser (webrtc only)', () => { expect(err).to.not.exist() peer1 = new PeerInfo(ids[0]) - const ma1 = '/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/' + ids[0].toB58String() + const ma1 = '/ip4/127.0.0.1/tcp/15555/ws/p2p-webrtc-star/ipfs/' + ids[0].toB58String() peer1.multiaddrs.add(ma1) peer2 = new PeerInfo(ids[1]) - const ma2 = '/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/' + ids[1].toB58String() + const ma2 = '/ip4/127.0.0.1/tcp/15555/ws/p2p-webrtc-star/ipfs/' + ids[1].toB58String() peer2.multiaddrs.add(ma2) done() @@ -67,7 +67,7 @@ describe('libp2p-ipfs-browser (webrtc only)', () => { expect(Object.keys(peers2)).to.have.length(1) pull( - pull.values([Buffer(text)]), + pull.values([Buffer.from(text)]), conn, pull.collect((err, data) => { expect(err).to.not.exist() @@ -108,7 +108,7 @@ describe('libp2p-ipfs-browser (webrtc only)', () => { expect(err).to.not.exist() const peer3 = new PeerInfo(id3) - const ma3 = '/libp2p-webrtc-star/ip4/127.0.0.1/tcp/15555/ws/ipfs/' + id3.toB58String() + const ma3 = '/ip4/127.0.0.1/tcp/15555/ws/p2p-webrtc-star/ipfs/' + id3.toB58String() peer3.multiaddrs.add(ma3) node1.on('peer:discovery', (peerInfo) => node1.dial(peerInfo, check)) diff --git a/test/nodejs-bundle/discovery.js b/test/nodejs-bundle/discovery.js index 4cdab4560c..0e3dc83c09 100644 --- a/test/nodejs-bundle/discovery.js +++ b/test/nodejs-bundle/discovery.js @@ -29,7 +29,7 @@ describe('discovery', () => { }, (cb) => createNode([ '/ip4/0.0.0.0/tcp/0', - `/libp2p-webrtc-star/ip4/127.0.0.1/tcp/${port}/ws` + `/ip4/127.0.0.1/tcp/${port}/ws/p2p-webrtc-star` ], options, (err, node) => { expect(err).to.not.exist() nodeA = node @@ -38,7 +38,7 @@ describe('discovery', () => { }), (cb) => createNode([ '/ip4/0.0.0.0/tcp/0', - `/libp2p-webrtc-star/ip4/127.0.0.1/tcp/${port}/ws` + `/ip4/127.0.0.1/tcp/${port}/ws/p2p-webrtc-star` ], options, (err, node) => { expect(err).to.not.exist() nodeB = node diff --git a/test/nodejs-bundle/tcp+websockets+webrtc-star.js b/test/nodejs-bundle/tcp+websockets+webrtc-star.js index a7992f3861..8d5939e28f 100644 --- a/test/nodejs-bundle/tcp+websockets+webrtc-star.js +++ b/test/nodejs-bundle/tcp+websockets+webrtc-star.js @@ -34,7 +34,7 @@ describe('TCP + WebSockets + WebRTCStar', () => { createNode([ '/ip4/0.0.0.0/tcp/0', '/ip4/127.0.0.1/tcp/25011/ws', - '/libp2p-webrtc-star/ip4/127.0.0.1/tcp/24642/ws' + '/ip4/127.0.0.1/tcp/24642/ws/p2p-webrtc-star' ], { modules: { transport: [wstar], @@ -68,7 +68,7 @@ describe('TCP + WebSockets + WebRTCStar', () => { const wstar = new WStar({wrtc: wrtc}) createNode([ - '/libp2p-webrtc-star/ip4/127.0.0.1/tcp/24642/ws' + '/ip4/127.0.0.1/tcp/24642/ws/p2p-webrtc-star' ], { modules: { transport: [wstar],