diff --git a/package.json b/package.json index 19342e384..5462fa400 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ipfs-api", "version": "18.0.0", - "description": "A client library for the IPFS HTTP API. Follows interface-ipfs-core spec", + "description": "A client library for the IPFS HTTP API", "main": "src/index.js", "browser": { "glob": false, @@ -71,7 +71,7 @@ "eslint-plugin-react": "^7.6.1", "go-ipfs-dep": "^0.4.13", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.50.1", + "interface-ipfs-core": "~0.51.0", "hapi": "^17.2.0", "ipfsd-ctl": "~0.28.0", "pre-commit": "^1.2.2", diff --git a/test/bootstrap.spec.js b/test/bootstrap.spec.js deleted file mode 100644 index 8a32d5274..000000000 --- a/test/bootstrap.spec.js +++ /dev/null @@ -1,113 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ -'use strict' - -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - -const IPFSApi = require('../src') -const f = require('./utils/factory') - -const invalidArg = 'this/Is/So/Invalid/' -const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z' - -describe('.bootstrap', function () { - this.timeout(100 * 1000) - - let ipfsd - let ipfs - - before((done) => { - f.spawn((err, _ipfsd) => { - expect(err).to.not.exist() - ipfsd = _ipfsd - ipfs = IPFSApi(_ipfsd.apiAddr) - done() - }) - }) - - after((done) => ipfsd.stop(done)) - - let peers - - describe('.add', () => { - it('returns an error when called with an invalid arg', (done) => { - ipfs.bootstrap.add(invalidArg, (err) => { - expect(err).to.be.an.instanceof(Error) - done() - }) - }) - - it('returns a list of containing the bootstrap peer when called with a valid arg (ip4)', (done) => { - ipfs.bootstrap.add(validIp4, (err, res) => { - expect(err).to.not.exist() - expect(res).to.be.eql({ Peers: [validIp4] }) - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.eql(1) - done() - }) - }) - - it('returns a list of bootstrap peers when called with the default option', (done) => { - ipfs.bootstrap.add({ default: true }, (err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.above(1) - done() - }) - }) - }) - - describe('.list', () => { - it('returns a list of peers', (done) => { - ipfs.bootstrap.list((err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - done() - }) - }) - }) - - describe('.rm', () => { - it('returns an error when called with an invalid arg', (done) => { - ipfs.bootstrap.rm(invalidArg, (err) => { - expect(err).to.be.an.instanceof(Error) - done() - }) - }) - - it('returns empty list because no peers removed when called without an arg or options', (done) => { - ipfs.bootstrap.rm(null, (err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.eql(0) - done() - }) - }) - - it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => { - ipfs.bootstrap.rm(null, (err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.eql(0) - done() - }) - }) - - it('returns list of all peers removed when all option is passed', (done) => { - ipfs.bootstrap.rm(null, { all: true }, (err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - done() - }) - }) - }) -}) diff --git a/test/interface/bootstrap.spec.js b/test/interface/bootstrap.spec.js new file mode 100644 index 000000000..4e2e4bd00 --- /dev/null +++ b/test/interface/bootstrap.spec.js @@ -0,0 +1,32 @@ +/* eslint-env mocha */ + +'use strict' + +const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + +const IPFSApi = require('../../src') +const f = require('../utils/factory') + +const nodes = [] +const common = { + setup: function (callback) { + callback(null, { + spawnNode: (cb) => { + f.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) + } +} + +test.bootstrap(common)