diff --git a/CHANGELOG.md b/CHANGELOG.md index 845a05a4..129e02b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +# [0.53.0](https://github.com/ipfs/interface-ipfs-core/compare/v0.52.0...v0.53.0) (2018-03-07) + + +### Bug Fixes + +* adapt dag tests to current environment ([7a6fc5f](https://github.com/ipfs/interface-ipfs-core/commit/7a6fc5f)) +* bwPullStream example ([59bd7ac](https://github.com/ipfs/interface-ipfs-core/commit/59bd7ac)) + + + # [0.52.0](https://github.com/ipfs/interface-ipfs-core/compare/v0.51.0...v0.52.0) (2018-02-15) diff --git a/SPEC/BLOCK.md b/SPEC/BLOCK.md index 65f748eb..24126d74 100644 --- a/SPEC/BLOCK.md +++ b/SPEC/BLOCK.md @@ -155,4 +155,4 @@ A great source of [examples][] can be found in the tests for this API. [block]:https://github.com/ipfs/js-ipfs-block [multihash]:https://github.com/multiformats/multihash -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/block.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/block.js diff --git a/SPEC/CONFIG.md b/SPEC/CONFIG.md index 846fd453..33d3073e 100644 --- a/SPEC/CONFIG.md +++ b/SPEC/CONFIG.md @@ -89,4 +89,4 @@ ipfs.config.replace(newConfig, (err) => { A great source of [examples][] can be found in the tests for this API. [promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/config.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/config.js diff --git a/SPEC/DAG.md b/SPEC/DAG.md index 3933d2ad..145dbb3c 100644 --- a/SPEC/DAG.md +++ b/SPEC/DAG.md @@ -170,4 +170,4 @@ ipfs.dag.tree('zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5', errOrLog) A great source of [examples][] can be found in the tests for this API. -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/dag.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/dag.js diff --git a/SPEC/DHT.md b/SPEC/DHT.md index c033ebfa..74e45eab 100644 --- a/SPEC/DHT.md +++ b/SPEC/DHT.md @@ -118,4 +118,4 @@ ipfs.dht.query(id, function (err, peerInfos) { A great source of [examples][] can be found in the tests for this API. -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/dht.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/dht.js diff --git a/SPEC/FILES.md b/SPEC/FILES.md index 637fd489..3e6670fd 100644 --- a/SPEC/FILES.md +++ b/SPEC/FILES.md @@ -524,7 +524,7 @@ It returns a [Pull Stream][os] that will yield objects of the form: ```JavaScript const validCID = 'QmQ2r6iMNpky5f1m4cnm3Yqw8VSvjuKpTcK1X7dBR1LkJF' -const stream = ipfs.files.getReadableStream(validCID) +const stream = ipfs.files.lsPullStream(validCID) pull( stream, @@ -831,7 +831,7 @@ ipfs.files.ls('/screenshots', function (err, files) { // 2018-01-22T18:08:49.184Z.png ``` -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/files.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/files.js [b]: https://www.npmjs.com/package/buffer [rs]: https://www.npmjs.com/package/readable-stream [ps]: https://www.npmjs.com/package/pull-stream diff --git a/SPEC/MISCELLANEOUS.md b/SPEC/MISCELLANEOUS.md index 9a02d4c8..d07504e4 100644 --- a/SPEC/MISCELLANEOUS.md +++ b/SPEC/MISCELLANEOUS.md @@ -76,7 +76,7 @@ ipfs.dns('ipfs.io', (err, path) => { A great source of [examples][] can be found in the tests for this API. -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/miscellaneous.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/miscellaneous.js #### `stop` @@ -101,4 +101,4 @@ ipfs.stop((err) => { A great source of [examples][] can be found in the tests for this API. -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/miscellaneous.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/miscellaneous.js diff --git a/SPEC/OBJECT.md b/SPEC/OBJECT.md index 1ac956b3..242b0956 100644 --- a/SPEC/OBJECT.md +++ b/SPEC/OBJECT.md @@ -417,4 +417,4 @@ A great source of [examples][] can be found in the tests for this API. [DAGNode]: https://github.com/ipld/js-ipld-dag-pb [multihash]: http://github.com/multiformats/multihash [promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/object.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/object.js diff --git a/SPEC/PIN.md b/SPEC/PIN.md index 418719d7..f805ee02 100644 --- a/SPEC/PIN.md +++ b/SPEC/PIN.md @@ -92,4 +92,4 @@ ipfs.pin.rm(hash, function (err, pinset) { A great source of [examples][] can be found in the tests for this API. -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/pin.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/pin.js diff --git a/SPEC/PUBSUB.md b/SPEC/PUBSUB.md index 8c829262..d65ada8f 100644 --- a/SPEC/PUBSUB.md +++ b/SPEC/PUBSUB.md @@ -146,4 +146,4 @@ ipfs.pubsub.peers(topic, (err, peerIds) => { A great source of [examples][] can be found in the tests for this API. -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/pubsub.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/pubsub.js diff --git a/SPEC/STATS.md b/SPEC/STATS.md index 21bbcbc0..f35186ea 100644 --- a/SPEC/STATS.md +++ b/SPEC/STATS.md @@ -63,7 +63,7 @@ Options are described on [`ipfs.stats.bw`](#bw). const pull = require('pull-stream') const log = require('pull-stream/sinks/log') -const stream = ipfs.stats.bwReadableStream({ poll: true }) +const stream = ipfs.stats.bwPullStream({ poll: true }) pull( stream, diff --git a/SPEC/SWARM.md b/SPEC/SWARM.md index 5a8ba2cb..ec9aa559 100644 --- a/SPEC/SWARM.md +++ b/SPEC/SWARM.md @@ -173,4 +173,4 @@ Example: ipfs.swarm.filters.rm(filter, function (err) {}) ``` -[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/swarm.js +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/swarm.js diff --git a/js/src/dag.js b/js/src/dag.js index a8a70cac..de74c172 100644 --- a/js/src/dag.js +++ b/js/src/dag.js @@ -17,6 +17,7 @@ const CID = require('cids') module.exports = (common) => { describe('.dag', () => { let ipfs + let withGo before(function (done) { // CI takes longer to instantiate the daemon, so we need to increase the @@ -28,7 +29,11 @@ module.exports = (common) => { factory.spawnNode((err, node) => { expect(err).to.not.exist() ipfs = node - done() + ipfs.id((err, id) => { + expect(err).to.not.exist() + withGo = id.agentVersion.startsWith('go-ipfs') + done() + }) }) }) }) @@ -67,17 +72,13 @@ module.exports = (common) => { }, done) }) - /* - * This works because dag-cbor will just treat pbNode as a regular object + // This works because dag-cbor will just treat pbNode as a regular object it.skip('dag-pb node with wrong multicodec', (done) => { - // This works because dag-cbor will just treat pbNode as a - // regular object ipfs.dag.put(pbNode, 'dag-cbor', 'sha3-512', (err) => { expect(err).to.exist() done() }) }) - */ it('dag-cbor with default hash func (sha2-256)', (done) => { ipfs.dag.put(cborNode, { @@ -93,7 +94,13 @@ module.exports = (common) => { }, done) }) - it('dag-cbor node with wrong multicodec', (done) => { + it('dag-cbor node with wrong multicodec', function (done) { + // This works in go-ipfs because dag-pb will serialize any object. If + // the object has neither a `data` nor `links` field it's serialized + // as an empty object + if (withGo) { + this.skip() + } ipfs.dag.put(cborNode, { format: 'dag-pb', hashAlg: 'sha3-512' @@ -106,7 +113,7 @@ module.exports = (common) => { it('returns the cid', (done) => { ipfs.dag.put(cborNode, { format: 'dag-cbor', - hashAlg: 'sha3-512' + hashAlg: 'sha2-256' }, (err, cid) => { expect(err).to.not.exist() expect(cid).to.exist() @@ -239,7 +246,13 @@ module.exports = (common) => { }) }) - it('dag-pb local scope', (done) => { + it('dag-pb local scope', function (done) { + // TODO vmx 2018-02-22: Currently not supported in go-ipfs, it might + // be possible once https://github.com/ipfs/go-ipfs/issues/4728 is + // done + if (withGo) { + this.skip() + } ipfs.dag.get(cidPb, 'Data', (err, result) => { expect(err).to.not.exist() expect(result.value).to.eql(Buffer.from('I am inside a Protobuf')) @@ -276,7 +289,13 @@ module.exports = (common) => { it.skip('dag-cbor two levels', (done) => {}) it.skip('from dag-pb to dag-cbor', (done) => {}) - it('from dag-cbor to dag-pb', (done) => { + it('from dag-cbor to dag-pb', function (done) { + // TODO vmx 2018-02-22: Currently not supported in go-ipfs, it might + // be possible once https://github.com/ipfs/go-ipfs/issues/4728 is + // done + if (withGo) { + this.skip() + } ipfs.dag.get(cidCbor, 'pb/Data', (err, result) => { expect(err).to.not.exist() expect(result.value).to.eql(Buffer.from('I am inside a Protobuf')) @@ -300,7 +319,13 @@ module.exports = (common) => { }) }) - it('CID String + path', (done) => { + it('CID String + path', function (done) { + // TODO vmx 2018-02-22: Currently not supported in go-ipfs, it might + // be possible once https://github.com/ipfs/go-ipfs/issues/4728 is + // done + if (withGo) { + this.skip() + } const cidCborStr = cidCbor.toBaseEncodedString() ipfs.dag.get(cidCborStr + '/pb/Data', (err, result) => { @@ -312,13 +337,17 @@ module.exports = (common) => { }) }) - describe('.tree', () => { + describe('.tree', function () { let nodePb let nodeCbor let cidPb let cidCbor - before((done) => { + before(function (done) { + // TODO vmx 2018-02-22: Currently the tree API is not exposed in go-ipfs + if (withGo) { + this.skip() + } series([ (cb) => { dagPB.DAGNode.create(Buffer.from('I am inside a Protobuf'), (err, node) => { diff --git a/js/src/pubsub.js b/js/src/pubsub.js index d9e40f96..689f48dc 100644 --- a/js/src/pubsub.js +++ b/js/src/pubsub.js @@ -560,64 +560,76 @@ module.exports = (common) => { ) }) - it('send/receive 10k messages', (done) => { - this.timeout(2 * 60 * 1000) + describe('send/receive', () => { + let topic + let sub1 + let sub2 - const msgBase = 'msg - ' - const count = 10000 - let sendCount = 0 - let receivedCount = 0 - let startTime - let counter = 0 - const topic = getTopic() + before(() => { + topic = getTopic() + }) - const sub1 = (msg) => { - // go-ipfs can't send messages in order when there are - // only two nodes in the same machine ¯\_(ツ)_/¯ - // https://github.com/ipfs/js-ipfs-api/pull/493#issuecomment-289499943 - // const expectedMsg = msgBase + receivedCount - // const receivedMsg = msg.data.toString() - // expect(receivedMsg).to.eql(expectedMsg) + after(() => { + ipfs1.pubsub.unsubscribe(topic, sub1) + ipfs2.pubsub.unsubscribe(topic, sub2) + }) - receivedCount++ + it('send/receive 10k messages', function (done) { + this.timeout(2 * 60 * 1000) - if (receivedCount >= count) { - const duration = new Date().getTime() - startTime - const opsPerSec = Math.floor(count / (duration / 1000)) + const msgBase = 'msg - ' + const count = 10000 + let sendCount = 0 + let receivedCount = 0 + let startTime + let counter = 0 - console.log(`Send/Receive 10k messages took: ${duration} ms, ${opsPerSec} ops / s\n`) + sub1 = (msg) => { + // go-ipfs can't send messages in order when there are + // only two nodes in the same machine ¯\_(ツ)_/¯ + // https://github.com/ipfs/js-ipfs-api/pull/493#issuecomment-289499943 + // const expectedMsg = msgBase + receivedCount + // const receivedMsg = msg.data.toString() + // expect(receivedMsg).to.eql(expectedMsg) - check() - } - } + receivedCount++ - const sub2 = (msg) => {} + if (receivedCount >= count) { + const duration = new Date().getTime() - startTime + const opsPerSec = Math.floor(count / (duration / 1000)) - function check () { - if (++counter === 2) { - ipfs1.pubsub.unsubscribe(topic, sub1) - ipfs2.pubsub.unsubscribe(topic, sub2) - done() + console.log(`Send/Receive 10k messages took: ${duration} ms, ${opsPerSec} ops / s\n`) + + check() + } } - } - series([ - (cb) => ipfs1.pubsub.subscribe(topic, sub1, cb), - (cb) => ipfs2.pubsub.subscribe(topic, sub2, cb), - (cb) => waitForPeers(ipfs1, topic, [ipfs2.peerId.id], cb) - ], (err) => { - expect(err).to.not.exist() - startTime = new Date().getTime() + sub2 = (msg) => {} - whilst( - () => sendCount < count, - (cb) => { - const msgData = Buffer.from(msgBase + sendCount) - sendCount++ - ipfs2.pubsub.publish(topic, msgData, cb) - }, - check - ) + function check () { + if (++counter === 2) { + done() + } + } + + series([ + (cb) => ipfs1.pubsub.subscribe(topic, sub1, cb), + (cb) => ipfs2.pubsub.subscribe(topic, sub2, cb), + (cb) => waitForPeers(ipfs1, topic, [ipfs2.peerId.id], cb) + ], (err) => { + expect(err).to.not.exist() + startTime = new Date().getTime() + + whilst( + () => sendCount < count, + (cb) => { + const msgData = Buffer.from(msgBase + sendCount) + sendCount++ + ipfs2.pubsub.publish(topic, msgData, cb) + }, + check + ) + }) }) }) diff --git a/package.json b/package.json index 8294d44d..ba02196b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "interface-ipfs-core", - "version": "0.52.0", + "version": "0.53.0", "description": "A test suite and interface you can use to implement a IPFS core interface.", "main": "js/src/index.js", "scripts": { @@ -30,25 +30,25 @@ }, "homepage": "https://github.com/ipfs/interface-ipfs-core#readme", "dependencies": { - "aegir": "^13.0.0", + "aegir": "^13.0.5", "async": "^2.6.0", "big.js": "^5.0.3", "bl": "^1.2.1", "bs58": "^4.0.1", "chai": "^4.1.2", "cids": "~0.5.2", - "concat-stream": "^1.6.0", + "concat-stream": "^1.6.1", "detect-node": "^2.0.3", "dirty-chai": "^2.0.1", "hat": "0.0.3", "ipfs-block": "~0.6.1", - "ipld-dag-cbor": "~0.11.2", - "ipld-dag-pb": "~0.11.4", + "ipld-dag-cbor": "~0.12.0", + "ipld-dag-pb": "~0.13.1", "multiaddr": "^3.0.2", "multihashes": "~0.4.13", - "multihashing-async": "~0.4.7", + "multihashing-async": "~0.4.8", "peer-id": "~0.10.6", - "pull-stream": "^3.6.1" + "pull-stream": "^3.6.2" }, "devDependencies": {}, "contributors": [ @@ -72,6 +72,8 @@ "Sangwon Hong ", "Stephen Whitmore ", "Thiago Delgado ", + "Volker Mische ", + "achingbrain ", "greenkeeperio-bot ", "haad ", "kumavis ",