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

Commit

Permalink
Move tests from js-ipfs-api to interface-ipfs-core
Browse files Browse the repository at this point in the history
  • Loading branch information
victorb committed Sep 21, 2016
1 parent bc2d695 commit 0f55017
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/dht.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* eslint-env mocha */
'use strict'

const expect = require('chai').expect

module.exports = (common) => {
describe.only('.dht', () => {
let ipfs

before((done) => {
common.setup((err, factory) => {
expect(err).to.not.exists
factory.spawnNode((err, node) => {
expect(err).to.not.exist
ipfs = node
done()
})
})
})

after((done) => {
common.teardown(done)
})
xdescribe('.findpeer', () => {})
describe('.get', (done) => {
it('errors when getting a non-existent key from the DHT', (done) => {
ipfs.dht.get('non-existing', {timeout: '100ms'}, (err, value) => {
expect(err).to.be.an.instanceof(Error)
done()
})
})
// belongs in put or integration
it('puts and gets a key value pair in the DHT', (done) => {
ipfs.dht.put('scope', 'interplanetary', (err, res) => {
expect(err).to.not.exist

expect(res).to.be.an('array')

done()
// bug: https://github.com/ipfs/go-ipfs/issues/1923#issuecomment-152932234
// apiClients.a.dht.get('scope', (err, value) => {
// expect(err).to.not.exist
// expect(value).to.be.equal('interplanetary')
// done()
// })
})
})
})
xdescribe('.put', () => {})
xdescribe('.query', () => {})
describe('.findprovs', () => {
it('finds providers', (done) => {
ipfs.dht.findprovs('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => {
expect(err).to.not.exist

expect(res).to.be.an('array')
done()
})
})
})
})
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ exports.pin = require('./pin')
exports.generic = require('./generic')
exports.swarm = require('./swarm')
exports.block = require('./block')
exports.dht = require('./dht')

0 comments on commit 0f55017

Please sign in to comment.