From 60c07475c4a0f0c509441beab018fbf41443222b Mon Sep 17 00:00:00 2001 From: David Dias Date: Wed, 30 May 2018 12:25:36 +0100 Subject: [PATCH 1/3] test: augment dht tests, disable the ones that are wonky for go just for go --- js/src/dht.js | 70 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/js/src/dht.js b/js/src/dht.js index 333d2a424..35ff50aa9 100644 --- a/js/src/dht.js +++ b/js/src/dht.js @@ -11,9 +11,10 @@ const CID = require('cids') const { spawnNodesWithId } = require('./utils/spawn') module.exports = (common) => { - describe('.dht', function () { + describe.only('.dht', function () { this.timeout(80 * 1000) + let withGo let nodeA let nodeB let nodeC @@ -47,7 +48,12 @@ module.exports = (common) => { (cb) => nodeE.swarm.connect(nodeB.peerId.addresses[0], cb), (cb) => nodeD.swarm.connect(nodeC.peerId.addresses[0], cb), (cb) => nodeE.swarm.connect(nodeC.peerId.addresses[0], cb), - (cb) => nodeD.swarm.connect(nodeE.peerId.addresses[0], cb) + (cb) => nodeD.swarm.connect(nodeE.peerId.addresses[0], cb), + (cb) => nodeA.id((err, id) => { + expect(err).to.not.exist() + withGo = id.agentVersion.startsWith('go-ipfs') + cb() + }) ], done) }) }) @@ -63,14 +69,19 @@ module.exports = (common) => { }) }) - // TODO: fix - go-ipfs errors with Error: key was not found (type 6) - // https://github.com/ipfs/go-ipfs/issues/3862 - it.skip('fetches value after it was put on another node', (done) => { + it('fetches value after it was put on another node', function (done) { + if (withGo) { + // go-ipfs errors with Error: key was not found (type 6) + // https://github.com/ipfs/go-ipfs/issues/3862 + this.skip() + } + + // TODO - this test needs to keep tryingl instead of the setTimeout waterfall([ (cb) => nodeB.object.new('unixfs-dir', cb), - (node, cb) => setTimeout(() => cb(null, node), 1000), - (node, cb) => { - const multihash = node.toJSON().multihash + (dagNode, cb) => setTimeout(() => cb(null, dagNode), 1000), + (dagNode, cb) => { + const multihash = dagNode.toJSON().multihash nodeA.dht.get(multihash, cb) }, @@ -80,14 +91,6 @@ module.exports = (common) => { } ], done) }) - - it('Promises support', (done) => { - nodeA.dht.get('non-existing', { timeout: '100ms' }) - .catch((err) => { - expect(err).to.exist() - done() - }) - }) }) describe('.findpeer', () => { @@ -100,9 +103,13 @@ module.exports = (common) => { }) }) - // TODO checking what is exactly go-ipfs returning - // https://github.com/ipfs/go-ipfs/issues/3862#issuecomment-294168090 - it.skip('fails to find other peer, if peer doesnt exist()s', (done) => { + it('fails to find other peer, if peer does not exist', function (done) { + if (withGo) { + // TODO checking what is exactly go-ipfs returning + // https://github.com/ipfs/go-ipfs/issues/3862#issuecomment-294168090 + this.skip() + } + nodeA.dht.findpeer('Qmd7qZS4T7xXtsNFdRoK1trfMs5zU94EpokQ9WFtxdPxsZ', (err, peer) => { expect(err).to.not.exist() expect(peer).to.be.equal(null) @@ -177,29 +184,22 @@ module.exports = (common) => { it.skip('recursive', () => {}) }) - describe.skip('findprovs', () => { + describe('findprovs', () => { it('basic', (done) => { - const cid = new CID('Qmd7qZS4T7xXtsNFdRoK1trfMs5zU94EpokQ9WFtxdPxxx') - waterfall([ - (cb) => nodeB.dht.provide(cid, cb), - (cb) => nodeC.dht.findprovs(cid, cb), + (cb) => nodeE.object.new('unixfs-dir', cb), + (dagNode, cb) => { + const cidV0 = new CID(dagNode.toJSON().multihash) + nodeE.dht.provide(cidV0, (err) => cb(err, cidV0)) + }, + (cidV0, cb) => nodeC.dht.findprovs(cidV0, cb), (provs, cb) => { expect(provs.map((p) => p.toB58String())) - .to.eql([nodeB.peerId.id]) + .to.eql([nodeE.peerId.id]) cb() } ], done) }) - - it('Promises support', (done) => { - nodeB.dht.findprovs('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') - .then((res) => { - expect(res).to.be.an('array') - done() - }) - .catch((err) => done(err)) - }) }) describe('.query', () => { @@ -207,7 +207,7 @@ module.exports = (common) => { const timeout = 150 * 1000 this.timeout(timeout) - // This test is flaky. DHT works best with >= 20 nodes. Therefore a + // This test is meh. DHT works best with >= 20 nodes. Therefore a // failure might happen, but we don't want to report it as such. // Hence skip the test before the timeout is reached const timeoutId = setTimeout(function () { From c453191db0369103b659c5f18c6948dd1f64838b Mon Sep 17 00:00:00 2001 From: David Dias Date: Wed, 30 May 2018 12:34:45 +0100 Subject: [PATCH 2/3] test: skip findprovs test in go until the issue has been fixed --- js/src/dht.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/src/dht.js b/js/src/dht.js index 35ff50aa9..149d47b29 100644 --- a/js/src/dht.js +++ b/js/src/dht.js @@ -185,7 +185,13 @@ module.exports = (common) => { }) describe('findprovs', () => { - it('basic', (done) => { + it('provide from one node and find it through another node', function (done) { + if (withGo) { + // TODO go-ipfs endpoint doesn't conform with the others + // https://github.com/ipfs/go-ipfs/issues/5047 + this.skip() + } + waterfall([ (cb) => nodeE.object.new('unixfs-dir', cb), (dagNode, cb) => { From 4b86f80c5862c31c69d5c6d992bce721fdde2234 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 4 Jun 2018 11:00:01 +0100 Subject: [PATCH 3/3] test: remove .only --- js/src/dht.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/src/dht.js b/js/src/dht.js index 149d47b29..6771cf7aa 100644 --- a/js/src/dht.js +++ b/js/src/dht.js @@ -11,7 +11,7 @@ const CID = require('cids') const { spawnNodesWithId } = require('./utils/spawn') module.exports = (common) => { - describe.only('.dht', function () { + describe('.dht', function () { this.timeout(80 * 1000) let withGo @@ -70,6 +70,8 @@ module.exports = (common) => { }) it('fetches value after it was put on another node', function (done) { + this.timeout(80 * 1000) + if (withGo) { // go-ipfs errors with Error: key was not found (type 6) // https://github.com/ipfs/go-ipfs/issues/3862 @@ -79,7 +81,7 @@ module.exports = (common) => { // TODO - this test needs to keep tryingl instead of the setTimeout waterfall([ (cb) => nodeB.object.new('unixfs-dir', cb), - (dagNode, cb) => setTimeout(() => cb(null, dagNode), 1000), + (dagNode, cb) => setTimeout(() => cb(null, dagNode), 20000), (dagNode, cb) => { const multihash = dagNode.toJSON().multihash