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

Commit 1487d3e

Browse files
victorbdaviddias
authored andcommitted
Move dht tests from js-ipfs-api to interface-ipfs-core (#385)
* Move dht tests from here to interface-ipfs-core * Update interface-ipfs-core version * Add back strict mode
1 parent 5ada84a commit 1487d3e

File tree

2 files changed

+14
-60
lines changed

2 files changed

+14
-60
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"chai": "^3.5.0",
6161
"gulp": "^3.9.1",
6262
"hapi": "^15.2.0",
63-
"interface-ipfs-core": "^0.18.2",
63+
"interface-ipfs-core": "^0.18.3",
6464
"ipfsd-ctl": "^0.17.0",
6565
"pre-commit": "^1.1.3",
6666
"socket.io": "^1.5.1",

test/interface-ipfs-core/dht.spec.js

+13-59
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,19 @@
11
/* eslint-env mocha */
2-
/* globals apiClients */
32
'use strict'
43

5-
const expect = require('chai').expect
4+
const test = require('interface-ipfs-core')
5+
const FactoryClient = require('../factory/factory-client')
66

7-
describe('.dht', () => {
8-
it('returns an error when getting a non-existent key from the DHT',
9-
(done) => {
10-
apiClients.a.dht.get('non-existent', {timeout: '100ms'}, (err, value) => {
11-
expect(err).to.be.an.instanceof(Error)
12-
done()
13-
})
14-
})
7+
let fc
158

16-
it('puts and gets a key value pair in the DHT', (done) => {
17-
apiClients.a.dht.put('scope', 'interplanetary', (err, res) => {
18-
expect(err).to.not.exist
9+
const common = {
10+
setup: function (callback) {
11+
fc = new FactoryClient()
12+
callback(null, fc)
13+
},
14+
teardown: function (callback) {
15+
fc.dismantle(callback)
16+
}
17+
}
1918

20-
expect(res).to.be.an('array')
21-
22-
done()
23-
24-
// non ipns or pk hashes fail to fetch, known bug
25-
// bug: https://github.com/ipfs/go-ipfs/issues/1923#issuecomment-152932234
26-
// apiClients.a.dht.get('scope', (err, value) => {
27-
// expect(err).to.not.exist
28-
// expect(value).to.be.equal('interplanetary')
29-
// done()
30-
// })
31-
})
32-
})
33-
34-
it('.dht.findprovs', (done) => {
35-
apiClients.a.dht.findprovs('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => {
36-
expect(err).to.not.exist
37-
38-
expect(res).to.be.an('array')
39-
done()
40-
})
41-
})
42-
43-
describe('promise', () => {
44-
it('returns an error when getting a non-existent key from the DHT', () => {
45-
return apiClients.a.dht.get('non-existent', {timeout: '100ms'})
46-
.catch((err) => {
47-
expect(err).to.be.an.instanceof(Error)
48-
})
49-
})
50-
51-
it('puts a key value pair in the DHT', () => {
52-
return apiClients.a.dht.put('scope', 'interplanetary')
53-
.then((res) => {
54-
expect(res).to.be.an('array')
55-
})
56-
})
57-
58-
it('.dht.findprovs', () => {
59-
return apiClients.a.dht.findprovs('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP')
60-
.then((res) => {
61-
expect(res).to.be.an('array')
62-
})
63-
})
64-
})
65-
})
19+
test.dht(common)

0 commit comments

Comments
 (0)