From 270603e9f2c53e2122c13d600564d32ad6b20451 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 27 May 2016 11:08:55 +0100 Subject: [PATCH] update deps --- .aegir.js | 20 ++++++++++++++++++ package.json | 30 ++++++++------------------- src/core/ipfs/id.js | 2 +- src/core/ipfs/init.js | 2 +- test/core/both/test-bitswap.js | 37 ++++++++++++++++++++++++++++++---- 5 files changed, 63 insertions(+), 28 deletions(-) create mode 100644 .aegir.js diff --git a/.aegir.js b/.aegir.js new file mode 100644 index 0000000000..0ca4c88827 --- /dev/null +++ b/.aegir.js @@ -0,0 +1,20 @@ +'use strict' + +const path = require('path') + +module.exports = { + webpack: { + resolve: { + alias: { + 'node-forge': path.resolve( + path.dirname(require.resolve('libp2p-crypto')), + '../vendor/forge.bundle.js' + ) + } + }, + externals: { + fs: '{}', + mkdirp: '{}' + } + } +} diff --git a/package.json b/package.json index 3194d7668f..82af884680 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "glob": "^7.0.3", "hapi": "^13.4.1", "ipfs-api": "^4.1.0", - "ipfs-bitswap": "^0.2.1", + "ipfs-bitswap": "^0.3.1", "ipfs-block": "^0.3.0", "ipfs-block-service": "^0.4.0", "ipfs-merkle-dag": "^0.6.0", @@ -73,16 +73,16 @@ "ipfs-repo": "^0.8.0", "ipfs-unixfs-engine": "^0.8.0", "joi": "^8.0.5", - "libp2p-ipfs": "^0.8.1", - "libp2p-ipfs-browser": "^0.7.0", - "libp2p-swarm": "^0.18.2", + "libp2p-ipfs": "^0.9.0", + "libp2p-ipfs-browser": "^0.8.0", + "libp2p-swarm": "^0.19.0", "lodash.get": "^4.3.0", "lodash.set": "^4.2.0", "multiaddr": "^2.0.2", "path-exists": "^3.0.0", - "peer-book": "^0.1.1", - "peer-id": "^0.6.7", - "peer-info": "^0.6.2", + "peer-book": "^0.3.0", + "peer-id": "^0.7.0", + "peer-info": "^0.7.0", "promisify-es6": "^1.0.1", "readable-stream": "1.1.13", "ronin": "^0.3.11", @@ -92,20 +92,6 @@ "run-waterfall": "^1.1.3", "temp": "^0.8.3" }, - "aegir": { - "webpack": { - "resolve": { - "alias": { - "node-forge": "../../../node_modules/peer-id/vendor/forge.bundle.js", - "libp2p-ipfs": "libp2p-ipfs-browser" - } - }, - "externals": { - "fs": "{}", - "mkdirp": "{}" - } - } - }, "contributors": [ "Andrew de Andrade ", "David Dias ", @@ -123,4 +109,4 @@ "kumavis ", "nginnever " ] -} \ No newline at end of file +} diff --git a/src/core/ipfs/id.js b/src/core/ipfs/id.js index d322b02d51..99d442cd92 100644 --- a/src/core/ipfs/id.js +++ b/src/core/ipfs/id.js @@ -15,7 +15,7 @@ module.exports = function id (self) { function ready () { callback(null, { ID: self._peerInfo.id.toB58String(), - PublicKey: self._peerInfo.id.pubKey.toString('base64'), + PublicKey: self._peerInfo.id.pubKey.bytes.toString('base64'), Addresses: self._peerInfo.multiaddrs.map((ma) => { return ma.toString() }).sort(), AgentVersion: 'js-ipfs', ProtocolVersion: '9000' diff --git a/src/core/ipfs/init.js b/src/core/ipfs/init.js index 66c4d470c6..71ef24a6f1 100644 --- a/src/core/ipfs/init.js +++ b/src/core/ipfs/init.js @@ -39,7 +39,7 @@ module.exports = function init (self) { }) config.Identity = { PeerID: keys.toB58String(), - PrivKey: keys.privKey.toString('base64') + PrivKey: keys.privKey.bytes.toString('base64') } writeVersion() diff --git a/test/core/both/test-bitswap.js b/test/core/both/test-bitswap.js index a104a0c3b3..4880c570ca 100644 --- a/test/core/both/test-bitswap.js +++ b/test/core/both/test-bitswap.js @@ -11,7 +11,7 @@ const bs58 = require('bs58') const bl = require('bl') const API = require('ipfs-api') const multiaddr = require('multiaddr') - +const isNode = require('detect-node') const IPFS = require('../../../src/core') function makeBlock () { @@ -20,10 +20,31 @@ function makeBlock () { describe('bitswap', () => { let ipfs + let configBak beforeEach((done) => { ipfs = new IPFS(require('../../utils/repo-path')) - ipfs.load(done) + if (!isNode) { + ipfs.config.show((err, config) => { + configBak = JSON.parse(JSON.stringify(config)) + expect(err).to.not.exist + config.Addresses.Swarm = [] + ipfs.config.replace(config, (err) => { + expect(err).to.not.exist + ipfs.load(done) + }) + }) + } else { + ipfs.load(done) + } + }) + + afterEach((done) => { + if (!isNode) { + ipfs.config.replace(configBak, done) + } else { + done() + } }) describe('connections', () => { @@ -36,9 +57,17 @@ describe('bitswap', () => { return _.includes(addr.protoNames(), 'ws') })[0] - let target = addr.encapsulate(multiaddr(`/ipfs/${res.ID}`)).toString() + let target + if (addr) { + target = addr.encapsulate(multiaddr(`/ipfs/${res.ID}`)).toString() + target = target.replace('0.0.0.0', '127.0.0.1') + } else { + // cause browser nodes don't have a websockets addrs + // TODO, what we really need is a way to dial to a peerId only + // and another to dial to peerInfo + target = multiaddr(`/ip4/0.0.0.0/tcp/0/ipfs/${res.ID}`).toString() + } - target = target.replace('0.0.0.0', '127.0.0.1') const swarm = node2.libp2p ? node2.libp2p.swarm : node2.swarm swarm.connect(target, done) })