This repository was archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
test: augment dht tests (first pass) #288
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ module.exports = (common) => { | |
describe('.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,21 @@ 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) { | ||
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 | ||
this.skip() | ||
} | ||
|
||
// TODO - this test needs to keep tryingl instead of the setTimeout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes please! 20s is ages to have to mandatory wait! |
||
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), 20000), | ||
(dagNode, cb) => { | ||
const multihash = dagNode.toJSON().multihash | ||
|
||
nodeA.dht.get(multihash, cb) | ||
}, | ||
|
@@ -80,14 +93,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 +105,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,37 +186,36 @@ module.exports = (common) => { | |
it.skip('recursive', () => {}) | ||
}) | ||
|
||
describe.skip('findprovs', () => { | ||
it('basic', (done) => { | ||
const cid = new CID('Qmd7qZS4T7xXtsNFdRoK1trfMs5zU94EpokQ9WFtxdPxxx') | ||
describe('findprovs', () => { | ||
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) => 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', () => { | ||
it('returns the other node in the query', function (done) { | ||
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 () { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI,
spawnNodesWithId
from above means that you already havenodeA.peerId.agentVersion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, missed that completely. Coming in a soon PR :) Thank you!