Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 3e5ed07

Browse files
committed
Move tests from js-ipfs-api to interface-ipfs-core
1 parent 841c2c3 commit 3e5ed07

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

src/dht.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
}

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ exports.pin = require('./pin')
77
exports.generic = require('./generic')
88
exports.swarm = require('./swarm')
99
exports.block = require('./block')
10+
exports.dht = require('./dht')

0 commit comments

Comments
 (0)