diff --git a/package.json b/package.json index af81f8f39d..439ece79b9 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,13 @@ "description": "A test suite and interface you can use to implement a IPFS core interface.", "main": "src/index.js", "scripts": { - "test": "exit(0)", - "lint": "aegir-lint", - "release": "aegir-release node", - "release-minor": "aegir-release node --type minor", - "release-major": "aegir-release node --type major", - "coverage": "exit(0)", - "coverage-publish": "exit(0)" + "test": "exit 0", + "lint": "aegir lint", + "release": "aegir release node", + "release-minor": "aegir release node --type minor", + "release-major": "aegir release node --type major", + "coverage": "exit 0", + "coverage-publish": "exit 0" }, "repository": { "type": "git", @@ -40,8 +40,7 @@ "multihashes": "^0.4.8", "multihashing-async": "^0.4.6", "peer-id": "^0.9.0", - "pull-stream": "^3.6.0", - "safe-buffer": "^5.1.1" + "pull-stream": "^3.6.0" }, "devDependencies": { "aegir": "^12.0.0", @@ -63,4 +62,4 @@ "haad ", "nginnever " ] -} \ No newline at end of file +} diff --git a/src/config.js b/src/config.js index 9ed692a46b..885c48559e 100644 --- a/src/config.js +++ b/src/config.js @@ -104,14 +104,14 @@ module.exports = (common) => { }) it('fail on non valid key', (done) => { - ipfs.config.set(new Buffer('heeey'), '', (err) => { + ipfs.config.set(Buffer.from('heeey'), '', (err) => { expect(err).to.exist() done() }) }) it('fail on non valid value', (done) => { - ipfs.config.set('Fruit', new Buffer('abc'), (err) => { + ipfs.config.set('Fruit', Buffer.from('abc'), (err) => { expect(err).to.exist() done() }) diff --git a/src/dag.js b/src/dag.js index a75998ab60..32b597b5af 100644 --- a/src/dag.js +++ b/src/dag.js @@ -39,7 +39,7 @@ module.exports = (common) => { let cborNode before((done) => { - const someData = new Buffer('some data') + const someData = Buffer.from('some data') pbNode = DAGNode.create(someData, (err, node) => { expect(err).to.not.exist() @@ -134,7 +134,7 @@ module.exports = (common) => { before((done) => { series([ (cb) => { - const someData = new Buffer('some other data') + const someData = Buffer.from('some other data') pbNode = DAGNode.create(someData, (err, node) => { expect(err).to.not.exist() @@ -147,7 +147,7 @@ module.exports = (common) => { } }, (cb) => { - dagPB.DAGNode.create(new Buffer('I am inside a Protobuf'), (err, node) => { + dagPB.DAGNode.create(Buffer.from('I am inside a Protobuf'), (err, node) => { expect(err).to.not.exist() nodePb = node cb() @@ -240,7 +240,7 @@ module.exports = (common) => { it('dag-pb local scope', (done) => { ipfs.dag.get(cidPb, 'Data', (err, result) => { expect(err).to.not.exist() - expect(result.value).to.eql(new Buffer('I am inside a Protobuf')) + expect(result.value).to.eql(Buffer.from('I am inside a Protobuf')) done() }) }) @@ -277,7 +277,7 @@ module.exports = (common) => { it('from dag-cbor to dag-pb', (done) => { ipfs.dag.get(cidCbor, 'pb/Data', (err, result) => { expect(err).to.not.exist() - expect(result.value).to.eql(new Buffer('I am inside a Protobuf')) + expect(result.value).to.eql(Buffer.from('I am inside a Protobuf')) done() }) }) @@ -303,7 +303,7 @@ module.exports = (common) => { ipfs.dag.get(cidCborStr + '/pb/Data', (err, result) => { expect(err).to.not.exist() - expect(result.value).to.eql(new Buffer('I am inside a Protobuf')) + expect(result.value).to.eql(Buffer.from('I am inside a Protobuf')) done() }) }) @@ -319,7 +319,7 @@ module.exports = (common) => { before((done) => { series([ (cb) => { - dagPB.DAGNode.create(new Buffer('I am inside a Protobuf'), (err, node) => { + dagPB.DAGNode.create(Buffer.from('I am inside a Protobuf'), (err, node) => { expect(err).to.not.exist() nodePb = node cb() diff --git a/src/object.js b/src/object.js index d20619c8e5..01de1a4d14 100644 --- a/src/object.js +++ b/src/object.js @@ -59,7 +59,7 @@ module.exports = (common) => { describe('.put', () => { it('of object', (done) => { const obj = { - Data: new Buffer('Some data'), + Data: Buffer.from('Some data'), Links: [] } @@ -75,7 +75,7 @@ module.exports = (common) => { it('of json encoded buffer', (done) => { const obj = { - Data: new Buffer('Some data'), + Data: Buffer.from('Some data'), Links: [] } @@ -84,7 +84,7 @@ module.exports = (common) => { Links: obj.Links } - const buf = new Buffer(JSON.stringify(obj2)) + const buf = Buffer.from(JSON.stringify(obj2)) ipfs.object.put(buf, { enc: 'json' }, (err, node) => { expect(err).to.not.exist() @@ -102,7 +102,7 @@ module.exports = (common) => { series([ (cb) => { - DAGNode.create(new Buffer('Some data'), (err, _node) => { + DAGNode.create(Buffer.from('Some data'), (err, _node) => { expect(err).to.not.exist() node = _node cb() @@ -128,7 +128,7 @@ module.exports = (common) => { }) it('of buffer treated as Data field', (done) => { - const data = new Buffer('Some data') + const data = Buffer.from('Some data') ipfs.object.put(data, (err, node) => { expect(err).to.not.exist() const nodeJSON = node.toJSON() @@ -140,7 +140,7 @@ module.exports = (common) => { }) it('of DAGNode', (done) => { - DAGNode.create(new Buffer('Some data'), (err, dNode) => { + DAGNode.create(Buffer.from('Some data'), (err, dNode) => { expect(err).to.not.exist() ipfs.object.put(dNode, (err, node) => { expect(err).to.not.exist() @@ -164,14 +164,14 @@ module.exports = (common) => { let node2 series([ (cb) => { - DAGNode.create(new Buffer('Some data 1'), (err, node) => { + DAGNode.create(Buffer.from('Some data 1'), (err, node) => { expect(err).to.not.exist() node1a = node cb() }) }, (cb) => { - DAGNode.create(new Buffer('Some data 2'), (err, node) => { + DAGNode.create(Buffer.from('Some data 2'), (err, node) => { expect(err).to.not.exist() node2 = node cb() @@ -202,7 +202,7 @@ module.exports = (common) => { describe('.get', () => { it('with multihash', (done) => { const obj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -225,7 +225,7 @@ module.exports = (common) => { // because js-ipfs-api can't infer if the // returned Data is Buffer or String if (typeof node2.data === 'string') { - node2.data = new Buffer(node2.data) + node2.data = Buffer.from(node2.data) } cb() }) @@ -255,14 +255,14 @@ module.exports = (common) => { series([ (cb) => { - DAGNode.create(new Buffer('Some data 1'), (err, node) => { + DAGNode.create(Buffer.from('Some data 1'), (err, node) => { expect(err).to.not.exist() node1a = node cb() }) }, (cb) => { - DAGNode.create(new Buffer('Some data 2'), (err, node) => { + DAGNode.create(Buffer.from('Some data 2'), (err, node) => { expect(err).to.not.exist() node2 = node cb() @@ -287,7 +287,7 @@ module.exports = (common) => { // because js-ipfs-api can't infer if the // returned Data is Buffer or String if (typeof node.data === 'string') { - node.data = new Buffer(node.data) + node.data = Buffer.from(node.data) } node1c = node @@ -304,7 +304,7 @@ module.exports = (common) => { it('with multihash base58 encoded', (done) => { const obj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -325,7 +325,7 @@ module.exports = (common) => { // because js-ipfs-api can't infer if the // returned Data is Buffer or String if (typeof node.data === 'string') { - node.data = new Buffer(node.data) + node.data = Buffer.from(node.data) } node1b = node cb() @@ -342,7 +342,7 @@ module.exports = (common) => { it('with multihash base58 encoded toString', (done) => { const obj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -363,7 +363,7 @@ module.exports = (common) => { // because js-ipfs-api can't infer if the // returned Data is Buffer or String if (typeof node.data === 'string') { - node.data = new Buffer(node.data) + node.data = Buffer.from(node.data) } node1b = node cb() @@ -382,7 +382,7 @@ module.exports = (common) => { describe('.data', () => { it('with multihash', (done) => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -395,7 +395,7 @@ module.exports = (common) => { // because js-ipfs-api can't infer // if the returned Data is Buffer or String if (typeof data === 'string') { - data = new Buffer(data) + data = Buffer.from(data) } expect(node.data).to.eql(data) done() @@ -405,7 +405,7 @@ module.exports = (common) => { it('with multihash base58 encoded', (done) => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -418,7 +418,7 @@ module.exports = (common) => { // because js-ipfs-api can't infer // if the returned Data is Buffer or String if (typeof data === 'string') { - data = new Buffer(data) + data = Buffer.from(data) } expect(node.data).to.eql(data) done() @@ -428,7 +428,7 @@ module.exports = (common) => { it('with multihash base58 encoded toString', (done) => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -441,7 +441,7 @@ module.exports = (common) => { // because js-ipfs-api can't infer if the // returned Data is Buffer or String if (typeof data === 'string') { - data = new Buffer(data) + data = Buffer.from(data) } expect(node.data).to.eql(data) done() @@ -453,7 +453,7 @@ module.exports = (common) => { describe('.links', () => { it('object.links with multihash', (done) => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -475,14 +475,14 @@ module.exports = (common) => { series([ (cb) => { - DAGNode.create(new Buffer('Some data 1'), (err, node) => { + DAGNode.create(Buffer.from('Some data 1'), (err, node) => { expect(err).to.not.exist() node1a = node cb() }) }, (cb) => { - DAGNode.create(new Buffer('Some data 2'), (err, node) => { + DAGNode.create(Buffer.from('Some data 2'), (err, node) => { expect(err).to.not.exist() node2 = node cb() @@ -513,7 +513,7 @@ module.exports = (common) => { it('with multihash base58 encoded', (done) => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -530,7 +530,7 @@ module.exports = (common) => { it('with multihash base58 encoded toString', (done) => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -548,7 +548,7 @@ module.exports = (common) => { describe('.stat', () => { it('with multihash', (done) => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -578,14 +578,14 @@ module.exports = (common) => { series([ (cb) => { - DAGNode.create(new Buffer('Some data 1'), (err, node) => { + DAGNode.create(Buffer.from('Some data 1'), (err, node) => { expect(err).to.not.exist() node1a = node cb() }) }, (cb) => { - DAGNode.create(new Buffer('Some data 2'), (err, node) => { + DAGNode.create(Buffer.from('Some data 2'), (err, node) => { expect(err).to.not.exist() node2 = node cb() @@ -624,7 +624,7 @@ module.exports = (common) => { it('with multihash base58 encoded', (done) => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -649,7 +649,7 @@ module.exports = (common) => { it('with multihash base58 encoded toString', (done) => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -679,7 +679,7 @@ module.exports = (common) => { let testLink const obj = { - Data: new Buffer('patch test object'), + Data: Buffer.from('patch test object'), Links: [] } @@ -705,7 +705,7 @@ module.exports = (common) => { }) }, (cb) => { - DAGNode.create(new Buffer('some other node'), (err, node) => { + DAGNode.create(Buffer.from('some other node'), (err, node) => { expect(err).to.not.exist() node2 = node cb() @@ -746,7 +746,7 @@ module.exports = (common) => { }) it('.appendData', (done) => { - ipfs.object.patch.appendData(testNodeMultihash, new Buffer('append'), (err, node) => { + ipfs.object.patch.appendData(testNodeMultihash, Buffer.from('append'), (err, node) => { expect(err).to.not.exist() expect(node.multihash).to.not.deep.equal(testNodeMultihash) done() @@ -754,7 +754,7 @@ module.exports = (common) => { }) it('.setData', (done) => { - ipfs.object.patch.appendData(testNodeMultihash, new Buffer('set'), (err, node) => { + ipfs.object.patch.appendData(testNodeMultihash, Buffer.from('set'), (err, node) => { expect(err).to.not.exist() expect(node.multihash).to.not.deep.equal(testNodeMultihash) done() @@ -774,7 +774,7 @@ module.exports = (common) => { it('object.put', () => { const obj = { - Data: new Buffer('Some data'), + Data: Buffer.from('Some data'), Links: [] } @@ -789,7 +789,7 @@ module.exports = (common) => { it('object.get', () => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -798,7 +798,7 @@ module.exports = (common) => { // because js-ipfs-api can't infer if the // returned Data is Buffer or String if (typeof node2.data === 'string') { - node2.data = new Buffer(node2.data) + node2.data = Buffer.from(node2.data) } expect(node1.data).to.deep.equal(node2.data) @@ -815,7 +815,7 @@ module.exports = (common) => { it('object.data', () => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -824,7 +824,7 @@ module.exports = (common) => { // because js-ipfs-api can't infer // if the returned Data is Buffer or String if (typeof data === 'string') { - data = new Buffer(data) + data = Buffer.from(data) } expect(node.data).to.deep.equal(data) }) @@ -833,7 +833,7 @@ module.exports = (common) => { it('object.stat', () => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -857,7 +857,7 @@ module.exports = (common) => { it('object.links', () => { const testObj = { - Data: new Buffer('get test object'), + Data: Buffer.from('get test object'), Links: [] } @@ -874,7 +874,7 @@ module.exports = (common) => { let testLink const obj = { - Data: new Buffer('patch test object'), + Data: Buffer.from('patch test object'), Links: [] } @@ -899,7 +899,7 @@ module.exports = (common) => { }).then((node) => { node1a = node return new Promise((resolve, reject) => { - DAGNode.create(new Buffer('some other node'), function (err, node) { + DAGNode.create(Buffer.from('some other node'), function (err, node) { if (err) { return reject(err) } @@ -938,14 +938,14 @@ module.exports = (common) => { }) it('.appendData', () => { - return ipfs.object.patch.appendData(testNodeMultihash, new Buffer('append')) + return ipfs.object.patch.appendData(testNodeMultihash, Buffer.from('append')) .then((node) => { expect(node.multihash).to.not.deep.equal(testNodeMultihash) }) }) it('.setData', () => { - return ipfs.object.patch.appendData(testNodeMultihash, new Buffer('set')) + return ipfs.object.patch.appendData(testNodeMultihash, Buffer.from('set')) .then((node) => { expect(node.multihash).to.not.deep.equal(testNodeMultihash) }) diff --git a/src/pubsub.js b/src/pubsub.js index af199889e7..407768f495 100644 --- a/src/pubsub.js +++ b/src/pubsub.js @@ -20,8 +20,8 @@ function waitForPeers (ipfs, topic, peersToWait, callback) { } const missingPeers = peersToWait - .map((e) => peers.indexOf(e) !== -1) - .filter((e) => !e) + .map((e) => peers.indexOf(e) !== -1) + .filter((e) => !e) if (missingPeers.length === 0) { clearInterval(i) @@ -103,7 +103,7 @@ module.exports = (common) => { }) it('message from buffer', (done) => { - ipfs1.pubsub.publish(topic, new Buffer('hello friend'), done) + ipfs1.pubsub.publish(topic, Buffer.from('hello friend'), done) }) }) @@ -129,14 +129,14 @@ module.exports = (common) => { ipfs1.pubsub.subscribe(topic, handler, (err) => { expect(err).to.not.exist() - ipfs1.pubsub.publish(topic, new Buffer('hi'), check) + ipfs1.pubsub.publish(topic, Buffer.from('hi'), check) }) }) it('attaches multiple event listeners', (done) => { const check = makeCheck(3, done) const handler1 = (msg) => { - expect(msg.data.toString()).to.be.eql('hello') + expect(msg.data.toString()).to.eql('hello') ipfs1.pubsub.unsubscribe(topic, handler1) @@ -168,7 +168,7 @@ module.exports = (common) => { (cb) => ipfs1.pubsub.subscribe(topic, handler2, cb) ], (err) => { expect(err).to.not.exist() - ipfs1.pubsub.publish(topic, new Buffer('hello'), check) + ipfs1.pubsub.publish(topic, Buffer.from('hello'), check) }) }) @@ -185,7 +185,7 @@ module.exports = (common) => { discover: true }, handler, (err) => { expect(err).to.not.exist() - ipfs1.pubsub.publish(topic, new Buffer('hi'), check) + ipfs1.pubsub.publish(topic, Buffer.from('hi'), check) }) }) }) @@ -378,7 +378,7 @@ module.exports = (common) => { ], (err) => { expect(err).to.not.exist() - ipfs2.pubsub.publish(topic, new Buffer(expectedString), check) + ipfs2.pubsub.publish(topic, Buffer.from(expectedString), check) }) }) @@ -457,7 +457,7 @@ module.exports = (common) => { expect(err).to.not.exist() outbox.forEach((msg) => { - ipfs2.pubsub.publish(topic, new Buffer(msg), check) + ipfs2.pubsub.publish(topic, Buffer.from(msg), check) }) }) }) @@ -482,7 +482,7 @@ module.exports = (common) => { () => sendCount < count, (cb) => { sendCount++ - ipfs1.pubsub.publish(topic, new Buffer('hey there'), cb) + ipfs1.pubsub.publish(topic, Buffer.from('hey there'), cb) }, done ) @@ -539,7 +539,7 @@ module.exports = (common) => { whilst( () => sendCount < count, (cb) => { - const msgData = new Buffer(msgBase + sendCount) + const msgData = Buffer.from(msgBase + sendCount) sendCount++ ipfs2.pubsub.publish(topic, msgData, cb) }, @@ -612,7 +612,7 @@ module.exports = (common) => { } return ipfs1.pubsub.subscribe(topic, sub) - .then(() => ipfs1.pubsub.publish(topic, new Buffer('hi'))) + .then(() => ipfs1.pubsub.publish(topic, Buffer.from('hi'))) }) it('.peers', () => {