|
| 1 | +/* eslint-env mocha */ |
| 2 | +'use strict' |
| 3 | + |
| 4 | +const expect = require('chai').expect |
| 5 | + |
| 6 | +module.exports = (common) => { |
| 7 | + describe.only('.dht', () => { |
| 8 | + let ipfs |
| 9 | + |
| 10 | + before((done) => { |
| 11 | + common.setup((err, factory) => { |
| 12 | + expect(err).to.not.exists |
| 13 | + factory.spawnNode((err, node) => { |
| 14 | + expect(err).to.not.exist |
| 15 | + ipfs = node |
| 16 | + done() |
| 17 | + }) |
| 18 | + }) |
| 19 | + }) |
| 20 | + |
| 21 | + after((done) => { |
| 22 | + common.teardown(done) |
| 23 | + }) |
| 24 | + xdescribe('.findpeer', () => {}) |
| 25 | + describe('.get', (done) => { |
| 26 | + it('errors when getting a non-existent key from the DHT', (done) => { |
| 27 | + ipfs.dht.get('non-existing', {timeout: '100ms'}, (err, value) => { |
| 28 | + expect(err).to.be.an.instanceof(Error) |
| 29 | + done() |
| 30 | + }) |
| 31 | + }) |
| 32 | + // belongs in put or integration |
| 33 | + it('puts and gets a key value pair in the DHT', (done) => { |
| 34 | + ipfs.dht.put('scope', 'interplanetary', (err, res) => { |
| 35 | + expect(err).to.not.exist |
| 36 | + |
| 37 | + expect(res).to.be.an('array') |
| 38 | + |
| 39 | + done() |
| 40 | + // bug: https://github.com/ipfs/go-ipfs/issues/1923#issuecomment-152932234 |
| 41 | + // apiClients.a.dht.get('scope', (err, value) => { |
| 42 | + // expect(err).to.not.exist |
| 43 | + // expect(value).to.be.equal('interplanetary') |
| 44 | + // done() |
| 45 | + // }) |
| 46 | + }) |
| 47 | + }) |
| 48 | + }) |
| 49 | + xdescribe('.put', () => {}) |
| 50 | + xdescribe('.query', () => {}) |
| 51 | + describe('.findprovs', () => { |
| 52 | + it('finds providers', (done) => { |
| 53 | + ipfs.dht.findprovs('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { |
| 54 | + expect(err).to.not.exist |
| 55 | + |
| 56 | + expect(res).to.be.an('array') |
| 57 | + done() |
| 58 | + }) |
| 59 | + }) |
| 60 | + }) |
| 61 | + }) |
| 62 | +} |
0 commit comments