From e828af04e78227ec6842e0d9bbaceda6e8ce1eb2 Mon Sep 17 00:00:00 2001 From: Victor Bjelkholm Date: Sat, 17 Sep 2016 17:50:24 +0200 Subject: [PATCH 1/3] Move dht tests from here to interface-ipfs-core --- test/interface-ipfs-core/dht.spec.js | 73 +++++----------------------- 1 file changed, 13 insertions(+), 60 deletions(-) diff --git a/test/interface-ipfs-core/dht.spec.js b/test/interface-ipfs-core/dht.spec.js index c24ab049e..fe1c51355 100644 --- a/test/interface-ipfs-core/dht.spec.js +++ b/test/interface-ipfs-core/dht.spec.js @@ -1,65 +1,18 @@ /* eslint-env mocha */ -/* globals apiClients */ -'use strict' -const expect = require('chai').expect +const test = require('interface-ipfs-core') +const FactoryClient = require('../factory/factory-client') -describe('.dht', () => { - it('returns an error when getting a non-existent key from the DHT', - (done) => { - apiClients.a.dht.get('non-existent', {timeout: '100ms'}, (err, value) => { - expect(err).to.be.an.instanceof(Error) - done() - }) - }) +let fc - it('puts and gets a key value pair in the DHT', (done) => { - apiClients.a.dht.put('scope', 'interplanetary', (err, res) => { - expect(err).to.not.exist +const common = { + setup: function (callback) { + fc = new FactoryClient() + callback(null, fc) + }, + teardown: function (callback) { + fc.dismantle(callback) + } +} - expect(res).to.be.an('array') - - done() - - // non ipns or pk hashes fail to fetch, known bug - // 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() - // }) - }) - }) - - it('.dht.findprovs', (done) => { - apiClients.a.dht.findprovs('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { - expect(err).to.not.exist - - expect(res).to.be.an('array') - done() - }) - }) - - describe('promise', () => { - it('returns an error when getting a non-existent key from the DHT', () => { - return apiClients.a.dht.get('non-existent', {timeout: '100ms'}) - .catch((err) => { - expect(err).to.be.an.instanceof(Error) - }) - }) - - it('puts a key value pair in the DHT', () => { - return apiClients.a.dht.put('scope', 'interplanetary') - .then((res) => { - expect(res).to.be.an('array') - }) - }) - - it('.dht.findprovs', () => { - return apiClients.a.dht.findprovs('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') - .then((res) => { - expect(res).to.be.an('array') - }) - }) - }) -}) +test.dht(common) From 77bc8b1fb2bc2a68d757241ce87df63fc3d5bdca Mon Sep 17 00:00:00 2001 From: Victor Bjelkholm Date: Tue, 8 Nov 2016 18:55:09 +0100 Subject: [PATCH 2/3] Update interface-ipfs-core version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 63c4d1945..ce60a2f18 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "chai": "^3.5.0", "gulp": "^3.9.1", "hapi": "^15.2.0", - "interface-ipfs-core": "^0.18.2", + "interface-ipfs-core": "^0.18.3", "ipfsd-ctl": "^0.17.0", "pre-commit": "^1.1.3", "socket.io": "^1.5.1", From b720d59f36fc27148247e7a9cf32eee9af8b72ef Mon Sep 17 00:00:00 2001 From: Victor Bjelkholm Date: Tue, 8 Nov 2016 19:42:28 +0100 Subject: [PATCH 3/3] Add back strict mode --- test/interface-ipfs-core/dht.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/interface-ipfs-core/dht.spec.js b/test/interface-ipfs-core/dht.spec.js index fe1c51355..ed6c9a162 100644 --- a/test/interface-ipfs-core/dht.spec.js +++ b/test/interface-ipfs-core/dht.spec.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +'use strict' const test = require('interface-ipfs-core') const FactoryClient = require('../factory/factory-client')