From 12e6da255de3e4c8dec5b9751c7472fd7e856014 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 21 Dec 2017 02:54:55 -0600 Subject: [PATCH 01/14] feat: use new ipfsd-ctl --- .aegir.js | 12 ++-- test/bitswap.spec.js | 28 +++++---- test/bootstrap.spec.js | 50 ++++++++-------- test/commands.spec.js | 19 +++--- test/constructor.spec.js | 14 +++-- test/diag.spec.js | 26 ++++----- test/files.spec.js | 89 ++++++++++++++-------------- test/get.spec.js | 29 +++++----- test/interface/block.spec.js | 10 +--- test/interface/config.spec.js | 10 +--- test/interface/dht.spec.js | 10 +--- test/interface/files.spec.js | 11 +--- test/interface/generic.spec.js | 10 +--- test/interface/key.spec.js | 10 +--- test/interface/object.spec.js | 10 +--- test/interface/pin.spec.js | 10 +--- test/interface/pubsub.spec.js | 12 ++-- test/interface/swarm.spec.js | 10 +--- test/ipfs-factory/client.js | 60 ------------------- test/ipfs-factory/daemon-spawner.js | 90 ----------------------------- test/ipfs-factory/server-routes.js | 35 ----------- test/ipfs-factory/server.js | 28 --------- test/ipfs-factory/tasks.js | 22 ------- test/key.spec.js | 28 +++++---- test/log.spec.js | 26 ++++----- test/name.spec.js | 37 +++++++----- test/ping.spec.js | 30 ++++++---- test/pubsub-in-browser.spec.js | 57 ++++++------------ test/refs.spec.js | 24 ++++---- test/repo.spec.js | 24 ++++---- test/stats.spec.js | 28 +++++---- test/util.spec.js | 32 +++++----- 32 files changed, 299 insertions(+), 592 deletions(-) delete mode 100644 test/ipfs-factory/client.js delete mode 100644 test/ipfs-factory/daemon-spawner.js delete mode 100644 test/ipfs-factory/server-routes.js delete mode 100644 test/ipfs-factory/server.js delete mode 100644 test/ipfs-factory/tasks.js diff --git a/.aegir.js b/.aegir.js index 0e7eebbde..58b0db315 100644 --- a/.aegir.js +++ b/.aegir.js @@ -1,7 +1,8 @@ 'use strict' -const factory = require('./test/ipfs-factory/tasks') +const createServer = require('ipfsd-ctl').createServer +const server = createServer() module.exports = { karma: { files: [{ @@ -9,10 +10,13 @@ module.exports = { watched: false, served: true, included: false - }] + }], + singleRun: true }, hooks: { - pre: factory.start, - post: factory.stop + browser: { + pre: server.start.bind(server), + post: server.stop.bind(server) + } } } diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index 35cd7a855..5e99e2a95 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -5,30 +5,28 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const FactoryClient = require('./ipfs-factory/client') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() describe('.bitswap', function () { this.timeout(20 * 1000) // slow CI - let ipfs - let fc + let ipfsd = null before((done) => { this.timeout(20 * 1000) // slow CI - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => { - fc.dismantle(done) - }) + after((done) => ipfsd.stop(done)) describe('Callback API', () => { it('.wantlist', (done) => { - ipfs.bitswap.wantlist((err, res) => { + ipfsd.api.bitswap.wantlist((err, res) => { expect(err).to.not.exist() expect(res).to.have.to.be.eql({ Keys: null @@ -38,7 +36,7 @@ describe('.bitswap', function () { }) it('.stat', (done) => { - ipfs.bitswap.stat((err, res) => { + ipfsd.api.bitswap.stat((err, res) => { expect(err).to.not.exist() expect(res).to.have.property('BlocksReceived') expect(res).to.have.property('DupBlksReceived') @@ -53,7 +51,7 @@ describe('.bitswap', function () { it('.unwant', (done) => { const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - ipfs.bitswap.unwant(key, (err) => { + ipfsd.api.bitswap.unwant(key, (err) => { expect(err).to.not.exist() done() }) @@ -62,7 +60,7 @@ describe('.bitswap', function () { describe('Promise API', () => { it('.wantlist', () => { - return ipfs.bitswap.wantlist() + return ipfsd.api.bitswap.wantlist() .then((res) => { expect(res).to.have.to.be.eql({ Keys: null @@ -71,7 +69,7 @@ describe('.bitswap', function () { }) it('.stat', () => { - return ipfs.bitswap.stat() + return ipfsd.api.bitswap.stat() .then((res) => { expect(res).to.have.property('BlocksReceived') expect(res).to.have.property('DupBlksReceived') @@ -84,7 +82,7 @@ describe('.bitswap', function () { it('.unwant', () => { const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - return ipfs.bitswap.unwant(key) + return ipfsd.api.bitswap.unwant(key) }) }) }) diff --git a/test/bootstrap.spec.js b/test/bootstrap.spec.js index 65b053485..e5bc5986e 100644 --- a/test/bootstrap.spec.js +++ b/test/bootstrap.spec.js @@ -6,7 +6,9 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const FactoryClient = require('./ipfs-factory/client') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const invalidArg = 'this/Is/So/Invalid/' const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z' @@ -14,21 +16,17 @@ const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrS describe('.bootstrap', function () { this.timeout(100 * 1000) - let ipfs - let fc + let ipfsd before((done) => { - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => { - fc.dismantle(done) - }) + after((done) => ipfsd.stop(done)) let peers @@ -37,14 +35,14 @@ describe('.bootstrap', function () { describe('.add', () => { it('returns an error when called with an invalid arg', (done) => { - ipfs.bootstrap.add(invalidArg, (err) => { + ipfsd.api.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) => { + ipfsd.api.bootstrap.add(validIp4, (err, res) => { expect(err).to.not.exist() expect(res).to.be.eql({ Peers: [validIp4] }) peers = res.Peers @@ -55,7 +53,7 @@ describe('.bootstrap', function () { }) it('returns a list of bootstrap peers when called with the default option', (done) => { - ipfs.bootstrap.add({ default: true }, (err, res) => { + ipfsd.api.bootstrap.add({ default: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -67,7 +65,7 @@ describe('.bootstrap', function () { describe('.list', () => { it('returns a list of peers', (done) => { - ipfs.bootstrap.list((err, res) => { + ipfsd.api.bootstrap.list((err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -78,14 +76,14 @@ describe('.bootstrap', function () { describe('.rm', () => { it('returns an error when called with an invalid arg', (done) => { - ipfs.bootstrap.rm(invalidArg, (err) => { + ipfsd.api.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) => { + ipfsd.api.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -95,7 +93,7 @@ describe('.bootstrap', function () { }) it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => { - ipfs.bootstrap.rm(null, (err, res) => { + ipfsd.api.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -105,7 +103,7 @@ describe('.bootstrap', function () { }) it('returns list of all peers removed when all option is passed', (done) => { - ipfs.bootstrap.rm(null, { all: true }, (err, res) => { + ipfsd.api.bootstrap.rm(null, { all: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -120,21 +118,21 @@ describe('.bootstrap', function () { describe('.add', () => { it('returns an error when called without args or options', () => { - return ipfs.bootstrap.add(null) + return ipfsd.api.bootstrap.add(null) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns an error when called with an invalid arg', () => { - return ipfs.bootstrap.add(invalidArg) + return ipfsd.api.bootstrap.add(invalidArg) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns a list of peers when called with a valid arg (ip4)', () => { - return ipfs.bootstrap.add(validIp4) + return ipfsd.api.bootstrap.add(validIp4) .then((res) => { expect(res).to.be.eql({ Peers: [validIp4] }) peers = res.Peers @@ -144,7 +142,7 @@ describe('.bootstrap', function () { }) it('returns a list of default peers when called with the default option', () => { - return ipfs.bootstrap.add(null, { default: true }) + return ipfsd.api.bootstrap.add(null, { default: true }) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -155,7 +153,7 @@ describe('.bootstrap', function () { describe('.list', () => { it('returns a list of peers', () => { - return ipfs.bootstrap.list() + return ipfsd.api.bootstrap.list() .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -165,14 +163,14 @@ describe('.bootstrap', function () { describe('.rm', () => { it('returns an error when called with an invalid arg', () => { - return ipfs.bootstrap.rm(invalidArg) + return ipfsd.api.bootstrap.rm(invalidArg) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns empty list when called without an arg or options', () => { - return ipfs.bootstrap.rm(null) + return ipfsd.api.bootstrap.rm(null) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -181,7 +179,7 @@ describe('.bootstrap', function () { }) it('returns list containing the peer removed when called with a valid arg (ip4)', () => { - return ipfs.bootstrap.rm(null) + return ipfsd.api.bootstrap.rm(null) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -190,7 +188,7 @@ describe('.bootstrap', function () { }) it('returns list of all peers removed when all option is passed', () => { - return ipfs.bootstrap.rm(null, { all: true }) + return ipfsd.api.bootstrap.rm(null, { all: true }) .then((res) => { peers = res.Peers expect(peers).to.exist() diff --git a/test/commands.spec.js b/test/commands.spec.js index 5962d47fb..e7f937f94 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -6,29 +6,26 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const FactoryClient = require('./ipfs-factory/client') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() describe('.commands', function () { this.timeout(20 * 1000) - let ipfs - let fc + let ipfsd before((done) => { - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => { - fc.dismantle(done) - }) + after((done) => ipfsd.stop(done)) it('lists commands', (done) => { - ipfs.commands((err, res) => { + ipfsd.api.commands((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -37,7 +34,7 @@ describe('.commands', function () { describe('promise', () => { it('lists commands', () => { - return ipfs.commands() + return ipfsd.api.commands() .then((res) => { expect(res).to.exist() }) diff --git a/test/constructor.spec.js b/test/constructor.spec.js index a210d1e36..46ef3fb3e 100644 --- a/test/constructor.spec.js +++ b/test/constructor.spec.js @@ -5,7 +5,9 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const FactoryClient = require('./ipfs-factory/client') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const ipfsAPI = require('../src/index.js') @@ -22,19 +24,19 @@ function clientWorks (client, done) { describe('ipfs-api constructor tests', () => { describe('parameter permuations', () => { let apiAddr - let fc + let ipfsd before(function (done) { this.timeout(20 * 1000) // slow CI - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - apiAddr = node.apiAddr + ipfsd = node + apiAddr = node.apiAddr.toString() done() }) }) - after((done) => fc.dismantle(done)) + after((done) => ipfsd.stop(done)) it('opts', (done) => { const splitted = apiAddr.split('/') diff --git a/test/diag.spec.js b/test/diag.spec.js index ca88ba225..b5731733d 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -1,13 +1,15 @@ /* eslint-env mocha */ 'use strict' -const FactoryClient = require('./ipfs-factory/client') const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) const os = require('os') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() + describe('.diag', function () { this.timeout(50 * 1000) @@ -16,24 +18,22 @@ describe('.diag', function () { return } - let ipfs - let fc + let ipfsd before((done) => { - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => fc.dismantle(done)) + after((done) => ipfsd.stop(done)) describe('Callback API', () => { // Disabled in go-ipfs 0.4.10 it.skip('.diag.net', (done) => { - ipfs.diag.net((err, res) => { + ipfsd.api.diag.net((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -41,7 +41,7 @@ describe('.diag', function () { }) it('.diag.sys', (done) => { - ipfs.diag.sys((err, res) => { + ipfsd.api.diag.sys((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('memory') @@ -51,7 +51,7 @@ describe('.diag', function () { }) it('.diag.cmds', (done) => { - ipfs.diag.cmds((err, res) => { + ipfsd.api.diag.cmds((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -62,12 +62,12 @@ describe('.diag', function () { describe('Promise API', () => { // Disabled in go-ipfs 0.4.10 it.skip('.diag.net', () => { - return ipfs.diag.net() + return ipfsd.api.diag.net() .then((res) => expect(res).to.exist()) }) it('.diag.sys', () => { - return ipfs.diag.sys() + return ipfsd.api.diag.sys() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('memory') @@ -76,7 +76,7 @@ describe('.diag', function () { }) it('.diag.cmds', () => { - return ipfs.diag.cmds() + return ipfsd.api.diag.cmds() .then((res) => expect(res).to.exist()) }) }) diff --git a/test/files.spec.js b/test/files.spec.js index 6806643eb..94536e51a 100644 --- a/test/files.spec.js +++ b/test/files.spec.js @@ -11,7 +11,8 @@ const loadFixture = require('aegir/fixtures') const mh = require('multihashes') const CID = require('cids') -const FactoryClient = require('./ipfs-factory/client') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const testfile = isNode ? loadFixture(__dirname, '/fixtures/testfile.txt') @@ -32,27 +33,25 @@ const HASH_ALGS = [ describe('.files (the MFS API part)', function () { this.timeout(120 * 1000) - let ipfs - let fc + let ipfsd const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' before((done) => { - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => fc.dismantle(done)) + after((done) => ipfsd.stop(done)) describe('Callback API', function () { this.timeout(120 * 1000) it('add file for testing', (done) => { - ipfs.files.add(testfile, (err, res) => { + ipfsd.api.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -80,7 +79,7 @@ describe('.files (the MFS API part)', function () { const expectedCid = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK' const options = { 'cid-version': 1, 'raw-leaves': false } - ipfs.files.add(testfile, options, (err, res) => { + ipfsd.api.files.add(testfile, options, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -91,7 +90,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add with options', (done) => { - ipfs.files.add(testfile, { pin: false }, (err, res) => { + ipfsd.api.files.add(testfile, { pin: false }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -110,7 +109,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - ipfs.files.add([file], options, (err, res) => { + ipfsd.api.files.add([file], options, (err, res) => { if (err) return done(err) expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -129,7 +128,7 @@ describe('.files (the MFS API part)', function () { progress = p } - ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -150,7 +149,7 @@ describe('.files (the MFS API part)', function () { } // TODO: needs to be using a big file - ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -171,7 +170,7 @@ describe('.files (the MFS API part)', function () { } // TODO: needs to be using a directory - ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -183,7 +182,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add without progress options', (done) => { - ipfs.files.add(testfile, (err, res) => { + ipfsd.api.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -200,7 +199,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - ipfs.files.add([file], options, (err, res) => { + ipfsd.api.files.add([file], options, (err, res) => { if (err) return done(err) expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -211,15 +210,15 @@ describe('.files (the MFS API part)', function () { }) it('files.mkdir', (done) => { - ipfs.files.mkdir('/test-folder', done) + ipfsd.api.files.mkdir('/test-folder', done) }) it('files.flush', (done) => { - ipfs.files.flush('/', done) + ipfsd.api.files.flush('/', done) }) it('files.cp', (done) => { - ipfs.files.cp([ + ipfsd.api.files.cp([ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', '/test-folder/test-file' ], (err) => { @@ -229,7 +228,7 @@ describe('.files (the MFS API part)', function () { }) it('files.ls', (done) => { - ipfs.files.ls('/test-folder', (err, res) => { + ipfsd.api.files.ls('/test-folder', (err, res) => { expect(err).to.not.exist() expect(res.Entries.length).to.equal(1) done() @@ -237,11 +236,11 @@ describe('.files (the MFS API part)', function () { }) it('files.write', (done) => { - ipfs.files + ipfsd.api.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), {create: true}, (err) => { expect(err).to.not.exist() - ipfs.files.read('/test-folder/test-file-2.txt', (err, stream) => { + ipfsd.api.files.read('/test-folder/test-file-2.txt', (err, stream) => { expect(err).to.not.exist() let buf = '' @@ -259,11 +258,11 @@ describe('.files (the MFS API part)', function () { }) it('files.write without options', (done) => { - ipfs.files + ipfsd.api.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), (err) => { expect(err).to.not.exist() - ipfs.files.read('/test-folder/test-file-2.txt', (err, stream) => { + ipfsd.api.files.read('/test-folder/test-file-2.txt', (err, stream) => { expect(err).to.not.exist() let buf = '' @@ -283,7 +282,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat', (done) => { - ipfs.files.stat('/test-folder/test-file', (err, res) => { + ipfsd.api.files.stat('/test-folder/test-file', (err, res) => { expect(err).to.not.exist() expect(res).to.deep.equal({ Hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', @@ -298,7 +297,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat file that does not exist()', (done) => { - ipfs.files.stat('/test-folder/does-not-exist()', (err, res) => { + ipfsd.api.files.stat('/test-folder/does-not-exist()', (err, res) => { expect(err).to.exist() if (err.code === 0) { return done() @@ -312,7 +311,7 @@ describe('.files (the MFS API part)', function () { return done() } - ipfs.files.read('/test-folder/test-file', (err, stream) => { + ipfsd.api.files.read('/test-folder/test-file', (err, stream) => { expect(err).to.not.exist() let buf = '' stream @@ -330,11 +329,11 @@ describe('.files (the MFS API part)', function () { }) it('files.rm without options', (done) => { - ipfs.files.rm('/test-folder/test-file-2.txt', done) + ipfsd.api.files.rm('/test-folder/test-file-2.txt', done) }) it('files.rm', (done) => { - ipfs.files.rm('/test-folder', {recursive: true}, done) + ipfsd.api.files.rm('/test-folder', {recursive: true}, done) }) }) @@ -342,7 +341,7 @@ describe('.files (the MFS API part)', function () { this.timeout(120 * 1000) it('files.add', () => { - return ipfs.files.add(testfile) + return ipfsd.api.files.add(testfile) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedMultihash) @@ -354,7 +353,7 @@ describe('.files (the MFS API part)', function () { const expectedHash = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK' const options = { 'cid-version': 1, 'raw-leaves': false } - return ipfs.files.add(testfile, options) + return ipfsd.api.files.add(testfile, options) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedHash) @@ -363,7 +362,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add with options', () => { - return ipfs.files.add(testfile, { pin: false }) + return ipfsd.api.files.add(testfile, { pin: false }) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedMultihash) @@ -380,7 +379,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - return ipfs.files.add([file], options) + return ipfsd.api.files.add([file], options) .then((res) => { expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -390,11 +389,11 @@ describe('.files (the MFS API part)', function () { }) it('files.mkdir', () => { - return ipfs.files.mkdir('/test-folder') + return ipfsd.api.files.mkdir('/test-folder') }) it('files.cp', () => { - return ipfs.files + return ipfsd.api.files .cp([ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', '/test-folder/test-file' @@ -402,17 +401,17 @@ describe('.files (the MFS API part)', function () { }) it('files.ls', () => { - return ipfs.files.ls('/test-folder') + return ipfsd.api.files.ls('/test-folder') .then((res) => { expect(res.Entries.length).to.equal(1) }) }) it('files.write', (done) => { - ipfs.files + ipfsd.api.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), {create: true}) .then(() => { - return ipfs.files.read('/test-folder/test-file-2.txt') + return ipfsd.api.files.read('/test-folder/test-file-2.txt') }) .then((stream) => { let buf = '' @@ -432,10 +431,10 @@ describe('.files (the MFS API part)', function () { }) it('files.write without options', (done) => { - ipfs.files + ipfsd.api.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world')) .then(() => { - return ipfs.files.read('/test-folder/test-file-2.txt') + return ipfsd.api.files.read('/test-folder/test-file-2.txt') }) .then((stream) => { let buf = '' @@ -455,7 +454,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat', () => { - return ipfs.files.stat('/test-folder/test-file') + return ipfsd.api.files.stat('/test-folder/test-file') .then((res) => { expect(res).to.deep.equal({ Hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', @@ -468,7 +467,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat file that does not exist()', () => { - return ipfs.files.stat('/test-folder/does-not-exist()') + return ipfsd.api.files.stat('/test-folder/does-not-exist()') .catch((err) => { expect(err).to.exist() expect(err.code).to.be.eql(0) @@ -478,7 +477,7 @@ describe('.files (the MFS API part)', function () { it('files.read', (done) => { if (!isNode) { return done() } - ipfs.files.read('/test-folder/test-file') + ipfsd.api.files.read('/test-folder/test-file') .then((stream) => { let buf = '' stream @@ -496,11 +495,11 @@ describe('.files (the MFS API part)', function () { }) it('files.rm without options', () => { - return ipfs.files.rm('/test-folder/test-file-2.txt') + return ipfsd.api.files.rm('/test-folder/test-file-2.txt') }) it('files.rm', () => { - return ipfs.files.rm('/test-folder', { recursive: true }) + return ipfsd.api.files.rm('/test-folder', { recursive: true }) }) }) }) diff --git a/test/get.spec.js b/test/get.spec.js index 008905bba..7c21659ee 100644 --- a/test/get.spec.js +++ b/test/get.spec.js @@ -10,7 +10,9 @@ chai.use(dirtyChai) const isNode = require('detect-node') const series = require('async/series') const loadFixture = require('aegir/fixtures') -const FactoryClient = require('./ipfs-factory/client') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() describe('.get (specific go-ipfs features)', function () { this.timeout(20 * 1000) @@ -24,26 +26,23 @@ describe('.get (specific go-ipfs features)', function () { data: fixture('../test/fixtures/testfile.txt') } - let ipfs - let fc + let ipfsd before((done) => { - fc = new FactoryClient() - series([ - (cb) => fc.spawnNode((err, node) => { + (cb) => df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node cb() }), - (cb) => ipfs.files.add(smallFile.data, cb) + (cb) => ipfsd.api.files.add(smallFile.data, cb) ], done) }) - after((done) => fc.dismantle(done)) + after((done) => ipfsd.stop(done)) it('no compression args', (done) => { - ipfs.get(smallFile.cid, (err, files) => { + ipfsd.api.get(smallFile.cid, (err, files) => { expect(err).to.not.exist() expect(files).to.be.length(1) @@ -53,7 +52,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('archive true', (done) => { - ipfs.get(smallFile.cid, { archive: true }, (err, files) => { + ipfsd.api.get(smallFile.cid, { archive: true }, (err, files) => { expect(err).to.not.exist() expect(files).to.be.length(1) @@ -63,7 +62,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('err with out of range compression level', (done) => { - ipfs.get(smallFile.cid, { + ipfsd.api.get(smallFile.cid, { compress: true, 'compression-level': 10 }, (err, files) => { @@ -74,7 +73,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('with compression level', (done) => { - ipfs.get(smallFile.cid, { compress: true, 'compression-level': 1 }, done) + ipfsd.api.get(smallFile.cid, { compress: true, 'compression-level': 1 }, done) }) it('add path containing "+"s (for testing get)', (done) => { @@ -83,7 +82,7 @@ describe('.get (specific go-ipfs features)', function () { const filename = 'ti,c64x+mega++mod-pic.txt' const subdir = 'tmp/c++files' const expectedCid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff' - ipfs.add([{ + ipfsd.api.add([{ path: subdir + '/' + filename, content: Buffer.from(subdir + '/' + filename, 'utf-8') }], (err, files) => { @@ -98,7 +97,7 @@ describe('.get (specific go-ipfs features)', function () { const cid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff' let count = 0 - ipfs.get(cid, (err, files) => { + ipfsd.api.get(cid, (err, files) => { expect(err).to.not.exist() files.forEach((file) => { if (file.path !== cid) { diff --git a/test/interface/block.spec.js b/test/interface/block.spec.js index ce96664dc..76a305720 100644 --- a/test/interface/block.spec.js +++ b/test/interface/block.spec.js @@ -3,17 +3,13 @@ 'use strict' const test = require('interface-ipfs-core') -const Factory = require('../ipfs-factory/client') -let factory +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const common = { setup: function (callback) { - factory = new Factory() - callback(null, factory) - }, - teardown: function (callback) { - factory.dismantle(callback) + callback(null, df) } } diff --git a/test/interface/config.spec.js b/test/interface/config.spec.js index 0527c954e..64305131e 100644 --- a/test/interface/config.spec.js +++ b/test/interface/config.spec.js @@ -3,17 +3,13 @@ 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('../ipfs-factory/client') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) - }, - teardown: function (callback) { - fc.dismantle(callback) + callback(null, df) } } diff --git a/test/interface/dht.spec.js b/test/interface/dht.spec.js index b1e731e77..202aa4dd6 100644 --- a/test/interface/dht.spec.js +++ b/test/interface/dht.spec.js @@ -2,17 +2,13 @@ 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('../ipfs-factory/client') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) - }, - teardown: function (callback) { - fc.dismantle(callback) + callback(null, df) } } diff --git a/test/interface/files.spec.js b/test/interface/files.spec.js index 8170ce597..9bf84fe25 100644 --- a/test/interface/files.spec.js +++ b/test/interface/files.spec.js @@ -4,17 +4,12 @@ const test = require('interface-ipfs-core') -const FactoryClient = require('../ipfs-factory/client') - -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) - }, - teardown: function (callback) { - fc.dismantle(callback) + callback(null, df) } } diff --git a/test/interface/generic.spec.js b/test/interface/generic.spec.js index 2e4403c60..69d1f579d 100644 --- a/test/interface/generic.spec.js +++ b/test/interface/generic.spec.js @@ -3,17 +3,13 @@ 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('../ipfs-factory/client') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) - }, - teardown: function (callback) { - fc.dismantle(callback) + callback(null, df) } } diff --git a/test/interface/key.spec.js b/test/interface/key.spec.js index 1f285895d..b7c8f2985 100644 --- a/test/interface/key.spec.js +++ b/test/interface/key.spec.js @@ -3,17 +3,13 @@ 'use strict' const test = require('interface-ipfs-core') -const Factory = require('../ipfs-factory/client') -let factory +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const common = { setup: function (callback) { - factory = new Factory() - callback(null, factory) - }, - teardown: function (callback) { - factory.dismantle(callback) + callback(null, df) } } diff --git a/test/interface/object.spec.js b/test/interface/object.spec.js index ea127d09c..affa0d6ae 100644 --- a/test/interface/object.spec.js +++ b/test/interface/object.spec.js @@ -3,17 +3,13 @@ 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('../ipfs-factory/client') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) - }, - teardown: function (callback) { - fc.dismantle(callback) + callback(null, df) } } diff --git a/test/interface/pin.spec.js b/test/interface/pin.spec.js index b841568ac..d434dba77 100644 --- a/test/interface/pin.spec.js +++ b/test/interface/pin.spec.js @@ -3,17 +3,13 @@ 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('../ipfs-factory/client') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) - }, - teardown: function (callback) { - fc.dismantle(callback) + callback(null, df) } } diff --git a/test/interface/pubsub.spec.js b/test/interface/pubsub.spec.js index 5448ccc97..0eeb0714f 100644 --- a/test/interface/pubsub.spec.js +++ b/test/interface/pubsub.spec.js @@ -3,19 +3,15 @@ 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('../ipfs-factory/client') const isNode = require('detect-node') -if (isNode) { - let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() +if (isNode) { const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) - }, - teardown: function (callback) { - fc.dismantle(callback) + callback(null, df) } } diff --git a/test/interface/swarm.spec.js b/test/interface/swarm.spec.js index 420f08543..ebbeaeb01 100644 --- a/test/interface/swarm.spec.js +++ b/test/interface/swarm.spec.js @@ -3,17 +3,13 @@ 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('../ipfs-factory/client') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) - }, - teardown: function (callback) { - fc.dismantle(callback) + callback(null, df) } } diff --git a/test/ipfs-factory/client.js b/test/ipfs-factory/client.js deleted file mode 100644 index a3df65e0e..000000000 --- a/test/ipfs-factory/client.js +++ /dev/null @@ -1,60 +0,0 @@ -'use strict' - -const io = require('socket.io-client') -const ipfsAPI = require('../../src') - -module.exports = Factory - -function Factory () { - if (!(this instanceof Factory)) { - return new Factory() - } - const sioOptions = { - transports: ['websocket'], - 'force new connection': true - } - const sioUrl = 'http://localhost:55155' - let sioConnected = false - let ioC - - this.spawnNode = (repoPath, config, callback) => { - if (typeof repoPath === 'function') { - callback = repoPath - repoPath = undefined - } - if (typeof config === 'function') { - callback = config - config = undefined - } - - if (sioConnected) { - spawnNode() - } else { - ioC = io.connect(sioUrl, sioOptions) - ioC.once('error', callback) - ioC.once('connect_error', callback) - ioC.once('connect', () => { - sioConnected = true - spawnNode() - }) - } - - function spawnNode () { - ioC.once('fc-node', (apiAddr) => { - const ipfs = ipfsAPI(apiAddr) - ipfs.apiAddr = apiAddr - callback(null, ipfs) - }) - ioC.emit('fs-spawn-node', repoPath, config) - } - } - - this.dismantle = function (callback) { - ioC.once('fc-nodes-shutdown', (err) => { - ioC.disconnect() - sioConnected = false - callback(err) - }) - ioC.emit('fs-dismantle') - } -} diff --git a/test/ipfs-factory/daemon-spawner.js b/test/ipfs-factory/daemon-spawner.js deleted file mode 100644 index 0d861c402..000000000 --- a/test/ipfs-factory/daemon-spawner.js +++ /dev/null @@ -1,90 +0,0 @@ -'use strict' - -const ipfsd = require('ipfsd-ctl') -const series = require('async/series') -const eachSeries = require('async/eachSeries') -const once = require('once') - -module.exports = Factory - -function Factory () { - if (!(this instanceof Factory)) { - return new Factory() - } - - let nodes = [] - - this.spawnNode = (repoPath, config, callback) => { - if (typeof repoPath === 'function') { - callback = repoPath - repoPath = undefined - } - if (typeof config === 'function') { - callback = config - config = undefined - } - - // TODO - // support custom repoPath - // support custom configs being passed - - spawnEphemeralNode((err, node) => { - if (err) { - return callback(err) - } - - nodes.push(node) - - callback(null, node.apiAddr) - }) - } - - this.dismantle = (callback) => { - eachSeries(nodes, (node, cb) => { - cb = once(cb) - node.stopDaemon(cb) - }, (err) => { - if (err) { - return callback(err) - } - - nodes = [] - - callback() - }) - } -} - -function spawnEphemeralNode (callback) { - ipfsd.disposable((err, node) => { - if (err) { - return callback(err) - } - - // Note: we have to set each config value - // independently since the config/replace endpoint - // doesn't work as expected - series([ - (cb) => { - const configValues = { - Bootstrap: [], - Discovery: {}, - 'API.HTTPHeaders.Access-Control-Allow-Origin': ['*'], - // This is not needed after all - // 'API.HTTPHeaders.Access-Control-Allow-Credentials': true, - 'API.HTTPHeaders.Access-Control-Allow-Methods': [ - 'PUT', - 'POST', - 'GET' - ] - } - - eachSeries(Object.keys(configValues), (configKey, cb) => { - const configVal = JSON.stringify(configValues[configKey]) - node.setConfig(configKey, configVal, cb) - }, cb) - }, - (cb) => node.startDaemon(['--enable-pubsub-experiment'], cb) - ], (err) => callback(err, node)) - }) -} diff --git a/test/ipfs-factory/server-routes.js b/test/ipfs-factory/server-routes.js deleted file mode 100644 index 31c60019a..000000000 --- a/test/ipfs-factory/server-routes.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict' - -const SocketIO = require('socket.io') -const DaemonSpawner = require('./daemon-spawner') - -module.exports = (http) => { - const io = new SocketIO(http.listener) - io.on('connection', handle) - io.on('error', (err) => this.emit('error', err)) - - const ds = new DaemonSpawner() - - function handle (socket) { - socket.on('fs-spawn-node', spawnNode.bind(socket)) - socket.on('fs-dismantle', dismantle.bind(socket)) - } - - function spawnNode (repoPath, config) { - ds.spawnNode(repoPath, config, (err, apiAddr) => { - if (err) { - return this.emit('error', err) - } - this.emit('fc-node', apiAddr.toString()) - }) - } - - function dismantle () { - ds.dismantle((err) => { - if (err) { - return this.emit('error', err) - } - this.emit('fc-nodes-shutdown') - }) - } -} diff --git a/test/ipfs-factory/server.js b/test/ipfs-factory/server.js deleted file mode 100644 index 9f4663334..000000000 --- a/test/ipfs-factory/server.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict' - -const Hapi = require('hapi') - -const port = Number(process.env.PORT) || 55155 -const options = { - connections: { - routes: { - cors: true - } - } -} - -module.exports = (callback) => { - const http = new Hapi.Server(options) - - http.connection({ port: port }) - - http.start((err) => { - if (err) { - return callback(err) - } - require('./server-routes')(http) - - callback(null, http) - // note: http.stop(callback) to stop the server :) - }) -} diff --git a/test/ipfs-factory/tasks.js b/test/ipfs-factory/tasks.js deleted file mode 100644 index eca18f8f3..000000000 --- a/test/ipfs-factory/tasks.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict' - -const factoryServer = require('./server') - -let factory - -module.exports = { - start (done) { - factoryServer((err, http) => { - if (err) { - return done(err) - } - factory = http - done() - }) - }, - stop (done) { - factory.stop({ - timeout: 1 - }, done) - } -} diff --git a/test/key.spec.js b/test/key.spec.js index f3bbaf7ef..b440b00e3 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -2,35 +2,33 @@ /* eslint max-nested-callbacks: ["error", 8] */ 'use strict' -const FactoryClient = require('./ipfs-factory/client') const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() + describe('.key', function () { this.timeout(50 * 1000) - let ipfs - let fc + let ipfsd before((done) => { - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => { - fc.dismantle(done) - }) + after((done) => ipfsd.stop(done)) describe('Callback API', () => { describe('.gen', () => { it('create a new rsa key', (done) => { - ipfs.key.gen('foobarsa', { type: 'rsa', size: 2048 }, (err, res) => { + ipfsd.api.key.gen('foobarsa', { type: 'rsa', size: 2048 }, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -38,7 +36,7 @@ describe('.key', function () { }) it('create a new ed25519 key', (done) => { - ipfs.key.gen('bazed', { type: 'ed25519' }, (err, res) => { + ipfsd.api.key.gen('bazed', { type: 'ed25519' }, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -48,7 +46,7 @@ describe('.key', function () { describe('.list', () => { it('both keys show up + self', (done) => { - ipfs.key.list((err, res) => { + ipfsd.api.key.list((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res.length).to.equal(3) @@ -61,13 +59,13 @@ describe('.key', function () { describe('Promise API', () => { describe('.gen', () => { it('create a new rsa key', () => { - return ipfs.key.gen('foobarsa2', {type: 'rsa', size: 2048}).then((res) => { + return ipfsd.api.key.gen('foobarsa2', { type: 'rsa', size: 2048 }).then((res) => { expect(res).to.exist() }) }) it('create a new ed25519 key', () => { - return ipfs.key.gen('bazed2', {type: 'ed25519'}).then((res) => { + return ipfsd.api.key.gen('bazed2', { type: 'ed25519' }).then((res) => { expect(res).to.exist() }) }) @@ -75,7 +73,7 @@ describe('.key', function () { describe('.list', () => { it('4 keys to show up + self', () => { - return ipfs.key.list().then((res) => { + return ipfsd.api.key.list().then((res) => { expect(res).to.exist() expect(res.length).to.equal(5) }) diff --git a/test/log.spec.js b/test/log.spec.js index 24d4fe11c..2d1d86e45 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -6,30 +6,30 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const FactoryClient = require('./ipfs-factory/client') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() describe('.log', function () { this.timeout(100 * 1000) - let ipfs - let fc + let ipfsd before((done) => { - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => fc.dismantle(done)) + after((done) => ipfsd.stop(done)) describe('Callback API', function () { this.timeout(100 * 1000) it('.log.tail', (done) => { - const req = ipfs.log.tail((err, res) => { + const req = ipfsd.api.log.tail((err, res) => { expect(err).to.not.exist() expect(req).to.exist() @@ -41,7 +41,7 @@ describe('.log', function () { }) it('.log.ls', (done) => { - ipfs.log.ls((err, res) => { + ipfsd.api.log.ls((err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -52,7 +52,7 @@ describe('.log', function () { }) it('.log.level', (done) => { - ipfs.log.level('all', 'error', (err, res) => { + ipfsd.api.log.level('all', 'error', (err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -69,7 +69,7 @@ describe('.log', function () { this.timeout(100 * 1000) it('.log.tail', () => { - return ipfs.log.tail() + return ipfsd.api.log.tail() .then((res) => { res.once('data', (obj) => { expect(obj).to.be.an('object') @@ -78,7 +78,7 @@ describe('.log', function () { }) it('.log.ls', () => { - return ipfs.log.ls() + return ipfsd.api.log.ls() .then((res) => { expect(res).to.exist() @@ -87,7 +87,7 @@ describe('.log', function () { }) it('.log.level', () => { - return ipfs.log.level('all', 'error') + return ipfsd.api.log.level('all', 'error') .then((res) => { expect(res).to.exist() diff --git a/test/name.spec.js b/test/name.spec.js index 4e2330e51..90f52d03b 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -5,10 +5,14 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) + +const parallel = require('async/parallel') const isNode = require('detect-node') const series = require('async/series') const loadFixture = require('aegir/fixtures') -const FactoryClient = require('./ipfs-factory/client') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() const testfile = isNode ? loadFixture(__dirname, '/fixtures/testfile.txt') @@ -17,38 +21,41 @@ const testfile = isNode describe('.name', function () { this.timeout(50 * 1000) - let ipfs + let ipfsd let other - let fc before((done) => { - fc = new FactoryClient() series([ (cb) => { - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node cb() }) }, (cb) => { - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() other = node cb() }) }, (cb) => { - ipfs.id((err, id) => { + ipfsd.api.id((err, id) => { expect(err).to.not.exist() const ma = id.addresses[0] - other.swarm.connect(ma, cb) + other.api.swarm.connect(ma, cb) }) } ], done) }) - after((done) => fc.dismantle(done)) + after((done) => { + parallel([ + (cb) => ipfsd.stop(cb), + (cb) => other.stop(cb) + ], done) + }) describe('Callback API', () => { let name @@ -56,7 +63,7 @@ describe('.name', function () { it('add file for testing', (done) => { const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - ipfs.files.add(testfile, (err, res) => { + ipfsd.api.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -67,7 +74,7 @@ describe('.name', function () { }) it('.name.publish', (done) => { - ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { + ipfsd.api.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { expect(err).to.not.exist() name = res expect(name).to.exist() @@ -76,7 +83,7 @@ describe('.name', function () { }) it('.name.resolve', (done) => { - ipfs.name.resolve(name.name, (err, res) => { + ipfsd.api.name.resolve(name.name, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.be.eql(name.value) @@ -89,7 +96,7 @@ describe('.name', function () { let name it('.name.publish', () => { - return ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') + return ipfsd.api.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') .then((res) => { name = res expect(name).to.exist() @@ -97,7 +104,7 @@ describe('.name', function () { }) it('.name.resolve', () => { - return ipfs.name.resolve(name.name) + return ipfsd.api.name.resolve(name.name) .then((res) => { expect(res).to.exist() expect(res).to.be.eql(name.value) diff --git a/test/ping.spec.js b/test/ping.spec.js index af287431c..126d42746 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -6,51 +6,57 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const parallel = require('async/parallel') const series = require('async/series') -const FactoryClient = require('./ipfs-factory/client') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() describe.skip('.ping', () => { - let ipfs + let ipfsd let other - let fc before(function (done) { this.timeout(20 * 1000) // slow CI - fc = new FactoryClient() series([ (cb) => { - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node cb() }) }, (cb) => { console.log('going to spawn second node') - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() other = node cb() }) }, (cb) => { - ipfs.id((err, id) => { + ipfsd.api.id((err, id) => { expect(err).to.not.exist() const ma = id.addresses[0] - other.swarm.connect(ma, cb) + other.api.swarm.connect(ma, cb) }) } ], done) }) - after((done) => fc.dismantle(done)) + after((done) => { + parallel([ + (cb) => ipfsd.stop(cb), + (cb) => other.stop(cb) + ], done) + }) describe('callback API', () => { it('ping another peer', (done) => { other.id((err, id) => { expect(err).to.not.exist() - ipfs.ping(id.id, (err, res) => { + ipfsd.api.ping(id.id, (err, res) => { expect(err).to.not.exist() expect(res).to.have.a.property('Success') expect(res).to.have.a.property('Time') @@ -67,7 +73,7 @@ describe.skip('.ping', () => { it('ping another peer', () => { return other.id() .then((id) => { - return ipfs.ping(id.id) + return ipfsd.api.ping(id.id) }) .then((res) => { expect(res).to.have.a.property('Success') diff --git a/test/pubsub-in-browser.spec.js b/test/pubsub-in-browser.spec.js index b6efe9f5c..c20f7383c 100644 --- a/test/pubsub-in-browser.spec.js +++ b/test/pubsub-in-browser.spec.js @@ -26,29 +26,16 @@ /* eslint max-nested-callbacks: ['error', 8] */ 'use strict' -const series = require('async/series') -const waterfall = require('async/waterfall') const isNode = require('detect-node') -const FactoryClient = require('./ipfs-factory/client') const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const expectedError = 'pubsub is currently not supported when run in the browser' +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() -function spawnWithId (factory, callback) { - waterfall([ - (cb) => factory.spawnNode(cb), - (node, cb) => node.id((err, res) => { - if (err) { - return cb(err) - } - node.peerId = res - cb(null, node) - }) - ], callback) -} +const expectedError = 'pubsub is currently not supported when run in the browser' describe('.pubsub-browser (pubsub not supported in the browsers currently)', function () { this.timeout(50 * 1000) @@ -59,33 +46,23 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun } const topic = 'pubsub-tests' - let factory - let ipfs1 + let ipfsd before((done) => { - factory = new FactoryClient() - - series([ - (cb) => spawnWithId(factory, cb) - ], (err, nodes) => { - if (err) { - return done(err) - } - - ipfs1 = nodes[0] + df.spawn((err, node) => { + expect(err).to.not.exist() + ipfsd = node done() }) }) - after((done) => { - factory.dismantle(done) - }) + after((done) => ipfsd.stop(done)) describe('everything errors', () => { describe('Callback API', () => { describe('.publish', () => { it('throws an error if called in the browser', (done) => { - ipfs1.pubsub.publish(topic, 'hello friend', (err, topics) => { + ipfsd.api.pubsub.publish(topic, 'hello friend', (err, topics) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) done() @@ -96,7 +73,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.subscribe', () => { const handler = () => {} it('throws an error if called in the browser', (done) => { - ipfs1.pubsub.subscribe(topic, {}, handler, (err, topics) => { + ipfsd.api.pubsub.subscribe(topic, {}, handler, (err, topics) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) done() @@ -106,7 +83,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.peers', () => { it('throws an error if called in the browser', (done) => { - ipfs1.pubsub.peers(topic, (err, topics) => { + ipfsd.api.pubsub.peers(topic, (err, topics) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) done() @@ -116,7 +93,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.ls', () => { it('throws an error if called in the browser', (done) => { - ipfs1.pubsub.ls((err, topics) => { + ipfsd.api.pubsub.ls((err, topics) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) done() @@ -128,7 +105,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('Promise API', () => { describe('.publish', () => { it('throws an error if called in the browser', () => { - return ipfs1.pubsub.publish(topic, 'hello friend') + return ipfsd.api.pubsub.publish(topic, 'hello friend') .catch((err) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) @@ -139,7 +116,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.subscribe', () => { const handler = () => {} it('throws an error if called in the browser', (done) => { - ipfs1.pubsub.subscribe(topic, {}, handler) + ipfsd.api.pubsub.subscribe(topic, {}, handler) .catch((err) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) @@ -150,7 +127,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.peers', () => { it('throws an error if called in the browser', (done) => { - ipfs1.pubsub.peers(topic) + ipfsd.api.pubsub.peers(topic) .catch((err) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) @@ -161,7 +138,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.ls', () => { it('throws an error if called in the browser', () => { - return ipfs1.pubsub.ls() + return ipfsd.api.pubsub.ls() .catch((err) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) @@ -173,7 +150,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.unsubscribe', () => { it('throws an error if called in the browser', (done) => { try { - ipfs1.pubsub.unsubscribe() + ipfsd.api.pubsub.unsubscribe() done('unsubscribe() didn\'t throw an error') } catch (err) { expect(err).to.exist() diff --git a/test/refs.spec.js b/test/refs.spec.js index b004db6de..4f42e3408 100644 --- a/test/refs.spec.js +++ b/test/refs.spec.js @@ -8,20 +8,22 @@ chai.use(dirtyChai) const isNode = require('detect-node') const waterfall = require('async/waterfall') const path = require('path') -const FactoryClient = require('./ipfs-factory/client') const fs = require('fs') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() + describe('.refs', function () { this.timeout(80 * 1000) - if (!isNode) { return } + if (!isNode) { + return + } - let ipfs - let fc + let ipfsd let folder before((done) => { - fc = new FactoryClient() const filesPath = path.join(__dirname, '/fixtures/test-folder') // Symlinks in a repo don't always clone well, especially on Windows. @@ -34,10 +36,10 @@ describe('.refs', function () { } waterfall([ - (cb) => fc.spawnNode(cb), + (cb) => df.spawn(cb), (node, cb) => { - ipfs = node - ipfs.util.addFromFs(filesPath, { recursive: true }, cb) + ipfsd = node + ipfsd.api.util.addFromFs(filesPath, { recursive: true }, cb) }, (hashes, cb) => { folder = hashes[hashes.length - 1].hash @@ -47,7 +49,7 @@ describe('.refs', function () { ], done) }) - after((done) => fc.dismantle(done)) + after((done) => ipfsd.stop(done)) const result = [ { @@ -76,7 +78,7 @@ describe('.refs', function () { describe('Callback API', () => { it('refs', (done) => { - ipfs.refs(folder, { format: ' ' }, (err, objs) => { + ipfsd.api.refs(folder, { format: ' ' }, (err, objs) => { expect(err).to.not.exist() expect(objs).to.eql(result) done() @@ -86,7 +88,7 @@ describe('.refs', function () { describe('Promise API', () => { it('refs', () => { - return ipfs.refs(folder, {format: ' '}) + return ipfsd.api.refs(folder, { format: ' ' }) .then((objs) => { expect(objs).to.eql(result) }) diff --git a/test/repo.spec.js b/test/repo.spec.js index 0af2a0001..51f7651e5 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -1,34 +1,32 @@ /* eslint-env mocha */ 'use strict' -const FactoryClient = require('./ipfs-factory/client') const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() + describe('.repo', function () { this.timeout(50 * 1000) // slow CI - let ipfs - let fc + let ipfsd before((done) => { - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => { - fc.dismantle(done) - }) + after((done) => ipfsd.stop(done)) describe('Callback API', () => { it('.repo.gc', (done) => { - ipfs.repo.gc((err, res) => { + ipfsd.api.repo.gc((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -36,7 +34,7 @@ describe('.repo', function () { }) it('.repo.stat', (done) => { - ipfs.repo.stat((err, res) => { + ipfsd.api.repo.stat((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('NumObjects') @@ -48,11 +46,11 @@ describe('.repo', function () { describe('Promise API', () => { it('.repo.gc', () => { - return ipfs.repo.gc().then((res) => expect(res).to.exist()) + return ipfsd.api.repo.gc().then((res) => expect(res).to.exist()) }) it('.repo.stat', () => { - return ipfs.repo.stat() + return ipfsd.api.repo.stat() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('NumObjects') diff --git a/test/stats.spec.js b/test/stats.spec.js index 8775d88ed..d7d29de97 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -1,34 +1,32 @@ /* eslint-env mocha */ 'use strict' -const FactoryClient = require('./ipfs-factory/client') const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() + describe('stats', function () { this.timeout(50 * 1000) // slow CI - let ipfs - let fc + let ipfsd before((done) => { - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => { - fc.dismantle(done) - }) + after((done) => ipfsd.stop(done)) describe('Callback API', () => { it('.stats.bitswap', (done) => { - ipfs.stats.bitswap((err, res) => { + ipfsd.api.stats.bitswap((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('provideBufLen') @@ -45,7 +43,7 @@ describe('stats', function () { }) it('.stats.bw', (done) => { - ipfs.stats.bw((err, res) => { + ipfsd.api.stats.bw((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('totalIn') @@ -57,7 +55,7 @@ describe('stats', function () { }) it('.stats.repo', (done) => { - ipfs.stats.repo((err, res) => { + ipfsd.api.stats.repo((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('numObjects') @@ -72,7 +70,7 @@ describe('stats', function () { describe('Promise API', () => { it('.stats.bw', () => { - return ipfs.stats.bw() + return ipfsd.api.stats.bw() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('totalIn') @@ -83,7 +81,7 @@ describe('stats', function () { }) it('.stats.repo', () => { - return ipfs.stats.repo() + return ipfsd.api.stats.repo() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('numObjects') @@ -95,7 +93,7 @@ describe('stats', function () { }) it('.stats.bitswap', () => { - return ipfs.stats.bitswap() + return ipfsd.api.stats.bitswap() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('provideBufLen') diff --git a/test/util.spec.js b/test/util.spec.js index e0a43d7d0..3074ff750 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -9,33 +9,33 @@ chai.use(dirtyChai) const isNode = require('detect-node') const path = require('path') const fs = require('fs') -const FactoryClient = require('./ipfs-factory/client') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() describe('.util', () => { if (!isNode) { return } - let ipfs - let fc + let ipfsd before(function (done) { this.timeout(20 * 1000) // slow CI - fc = new FactoryClient() - fc.spawnNode((err, node) => { + df.spawn((err, node) => { expect(err).to.not.exist() - ipfs = node + ipfsd = node done() }) }) - after((done) => fc.dismantle(done)) + after((done) => ipfsd.stop(done)) it('.streamAdd', (done) => { const tfpath = path.join(__dirname, '/fixtures/testfile.txt') const rs = fs.createReadStream(tfpath) rs.path = '' // clean the path for testing purposes - ipfs.util.addFromStream(rs, (err, result) => { + ipfsd.api.util.addFromStream(rs, (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -45,7 +45,7 @@ describe('.util', () => { describe('.fsAdd should add', () => { it('a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => { + ipfsd.api.util.addFromFs(filesPath, { recursive: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(8) done() @@ -54,7 +54,7 @@ describe('.util', () => { it('a directory with an odd name', (done) => { const filesPath = path.join(__dirname, '/fixtures/weird name folder [v0]') - ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => { + ipfsd.api.util.addFromFs(filesPath, { recursive: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(8) done() @@ -63,7 +63,7 @@ describe('.util', () => { it('add and ignore a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfs.util.addFromFs(filesPath, { recursive: true, ignore: ['files/**'] }, (err, result) => { + ipfsd.api.util.addFromFs(filesPath, { recursive: true, ignore: ['files/**'] }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.below(9) done() @@ -72,7 +72,7 @@ describe('.util', () => { it('a file', (done) => { const filePath = path.join(__dirname, '/fixtures/testfile.txt') - ipfs.util.addFromFs(filePath, (err, result) => { + ipfsd.api.util.addFromFs(filePath, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.equal(1) expect(result[0].path).to.be.equal('testfile.txt') @@ -82,7 +82,7 @@ describe('.util', () => { it('a hidden file in a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfs.util.addFromFs(filesPath, { recursive: true, hidden: true }, (err, result) => { + ipfsd.api.util.addFromFs(filesPath, { recursive: true, hidden: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(10) expect(result.map(object => object.path)).to.include('test-folder/.hiddenTest.txt') @@ -95,7 +95,7 @@ describe('.util', () => { it('.urlAdd http', function (done) { this.timeout(20 * 1000) - ipfs.util.addFromURL('http://example.com/', (err, result) => { + ipfsd.api.util.addFromURL('http://example.com/', (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -103,7 +103,7 @@ describe('.util', () => { }) it('.urlAdd https', (done) => { - ipfs.util.addFromURL('https://example.com/', (err, result) => { + ipfsd.api.util.addFromURL('https://example.com/', (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -111,7 +111,7 @@ describe('.util', () => { }) it('.urlAdd http with redirection', (done) => { - ipfs.util.addFromURL('http://covers.openlibrary.org/book/id/969165.jpg', (err, result) => { + ipfsd.api.util.addFromURL('http://covers.openlibrary.org/book/id/969165.jpg', (err, result) => { expect(err).to.not.exist() expect(result[0].hash).to.equal('QmaL9zy7YUfvWmtD5ZXp42buP7P4xmZJWFkm78p8FJqgjg') done() From 1220843976603591de8c01112e6245125248370b Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 21 Dec 2017 13:04:30 -0600 Subject: [PATCH 02/14] fix: avoid too many changes --- test/bitswap.spec.js | 14 +++--- test/bootstrap.spec.js | 36 ++++++++-------- test/commands.spec.js | 6 ++- test/diag.spec.js | 14 +++--- test/files.spec.js | 78 +++++++++++++++++----------------- test/get.spec.js | 14 +++--- test/key.spec.js | 14 +++--- test/log.spec.js | 14 +++--- test/name.spec.js | 20 +++++---- test/ping.spec.js | 12 ++++-- test/pubsub-in-browser.spec.js | 20 +++++---- test/refs.spec.js | 6 ++- test/repo.spec.js | 10 +++-- test/stats.spec.js | 14 +++--- test/util.spec.js | 20 +++++---- 15 files changed, 163 insertions(+), 129 deletions(-) diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index 5e99e2a95..ef4c18f23 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -11,6 +11,7 @@ const df = DaemonFactory.create() describe('.bitswap', function () { this.timeout(20 * 1000) // slow CI + let ipfs let ipfsd = null before((done) => { @@ -18,6 +19,7 @@ describe('.bitswap', function () { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -26,7 +28,7 @@ describe('.bitswap', function () { describe('Callback API', () => { it('.wantlist', (done) => { - ipfsd.api.bitswap.wantlist((err, res) => { + ipfs.bitswap.wantlist((err, res) => { expect(err).to.not.exist() expect(res).to.have.to.be.eql({ Keys: null @@ -36,7 +38,7 @@ describe('.bitswap', function () { }) it('.stat', (done) => { - ipfsd.api.bitswap.stat((err, res) => { + ipfs.bitswap.stat((err, res) => { expect(err).to.not.exist() expect(res).to.have.property('BlocksReceived') expect(res).to.have.property('DupBlksReceived') @@ -51,7 +53,7 @@ describe('.bitswap', function () { it('.unwant', (done) => { const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - ipfsd.api.bitswap.unwant(key, (err) => { + ipfs.bitswap.unwant(key, (err) => { expect(err).to.not.exist() done() }) @@ -60,7 +62,7 @@ describe('.bitswap', function () { describe('Promise API', () => { it('.wantlist', () => { - return ipfsd.api.bitswap.wantlist() + return ipfs.bitswap.wantlist() .then((res) => { expect(res).to.have.to.be.eql({ Keys: null @@ -69,7 +71,7 @@ describe('.bitswap', function () { }) it('.stat', () => { - return ipfsd.api.bitswap.stat() + return ipfs.bitswap.stat() .then((res) => { expect(res).to.have.property('BlocksReceived') expect(res).to.have.property('DupBlksReceived') @@ -82,7 +84,7 @@ describe('.bitswap', function () { it('.unwant', () => { const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - return ipfsd.api.bitswap.unwant(key) + return ipfs.bitswap.unwant(key) }) }) }) diff --git a/test/bootstrap.spec.js b/test/bootstrap.spec.js index e5bc5986e..a0331ba8a 100644 --- a/test/bootstrap.spec.js +++ b/test/bootstrap.spec.js @@ -17,11 +17,13 @@ describe('.bootstrap', function () { this.timeout(100 * 1000) let ipfsd + let ipfs before((done) => { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -35,14 +37,14 @@ describe('.bootstrap', function () { describe('.add', () => { it('returns an error when called with an invalid arg', (done) => { - ipfsd.api.bootstrap.add(invalidArg, (err) => { + 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) => { - ipfsd.api.bootstrap.add(validIp4, (err, res) => { + ipfs.bootstrap.add(validIp4, (err, res) => { expect(err).to.not.exist() expect(res).to.be.eql({ Peers: [validIp4] }) peers = res.Peers @@ -53,7 +55,7 @@ describe('.bootstrap', function () { }) it('returns a list of bootstrap peers when called with the default option', (done) => { - ipfsd.api.bootstrap.add({ default: true }, (err, res) => { + ipfs.bootstrap.add({ default: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -65,7 +67,7 @@ describe('.bootstrap', function () { describe('.list', () => { it('returns a list of peers', (done) => { - ipfsd.api.bootstrap.list((err, res) => { + ipfs.bootstrap.list((err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -76,14 +78,14 @@ describe('.bootstrap', function () { describe('.rm', () => { it('returns an error when called with an invalid arg', (done) => { - ipfsd.api.bootstrap.rm(invalidArg, (err) => { + 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) => { - ipfsd.api.bootstrap.rm(null, (err, res) => { + ipfs.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -93,7 +95,7 @@ describe('.bootstrap', function () { }) it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => { - ipfsd.api.bootstrap.rm(null, (err, res) => { + ipfs.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -103,7 +105,7 @@ describe('.bootstrap', function () { }) it('returns list of all peers removed when all option is passed', (done) => { - ipfsd.api.bootstrap.rm(null, { all: true }, (err, res) => { + ipfs.bootstrap.rm(null, { all: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -118,21 +120,21 @@ describe('.bootstrap', function () { describe('.add', () => { it('returns an error when called without args or options', () => { - return ipfsd.api.bootstrap.add(null) + return ipfs.bootstrap.add(null) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns an error when called with an invalid arg', () => { - return ipfsd.api.bootstrap.add(invalidArg) + return ipfs.bootstrap.add(invalidArg) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns a list of peers when called with a valid arg (ip4)', () => { - return ipfsd.api.bootstrap.add(validIp4) + return ipfs.bootstrap.add(validIp4) .then((res) => { expect(res).to.be.eql({ Peers: [validIp4] }) peers = res.Peers @@ -142,7 +144,7 @@ describe('.bootstrap', function () { }) it('returns a list of default peers when called with the default option', () => { - return ipfsd.api.bootstrap.add(null, { default: true }) + return ipfs.bootstrap.add(null, { default: true }) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -153,7 +155,7 @@ describe('.bootstrap', function () { describe('.list', () => { it('returns a list of peers', () => { - return ipfsd.api.bootstrap.list() + return ipfs.bootstrap.list() .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -163,14 +165,14 @@ describe('.bootstrap', function () { describe('.rm', () => { it('returns an error when called with an invalid arg', () => { - return ipfsd.api.bootstrap.rm(invalidArg) + return ipfs.bootstrap.rm(invalidArg) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns empty list when called without an arg or options', () => { - return ipfsd.api.bootstrap.rm(null) + return ipfs.bootstrap.rm(null) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -179,7 +181,7 @@ describe('.bootstrap', function () { }) it('returns list containing the peer removed when called with a valid arg (ip4)', () => { - return ipfsd.api.bootstrap.rm(null) + return ipfs.bootstrap.rm(null) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -188,7 +190,7 @@ describe('.bootstrap', function () { }) it('returns list of all peers removed when all option is passed', () => { - return ipfsd.api.bootstrap.rm(null, { all: true }) + return ipfs.bootstrap.rm(null, { all: true }) .then((res) => { peers = res.Peers expect(peers).to.exist() diff --git a/test/commands.spec.js b/test/commands.spec.js index e7f937f94..09e8db6e7 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -13,11 +13,13 @@ describe('.commands', function () { this.timeout(20 * 1000) let ipfsd + let ipfs before((done) => { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -25,7 +27,7 @@ describe('.commands', function () { after((done) => ipfsd.stop(done)) it('lists commands', (done) => { - ipfsd.api.commands((err, res) => { + ipfs.commands((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -34,7 +36,7 @@ describe('.commands', function () { describe('promise', () => { it('lists commands', () => { - return ipfsd.api.commands() + return ipfs.commands() .then((res) => { expect(res).to.exist() }) diff --git a/test/diag.spec.js b/test/diag.spec.js index b5731733d..f862693c5 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -19,11 +19,13 @@ describe('.diag', function () { } let ipfsd + let ipfs before((done) => { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -33,7 +35,7 @@ describe('.diag', function () { describe('Callback API', () => { // Disabled in go-ipfs 0.4.10 it.skip('.diag.net', (done) => { - ipfsd.api.diag.net((err, res) => { + ipfs.diag.net((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -41,7 +43,7 @@ describe('.diag', function () { }) it('.diag.sys', (done) => { - ipfsd.api.diag.sys((err, res) => { + ipfs.diag.sys((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('memory') @@ -51,7 +53,7 @@ describe('.diag', function () { }) it('.diag.cmds', (done) => { - ipfsd.api.diag.cmds((err, res) => { + ipfs.diag.cmds((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -62,12 +64,12 @@ describe('.diag', function () { describe('Promise API', () => { // Disabled in go-ipfs 0.4.10 it.skip('.diag.net', () => { - return ipfsd.api.diag.net() + return ipfs.diag.net() .then((res) => expect(res).to.exist()) }) it('.diag.sys', () => { - return ipfsd.api.diag.sys() + return ipfs.diag.sys() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('memory') @@ -76,7 +78,7 @@ describe('.diag', function () { }) it('.diag.cmds', () => { - return ipfsd.api.diag.cmds() + return ipfs.diag.cmds() .then((res) => expect(res).to.exist()) }) }) diff --git a/test/files.spec.js b/test/files.spec.js index 94536e51a..93ddb8a31 100644 --- a/test/files.spec.js +++ b/test/files.spec.js @@ -34,6 +34,7 @@ describe('.files (the MFS API part)', function () { this.timeout(120 * 1000) let ipfsd + let ipfs const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' @@ -41,6 +42,7 @@ describe('.files (the MFS API part)', function () { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -51,7 +53,7 @@ describe('.files (the MFS API part)', function () { this.timeout(120 * 1000) it('add file for testing', (done) => { - ipfsd.api.files.add(testfile, (err, res) => { + ipfs.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -79,7 +81,7 @@ describe('.files (the MFS API part)', function () { const expectedCid = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK' const options = { 'cid-version': 1, 'raw-leaves': false } - ipfsd.api.files.add(testfile, options, (err, res) => { + ipfs.files.add(testfile, options, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -90,7 +92,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add with options', (done) => { - ipfsd.api.files.add(testfile, { pin: false }, (err, res) => { + ipfs.files.add(testfile, { pin: false }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -109,7 +111,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - ipfsd.api.files.add([file], options, (err, res) => { + ipfs.files.add([file], options, (err, res) => { if (err) return done(err) expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -128,7 +130,7 @@ describe('.files (the MFS API part)', function () { progress = p } - ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -149,7 +151,7 @@ describe('.files (the MFS API part)', function () { } // TODO: needs to be using a big file - ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -170,7 +172,7 @@ describe('.files (the MFS API part)', function () { } // TODO: needs to be using a directory - ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -182,7 +184,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add without progress options', (done) => { - ipfsd.api.files.add(testfile, (err, res) => { + ipfs.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -199,7 +201,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - ipfsd.api.files.add([file], options, (err, res) => { + ipfs.files.add([file], options, (err, res) => { if (err) return done(err) expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -210,15 +212,15 @@ describe('.files (the MFS API part)', function () { }) it('files.mkdir', (done) => { - ipfsd.api.files.mkdir('/test-folder', done) + ipfs.files.mkdir('/test-folder', done) }) it('files.flush', (done) => { - ipfsd.api.files.flush('/', done) + ipfs.files.flush('/', done) }) it('files.cp', (done) => { - ipfsd.api.files.cp([ + ipfs.files.cp([ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', '/test-folder/test-file' ], (err) => { @@ -228,7 +230,7 @@ describe('.files (the MFS API part)', function () { }) it('files.ls', (done) => { - ipfsd.api.files.ls('/test-folder', (err, res) => { + ipfs.files.ls('/test-folder', (err, res) => { expect(err).to.not.exist() expect(res.Entries.length).to.equal(1) done() @@ -236,11 +238,11 @@ describe('.files (the MFS API part)', function () { }) it('files.write', (done) => { - ipfsd.api.files + ipfs.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), {create: true}, (err) => { expect(err).to.not.exist() - ipfsd.api.files.read('/test-folder/test-file-2.txt', (err, stream) => { + ipfs.files.read('/test-folder/test-file-2.txt', (err, stream) => { expect(err).to.not.exist() let buf = '' @@ -258,11 +260,11 @@ describe('.files (the MFS API part)', function () { }) it('files.write without options', (done) => { - ipfsd.api.files + ipfs.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), (err) => { expect(err).to.not.exist() - ipfsd.api.files.read('/test-folder/test-file-2.txt', (err, stream) => { + ipfs.files.read('/test-folder/test-file-2.txt', (err, stream) => { expect(err).to.not.exist() let buf = '' @@ -282,7 +284,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat', (done) => { - ipfsd.api.files.stat('/test-folder/test-file', (err, res) => { + ipfs.files.stat('/test-folder/test-file', (err, res) => { expect(err).to.not.exist() expect(res).to.deep.equal({ Hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', @@ -297,7 +299,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat file that does not exist()', (done) => { - ipfsd.api.files.stat('/test-folder/does-not-exist()', (err, res) => { + ipfs.files.stat('/test-folder/does-not-exist()', (err, res) => { expect(err).to.exist() if (err.code === 0) { return done() @@ -311,7 +313,7 @@ describe('.files (the MFS API part)', function () { return done() } - ipfsd.api.files.read('/test-folder/test-file', (err, stream) => { + ipfs.files.read('/test-folder/test-file', (err, stream) => { expect(err).to.not.exist() let buf = '' stream @@ -329,11 +331,11 @@ describe('.files (the MFS API part)', function () { }) it('files.rm without options', (done) => { - ipfsd.api.files.rm('/test-folder/test-file-2.txt', done) + ipfs.files.rm('/test-folder/test-file-2.txt', done) }) it('files.rm', (done) => { - ipfsd.api.files.rm('/test-folder', {recursive: true}, done) + ipfs.files.rm('/test-folder', {recursive: true}, done) }) }) @@ -341,7 +343,7 @@ describe('.files (the MFS API part)', function () { this.timeout(120 * 1000) it('files.add', () => { - return ipfsd.api.files.add(testfile) + return ipfs.files.add(testfile) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedMultihash) @@ -353,7 +355,7 @@ describe('.files (the MFS API part)', function () { const expectedHash = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK' const options = { 'cid-version': 1, 'raw-leaves': false } - return ipfsd.api.files.add(testfile, options) + return ipfs.files.add(testfile, options) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedHash) @@ -362,7 +364,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add with options', () => { - return ipfsd.api.files.add(testfile, { pin: false }) + return ipfs.files.add(testfile, { pin: false }) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedMultihash) @@ -379,7 +381,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - return ipfsd.api.files.add([file], options) + return ipfs.files.add([file], options) .then((res) => { expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -389,11 +391,11 @@ describe('.files (the MFS API part)', function () { }) it('files.mkdir', () => { - return ipfsd.api.files.mkdir('/test-folder') + return ipfs.files.mkdir('/test-folder') }) it('files.cp', () => { - return ipfsd.api.files + return ipfs.files .cp([ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', '/test-folder/test-file' @@ -401,17 +403,17 @@ describe('.files (the MFS API part)', function () { }) it('files.ls', () => { - return ipfsd.api.files.ls('/test-folder') + return ipfs.files.ls('/test-folder') .then((res) => { expect(res.Entries.length).to.equal(1) }) }) it('files.write', (done) => { - ipfsd.api.files + ipfs.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), {create: true}) .then(() => { - return ipfsd.api.files.read('/test-folder/test-file-2.txt') + return ipfs.files.read('/test-folder/test-file-2.txt') }) .then((stream) => { let buf = '' @@ -431,10 +433,10 @@ describe('.files (the MFS API part)', function () { }) it('files.write without options', (done) => { - ipfsd.api.files + ipfs.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world')) .then(() => { - return ipfsd.api.files.read('/test-folder/test-file-2.txt') + return ipfs.files.read('/test-folder/test-file-2.txt') }) .then((stream) => { let buf = '' @@ -454,7 +456,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat', () => { - return ipfsd.api.files.stat('/test-folder/test-file') + return ipfs.files.stat('/test-folder/test-file') .then((res) => { expect(res).to.deep.equal({ Hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', @@ -467,7 +469,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat file that does not exist()', () => { - return ipfsd.api.files.stat('/test-folder/does-not-exist()') + return ipfs.files.stat('/test-folder/does-not-exist()') .catch((err) => { expect(err).to.exist() expect(err.code).to.be.eql(0) @@ -477,7 +479,7 @@ describe('.files (the MFS API part)', function () { it('files.read', (done) => { if (!isNode) { return done() } - ipfsd.api.files.read('/test-folder/test-file') + ipfs.files.read('/test-folder/test-file') .then((stream) => { let buf = '' stream @@ -495,11 +497,11 @@ describe('.files (the MFS API part)', function () { }) it('files.rm without options', () => { - return ipfsd.api.files.rm('/test-folder/test-file-2.txt') + return ipfs.files.rm('/test-folder/test-file-2.txt') }) it('files.rm', () => { - return ipfsd.api.files.rm('/test-folder', { recursive: true }) + return ipfs.files.rm('/test-folder', { recursive: true }) }) }) }) diff --git a/test/get.spec.js b/test/get.spec.js index 7c21659ee..4231a8c72 100644 --- a/test/get.spec.js +++ b/test/get.spec.js @@ -27,12 +27,14 @@ describe('.get (specific go-ipfs features)', function () { } let ipfsd + let ipfs before((done) => { series([ (cb) => df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api cb() }), (cb) => ipfsd.api.files.add(smallFile.data, cb) @@ -42,7 +44,7 @@ describe('.get (specific go-ipfs features)', function () { after((done) => ipfsd.stop(done)) it('no compression args', (done) => { - ipfsd.api.get(smallFile.cid, (err, files) => { + ipfs.get(smallFile.cid, (err, files) => { expect(err).to.not.exist() expect(files).to.be.length(1) @@ -52,7 +54,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('archive true', (done) => { - ipfsd.api.get(smallFile.cid, { archive: true }, (err, files) => { + ipfs.get(smallFile.cid, { archive: true }, (err, files) => { expect(err).to.not.exist() expect(files).to.be.length(1) @@ -62,7 +64,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('err with out of range compression level', (done) => { - ipfsd.api.get(smallFile.cid, { + ipfs.get(smallFile.cid, { compress: true, 'compression-level': 10 }, (err, files) => { @@ -73,7 +75,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('with compression level', (done) => { - ipfsd.api.get(smallFile.cid, { compress: true, 'compression-level': 1 }, done) + ipfs.get(smallFile.cid, { compress: true, 'compression-level': 1 }, done) }) it('add path containing "+"s (for testing get)', (done) => { @@ -82,7 +84,7 @@ describe('.get (specific go-ipfs features)', function () { const filename = 'ti,c64x+mega++mod-pic.txt' const subdir = 'tmp/c++files' const expectedCid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff' - ipfsd.api.add([{ + ipfs.add([{ path: subdir + '/' + filename, content: Buffer.from(subdir + '/' + filename, 'utf-8') }], (err, files) => { @@ -97,7 +99,7 @@ describe('.get (specific go-ipfs features)', function () { const cid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff' let count = 0 - ipfsd.api.get(cid, (err, files) => { + ipfs.get(cid, (err, files) => { expect(err).to.not.exist() files.forEach((file) => { if (file.path !== cid) { diff --git a/test/key.spec.js b/test/key.spec.js index b440b00e3..652dd76c8 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -14,11 +14,13 @@ describe('.key', function () { this.timeout(50 * 1000) let ipfsd + let ipfs before((done) => { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -28,7 +30,7 @@ describe('.key', function () { describe('Callback API', () => { describe('.gen', () => { it('create a new rsa key', (done) => { - ipfsd.api.key.gen('foobarsa', { type: 'rsa', size: 2048 }, (err, res) => { + ipfs.key.gen('foobarsa', { type: 'rsa', size: 2048 }, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -36,7 +38,7 @@ describe('.key', function () { }) it('create a new ed25519 key', (done) => { - ipfsd.api.key.gen('bazed', { type: 'ed25519' }, (err, res) => { + ipfs.key.gen('bazed', { type: 'ed25519' }, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -46,7 +48,7 @@ describe('.key', function () { describe('.list', () => { it('both keys show up + self', (done) => { - ipfsd.api.key.list((err, res) => { + ipfs.key.list((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res.length).to.equal(3) @@ -59,13 +61,13 @@ describe('.key', function () { describe('Promise API', () => { describe('.gen', () => { it('create a new rsa key', () => { - return ipfsd.api.key.gen('foobarsa2', { type: 'rsa', size: 2048 }).then((res) => { + return ipfs.key.gen('foobarsa2', {type: 'rsa', size: 2048}).then((res) => { expect(res).to.exist() }) }) it('create a new ed25519 key', () => { - return ipfsd.api.key.gen('bazed2', { type: 'ed25519' }).then((res) => { + return ipfs.key.gen('bazed2', {type: 'ed25519'}).then((res) => { expect(res).to.exist() }) }) @@ -73,7 +75,7 @@ describe('.key', function () { describe('.list', () => { it('4 keys to show up + self', () => { - return ipfsd.api.key.list().then((res) => { + return ipfs.key.list().then((res) => { expect(res).to.exist() expect(res.length).to.equal(5) }) diff --git a/test/log.spec.js b/test/log.spec.js index 2d1d86e45..cdfb7f337 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -14,11 +14,13 @@ describe('.log', function () { this.timeout(100 * 1000) let ipfsd + let ipfs before((done) => { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -29,7 +31,7 @@ describe('.log', function () { this.timeout(100 * 1000) it('.log.tail', (done) => { - const req = ipfsd.api.log.tail((err, res) => { + const req = ipfs.log.tail((err, res) => { expect(err).to.not.exist() expect(req).to.exist() @@ -41,7 +43,7 @@ describe('.log', function () { }) it('.log.ls', (done) => { - ipfsd.api.log.ls((err, res) => { + ipfs.log.ls((err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -52,7 +54,7 @@ describe('.log', function () { }) it('.log.level', (done) => { - ipfsd.api.log.level('all', 'error', (err, res) => { + ipfs.log.level('all', 'error', (err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -69,7 +71,7 @@ describe('.log', function () { this.timeout(100 * 1000) it('.log.tail', () => { - return ipfsd.api.log.tail() + return ipfs.log.tail() .then((res) => { res.once('data', (obj) => { expect(obj).to.be.an('object') @@ -78,7 +80,7 @@ describe('.log', function () { }) it('.log.ls', () => { - return ipfsd.api.log.ls() + return ipfs.log.ls() .then((res) => { expect(res).to.exist() @@ -87,7 +89,7 @@ describe('.log', function () { }) it('.log.level', () => { - return ipfsd.api.log.level('all', 'error') + return ipfs.log.level('all', 'error') .then((res) => { expect(res).to.exist() diff --git a/test/name.spec.js b/test/name.spec.js index 90f52d03b..9ceb508ea 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -21,8 +21,10 @@ const testfile = isNode describe('.name', function () { this.timeout(50 * 1000) + let ipfs let ipfsd let other + let otherd before((done) => { series([ @@ -30,13 +32,15 @@ describe('.name', function () { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api cb() }) }, (cb) => { df.spawn((err, node) => { expect(err).to.not.exist() - other = node + other = node.api + otherd = node cb() }) }, @@ -44,7 +48,7 @@ describe('.name', function () { ipfsd.api.id((err, id) => { expect(err).to.not.exist() const ma = id.addresses[0] - other.api.swarm.connect(ma, cb) + other.swarm.connect(ma, cb) }) } ], done) @@ -53,7 +57,7 @@ describe('.name', function () { after((done) => { parallel([ (cb) => ipfsd.stop(cb), - (cb) => other.stop(cb) + (cb) => otherd.stop(cb) ], done) }) @@ -63,7 +67,7 @@ describe('.name', function () { it('add file for testing', (done) => { const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - ipfsd.api.files.add(testfile, (err, res) => { + ipfs.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -74,7 +78,7 @@ describe('.name', function () { }) it('.name.publish', (done) => { - ipfsd.api.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { + ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { expect(err).to.not.exist() name = res expect(name).to.exist() @@ -83,7 +87,7 @@ describe('.name', function () { }) it('.name.resolve', (done) => { - ipfsd.api.name.resolve(name.name, (err, res) => { + ipfs.name.resolve(name.name, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.be.eql(name.value) @@ -96,7 +100,7 @@ describe('.name', function () { let name it('.name.publish', () => { - return ipfsd.api.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') + return ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') .then((res) => { name = res expect(name).to.exist() @@ -104,7 +108,7 @@ describe('.name', function () { }) it('.name.resolve', () => { - return ipfsd.api.name.resolve(name.name) + return ipfs.name.resolve(name.name) .then((res) => { expect(res).to.exist() expect(res).to.be.eql(name.value) diff --git a/test/ping.spec.js b/test/ping.spec.js index 126d42746..bee554e48 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -13,8 +13,10 @@ const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() describe.skip('.ping', () => { + let ipfs let ipfsd let other + let otherd before(function (done) { this.timeout(20 * 1000) // slow CI @@ -23,6 +25,7 @@ describe.skip('.ping', () => { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api cb() }) }, @@ -30,7 +33,8 @@ describe.skip('.ping', () => { console.log('going to spawn second node') df.spawn((err, node) => { expect(err).to.not.exist() - other = node + other = node.api + otherd = node cb() }) }, @@ -47,7 +51,7 @@ describe.skip('.ping', () => { after((done) => { parallel([ (cb) => ipfsd.stop(cb), - (cb) => other.stop(cb) + (cb) => otherd.stop(cb) ], done) }) @@ -56,7 +60,7 @@ describe.skip('.ping', () => { other.id((err, id) => { expect(err).to.not.exist() - ipfsd.api.ping(id.id, (err, res) => { + ipfs.ping(id.id, (err, res) => { expect(err).to.not.exist() expect(res).to.have.a.property('Success') expect(res).to.have.a.property('Time') @@ -73,7 +77,7 @@ describe.skip('.ping', () => { it('ping another peer', () => { return other.id() .then((id) => { - return ipfsd.api.ping(id.id) + return ipfs.ping(id.id) }) .then((res) => { expect(res).to.have.a.property('Success') diff --git a/test/pubsub-in-browser.spec.js b/test/pubsub-in-browser.spec.js index c20f7383c..3e7dcc0f6 100644 --- a/test/pubsub-in-browser.spec.js +++ b/test/pubsub-in-browser.spec.js @@ -46,11 +46,13 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun } const topic = 'pubsub-tests' + let ipfs let ipfsd before((done) => { df.spawn((err, node) => { expect(err).to.not.exist() + ipfs = node.api ipfsd = node done() }) @@ -62,7 +64,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('Callback API', () => { describe('.publish', () => { it('throws an error if called in the browser', (done) => { - ipfsd.api.pubsub.publish(topic, 'hello friend', (err, topics) => { + ipfs.pubsub.publish(topic, 'hello friend', (err, topics) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) done() @@ -73,7 +75,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.subscribe', () => { const handler = () => {} it('throws an error if called in the browser', (done) => { - ipfsd.api.pubsub.subscribe(topic, {}, handler, (err, topics) => { + ipfs.pubsub.subscribe(topic, {}, handler, (err, topics) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) done() @@ -83,7 +85,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.peers', () => { it('throws an error if called in the browser', (done) => { - ipfsd.api.pubsub.peers(topic, (err, topics) => { + ipfs.pubsub.peers(topic, (err, topics) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) done() @@ -93,7 +95,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.ls', () => { it('throws an error if called in the browser', (done) => { - ipfsd.api.pubsub.ls((err, topics) => { + ipfs.pubsub.ls((err, topics) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) done() @@ -105,7 +107,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('Promise API', () => { describe('.publish', () => { it('throws an error if called in the browser', () => { - return ipfsd.api.pubsub.publish(topic, 'hello friend') + return ipfs.pubsub.publish(topic, 'hello friend') .catch((err) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) @@ -116,7 +118,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.subscribe', () => { const handler = () => {} it('throws an error if called in the browser', (done) => { - ipfsd.api.pubsub.subscribe(topic, {}, handler) + ipfs.pubsub.subscribe(topic, {}, handler) .catch((err) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) @@ -127,7 +129,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.peers', () => { it('throws an error if called in the browser', (done) => { - ipfsd.api.pubsub.peers(topic) + ipfs.pubsub.peers(topic) .catch((err) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) @@ -138,7 +140,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.ls', () => { it('throws an error if called in the browser', () => { - return ipfsd.api.pubsub.ls() + return ipfs.pubsub.ls() .catch((err) => { expect(err).to.exist() expect(err.message).to.equal(expectedError) @@ -150,7 +152,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun describe('.unsubscribe', () => { it('throws an error if called in the browser', (done) => { try { - ipfsd.api.pubsub.unsubscribe() + ipfs.pubsub.unsubscribe() done('unsubscribe() didn\'t throw an error') } catch (err) { expect(err).to.exist() diff --git a/test/refs.spec.js b/test/refs.spec.js index 4f42e3408..0b0a406cd 100644 --- a/test/refs.spec.js +++ b/test/refs.spec.js @@ -20,6 +20,7 @@ describe('.refs', function () { return } + let ipfs let ipfsd let folder @@ -39,6 +40,7 @@ describe('.refs', function () { (cb) => df.spawn(cb), (node, cb) => { ipfsd = node + ipfs = node.api ipfsd.api.util.addFromFs(filesPath, { recursive: true }, cb) }, (hashes, cb) => { @@ -78,7 +80,7 @@ describe('.refs', function () { describe('Callback API', () => { it('refs', (done) => { - ipfsd.api.refs(folder, { format: ' ' }, (err, objs) => { + ipfs.refs(folder, { format: ' ' }, (err, objs) => { expect(err).to.not.exist() expect(objs).to.eql(result) done() @@ -88,7 +90,7 @@ describe('.refs', function () { describe('Promise API', () => { it('refs', () => { - return ipfsd.api.refs(folder, { format: ' ' }) + return ipfs.refs(folder, {format: ' '}) .then((objs) => { expect(objs).to.eql(result) }) diff --git a/test/repo.spec.js b/test/repo.spec.js index 51f7651e5..aa044f606 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -12,12 +12,14 @@ const df = DaemonFactory.create() describe('.repo', function () { this.timeout(50 * 1000) // slow CI + let ipfs let ipfsd before((done) => { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -26,7 +28,7 @@ describe('.repo', function () { describe('Callback API', () => { it('.repo.gc', (done) => { - ipfsd.api.repo.gc((err, res) => { + ipfs.repo.gc((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -34,7 +36,7 @@ describe('.repo', function () { }) it('.repo.stat', (done) => { - ipfsd.api.repo.stat((err, res) => { + ipfs.repo.stat((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('NumObjects') @@ -46,11 +48,11 @@ describe('.repo', function () { describe('Promise API', () => { it('.repo.gc', () => { - return ipfsd.api.repo.gc().then((res) => expect(res).to.exist()) + return ipfs.repo.gc().then((res) => expect(res).to.exist()) }) it('.repo.stat', () => { - return ipfsd.api.repo.stat() + return ipfs.repo.stat() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('NumObjects') diff --git a/test/stats.spec.js b/test/stats.spec.js index d7d29de97..67bf6b360 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -12,12 +12,14 @@ const df = DaemonFactory.create() describe('stats', function () { this.timeout(50 * 1000) // slow CI + let ipfs let ipfsd before((done) => { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -26,7 +28,7 @@ describe('stats', function () { describe('Callback API', () => { it('.stats.bitswap', (done) => { - ipfsd.api.stats.bitswap((err, res) => { + ipfs.stats.bitswap((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('provideBufLen') @@ -43,7 +45,7 @@ describe('stats', function () { }) it('.stats.bw', (done) => { - ipfsd.api.stats.bw((err, res) => { + ipfs.stats.bw((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('totalIn') @@ -55,7 +57,7 @@ describe('stats', function () { }) it('.stats.repo', (done) => { - ipfsd.api.stats.repo((err, res) => { + ipfs.stats.repo((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('numObjects') @@ -70,7 +72,7 @@ describe('stats', function () { describe('Promise API', () => { it('.stats.bw', () => { - return ipfsd.api.stats.bw() + return ipfs.stats.bw() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('totalIn') @@ -81,7 +83,7 @@ describe('stats', function () { }) it('.stats.repo', () => { - return ipfsd.api.stats.repo() + return ipfs.stats.repo() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('numObjects') @@ -93,7 +95,7 @@ describe('stats', function () { }) it('.stats.bitswap', () => { - return ipfsd.api.stats.bitswap() + return ipfs.stats.bitswap() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('provideBufLen') diff --git a/test/util.spec.js b/test/util.spec.js index 3074ff750..184f3c15b 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -17,6 +17,7 @@ describe('.util', () => { if (!isNode) { return } let ipfsd + let ipfs before(function (done) { this.timeout(20 * 1000) // slow CI @@ -24,6 +25,7 @@ describe('.util', () => { df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node + ipfs = node.api done() }) }) @@ -35,7 +37,7 @@ describe('.util', () => { const rs = fs.createReadStream(tfpath) rs.path = '' // clean the path for testing purposes - ipfsd.api.util.addFromStream(rs, (err, result) => { + ipfs.util.addFromStream(rs, (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -45,7 +47,7 @@ describe('.util', () => { describe('.fsAdd should add', () => { it('a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfsd.api.util.addFromFs(filesPath, { recursive: true }, (err, result) => { + ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(8) done() @@ -54,7 +56,7 @@ describe('.util', () => { it('a directory with an odd name', (done) => { const filesPath = path.join(__dirname, '/fixtures/weird name folder [v0]') - ipfsd.api.util.addFromFs(filesPath, { recursive: true }, (err, result) => { + ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(8) done() @@ -63,7 +65,7 @@ describe('.util', () => { it('add and ignore a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfsd.api.util.addFromFs(filesPath, { recursive: true, ignore: ['files/**'] }, (err, result) => { + ipfs.util.addFromFs(filesPath, { recursive: true, ignore: ['files/**'] }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.below(9) done() @@ -72,7 +74,7 @@ describe('.util', () => { it('a file', (done) => { const filePath = path.join(__dirname, '/fixtures/testfile.txt') - ipfsd.api.util.addFromFs(filePath, (err, result) => { + ipfs.util.addFromFs(filePath, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.equal(1) expect(result[0].path).to.be.equal('testfile.txt') @@ -82,7 +84,7 @@ describe('.util', () => { it('a hidden file in a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfsd.api.util.addFromFs(filesPath, { recursive: true, hidden: true }, (err, result) => { + ipfs.util.addFromFs(filesPath, { recursive: true, hidden: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(10) expect(result.map(object => object.path)).to.include('test-folder/.hiddenTest.txt') @@ -95,7 +97,7 @@ describe('.util', () => { it('.urlAdd http', function (done) { this.timeout(20 * 1000) - ipfsd.api.util.addFromURL('http://example.com/', (err, result) => { + ipfs.util.addFromURL('http://example.com/', (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -103,7 +105,7 @@ describe('.util', () => { }) it('.urlAdd https', (done) => { - ipfsd.api.util.addFromURL('https://example.com/', (err, result) => { + ipfs.util.addFromURL('https://example.com/', (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -111,7 +113,7 @@ describe('.util', () => { }) it('.urlAdd http with redirection', (done) => { - ipfsd.api.util.addFromURL('http://covers.openlibrary.org/book/id/969165.jpg', (err, result) => { + ipfs.util.addFromURL('http://covers.openlibrary.org/book/id/969165.jpg', (err, result) => { expect(err).to.not.exist() expect(result[0].hash).to.equal('QmaL9zy7YUfvWmtD5ZXp42buP7P4xmZJWFkm78p8FJqgjg') done() From 00245690afeecab41c64657e95fd50b0fb8dc889 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 28 Dec 2017 16:17:42 -0600 Subject: [PATCH 03/14] chore: adding go-ipfs-dep --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index ab520573a..93efacc57 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "chai": "^4.1.2", "dirty-chai": "^2.0.1", "eslint-plugin-react": "^7.5.1", + "go-ipfs-dep": "^0.4.13", "gulp": "^3.9.1", "interface-ipfs-core": "~0.40.0", "hapi": "^16.6.2", From 3ce88a3fcee59f6b36687a239532fe0f147e9319 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 21 Dec 2017 02:54:55 -0600 Subject: [PATCH 04/14] feat: use new ipfsd-ctl --- test/bitswap.spec.js | 12 +++---- test/bootstrap.spec.js | 34 +++++++++---------- test/commands.spec.js | 4 +-- test/diag.spec.js | 12 +++---- test/files.spec.js | 76 +++++++++++++++++++++--------------------- test/get.spec.js | 12 +++---- test/key.spec.js | 12 +++---- test/log.spec.js | 12 +++---- test/name.spec.js | 12 +++---- test/ping.spec.js | 4 +-- test/refs.spec.js | 4 +-- test/repo.spec.js | 8 ++--- test/stats.spec.js | 12 +++---- test/util.spec.js | 18 +++++----- 14 files changed, 116 insertions(+), 116 deletions(-) diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index ef4c18f23..89ba07a73 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -28,7 +28,7 @@ describe('.bitswap', function () { describe('Callback API', () => { it('.wantlist', (done) => { - ipfs.bitswap.wantlist((err, res) => { + ipfsd.api.bitswap.wantlist((err, res) => { expect(err).to.not.exist() expect(res).to.have.to.be.eql({ Keys: null @@ -38,7 +38,7 @@ describe('.bitswap', function () { }) it('.stat', (done) => { - ipfs.bitswap.stat((err, res) => { + ipfsd.api.bitswap.stat((err, res) => { expect(err).to.not.exist() expect(res).to.have.property('BlocksReceived') expect(res).to.have.property('DupBlksReceived') @@ -53,7 +53,7 @@ describe('.bitswap', function () { it('.unwant', (done) => { const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - ipfs.bitswap.unwant(key, (err) => { + ipfsd.api.bitswap.unwant(key, (err) => { expect(err).to.not.exist() done() }) @@ -62,7 +62,7 @@ describe('.bitswap', function () { describe('Promise API', () => { it('.wantlist', () => { - return ipfs.bitswap.wantlist() + return ipfsd.api.bitswap.wantlist() .then((res) => { expect(res).to.have.to.be.eql({ Keys: null @@ -71,7 +71,7 @@ describe('.bitswap', function () { }) it('.stat', () => { - return ipfs.bitswap.stat() + return ipfsd.api.bitswap.stat() .then((res) => { expect(res).to.have.property('BlocksReceived') expect(res).to.have.property('DupBlksReceived') @@ -84,7 +84,7 @@ describe('.bitswap', function () { it('.unwant', () => { const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - return ipfs.bitswap.unwant(key) + return ipfsd.api.bitswap.unwant(key) }) }) }) diff --git a/test/bootstrap.spec.js b/test/bootstrap.spec.js index a0331ba8a..dd158886e 100644 --- a/test/bootstrap.spec.js +++ b/test/bootstrap.spec.js @@ -37,14 +37,14 @@ describe('.bootstrap', function () { describe('.add', () => { it('returns an error when called with an invalid arg', (done) => { - ipfs.bootstrap.add(invalidArg, (err) => { + ipfsd.api.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) => { + ipfsd.api.bootstrap.add(validIp4, (err, res) => { expect(err).to.not.exist() expect(res).to.be.eql({ Peers: [validIp4] }) peers = res.Peers @@ -55,7 +55,7 @@ describe('.bootstrap', function () { }) it('returns a list of bootstrap peers when called with the default option', (done) => { - ipfs.bootstrap.add({ default: true }, (err, res) => { + ipfsd.api.bootstrap.add({ default: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -67,7 +67,7 @@ describe('.bootstrap', function () { describe('.list', () => { it('returns a list of peers', (done) => { - ipfs.bootstrap.list((err, res) => { + ipfsd.api.bootstrap.list((err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -78,14 +78,14 @@ describe('.bootstrap', function () { describe('.rm', () => { it('returns an error when called with an invalid arg', (done) => { - ipfs.bootstrap.rm(invalidArg, (err) => { + ipfsd.api.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) => { + ipfsd.api.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -95,7 +95,7 @@ describe('.bootstrap', function () { }) it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => { - ipfs.bootstrap.rm(null, (err, res) => { + ipfsd.api.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -105,7 +105,7 @@ describe('.bootstrap', function () { }) it('returns list of all peers removed when all option is passed', (done) => { - ipfs.bootstrap.rm(null, { all: true }, (err, res) => { + ipfsd.api.bootstrap.rm(null, { all: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -120,21 +120,21 @@ describe('.bootstrap', function () { describe('.add', () => { it('returns an error when called without args or options', () => { - return ipfs.bootstrap.add(null) + return ipfsd.api.bootstrap.add(null) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns an error when called with an invalid arg', () => { - return ipfs.bootstrap.add(invalidArg) + return ipfsd.api.bootstrap.add(invalidArg) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns a list of peers when called with a valid arg (ip4)', () => { - return ipfs.bootstrap.add(validIp4) + return ipfsd.api.bootstrap.add(validIp4) .then((res) => { expect(res).to.be.eql({ Peers: [validIp4] }) peers = res.Peers @@ -144,7 +144,7 @@ describe('.bootstrap', function () { }) it('returns a list of default peers when called with the default option', () => { - return ipfs.bootstrap.add(null, { default: true }) + return ipfsd.api.bootstrap.add(null, { default: true }) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -155,7 +155,7 @@ describe('.bootstrap', function () { describe('.list', () => { it('returns a list of peers', () => { - return ipfs.bootstrap.list() + return ipfsd.api.bootstrap.list() .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -165,14 +165,14 @@ describe('.bootstrap', function () { describe('.rm', () => { it('returns an error when called with an invalid arg', () => { - return ipfs.bootstrap.rm(invalidArg) + return ipfsd.api.bootstrap.rm(invalidArg) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns empty list when called without an arg or options', () => { - return ipfs.bootstrap.rm(null) + return ipfsd.api.bootstrap.rm(null) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -181,7 +181,7 @@ describe('.bootstrap', function () { }) it('returns list containing the peer removed when called with a valid arg (ip4)', () => { - return ipfs.bootstrap.rm(null) + return ipfsd.api.bootstrap.rm(null) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -190,7 +190,7 @@ describe('.bootstrap', function () { }) it('returns list of all peers removed when all option is passed', () => { - return ipfs.bootstrap.rm(null, { all: true }) + return ipfsd.api.bootstrap.rm(null, { all: true }) .then((res) => { peers = res.Peers expect(peers).to.exist() diff --git a/test/commands.spec.js b/test/commands.spec.js index 09e8db6e7..ab82c6b34 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -27,7 +27,7 @@ describe('.commands', function () { after((done) => ipfsd.stop(done)) it('lists commands', (done) => { - ipfs.commands((err, res) => { + ipfsd.api.commands((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -36,7 +36,7 @@ describe('.commands', function () { describe('promise', () => { it('lists commands', () => { - return ipfs.commands() + return ipfsd.api.commands() .then((res) => { expect(res).to.exist() }) diff --git a/test/diag.spec.js b/test/diag.spec.js index f862693c5..5b5a8f017 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -35,7 +35,7 @@ describe('.diag', function () { describe('Callback API', () => { // Disabled in go-ipfs 0.4.10 it.skip('.diag.net', (done) => { - ipfs.diag.net((err, res) => { + ipfsd.api.diag.net((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -43,7 +43,7 @@ describe('.diag', function () { }) it('.diag.sys', (done) => { - ipfs.diag.sys((err, res) => { + ipfsd.api.diag.sys((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('memory') @@ -53,7 +53,7 @@ describe('.diag', function () { }) it('.diag.cmds', (done) => { - ipfs.diag.cmds((err, res) => { + ipfsd.api.diag.cmds((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -64,12 +64,12 @@ describe('.diag', function () { describe('Promise API', () => { // Disabled in go-ipfs 0.4.10 it.skip('.diag.net', () => { - return ipfs.diag.net() + return ipfsd.api.diag.net() .then((res) => expect(res).to.exist()) }) it('.diag.sys', () => { - return ipfs.diag.sys() + return ipfsd.api.diag.sys() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('memory') @@ -78,7 +78,7 @@ describe('.diag', function () { }) it('.diag.cmds', () => { - return ipfs.diag.cmds() + return ipfsd.api.diag.cmds() .then((res) => expect(res).to.exist()) }) }) diff --git a/test/files.spec.js b/test/files.spec.js index 93ddb8a31..a28016634 100644 --- a/test/files.spec.js +++ b/test/files.spec.js @@ -53,7 +53,7 @@ describe('.files (the MFS API part)', function () { this.timeout(120 * 1000) it('add file for testing', (done) => { - ipfs.files.add(testfile, (err, res) => { + ipfsd.api.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -81,7 +81,7 @@ describe('.files (the MFS API part)', function () { const expectedCid = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK' const options = { 'cid-version': 1, 'raw-leaves': false } - ipfs.files.add(testfile, options, (err, res) => { + ipfsd.api.files.add(testfile, options, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -92,7 +92,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add with options', (done) => { - ipfs.files.add(testfile, { pin: false }, (err, res) => { + ipfsd.api.files.add(testfile, { pin: false }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -111,7 +111,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - ipfs.files.add([file], options, (err, res) => { + ipfsd.api.files.add([file], options, (err, res) => { if (err) return done(err) expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -130,7 +130,7 @@ describe('.files (the MFS API part)', function () { progress = p } - ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -151,7 +151,7 @@ describe('.files (the MFS API part)', function () { } // TODO: needs to be using a big file - ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -172,7 +172,7 @@ describe('.files (the MFS API part)', function () { } // TODO: needs to be using a directory - ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -184,7 +184,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add without progress options', (done) => { - ipfs.files.add(testfile, (err, res) => { + ipfsd.api.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -201,7 +201,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - ipfs.files.add([file], options, (err, res) => { + ipfsd.api.files.add([file], options, (err, res) => { if (err) return done(err) expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -212,15 +212,15 @@ describe('.files (the MFS API part)', function () { }) it('files.mkdir', (done) => { - ipfs.files.mkdir('/test-folder', done) + ipfsd.api.files.mkdir('/test-folder', done) }) it('files.flush', (done) => { - ipfs.files.flush('/', done) + ipfsd.api.files.flush('/', done) }) it('files.cp', (done) => { - ipfs.files.cp([ + ipfsd.api.files.cp([ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', '/test-folder/test-file' ], (err) => { @@ -230,7 +230,7 @@ describe('.files (the MFS API part)', function () { }) it('files.ls', (done) => { - ipfs.files.ls('/test-folder', (err, res) => { + ipfsd.api.files.ls('/test-folder', (err, res) => { expect(err).to.not.exist() expect(res.Entries.length).to.equal(1) done() @@ -238,11 +238,11 @@ describe('.files (the MFS API part)', function () { }) it('files.write', (done) => { - ipfs.files + ipfsd.api.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), {create: true}, (err) => { expect(err).to.not.exist() - ipfs.files.read('/test-folder/test-file-2.txt', (err, stream) => { + ipfsd.api.files.read('/test-folder/test-file-2.txt', (err, stream) => { expect(err).to.not.exist() let buf = '' @@ -260,11 +260,11 @@ describe('.files (the MFS API part)', function () { }) it('files.write without options', (done) => { - ipfs.files + ipfsd.api.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), (err) => { expect(err).to.not.exist() - ipfs.files.read('/test-folder/test-file-2.txt', (err, stream) => { + ipfsd.api.files.read('/test-folder/test-file-2.txt', (err, stream) => { expect(err).to.not.exist() let buf = '' @@ -284,7 +284,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat', (done) => { - ipfs.files.stat('/test-folder/test-file', (err, res) => { + ipfsd.api.files.stat('/test-folder/test-file', (err, res) => { expect(err).to.not.exist() expect(res).to.deep.equal({ Hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', @@ -299,7 +299,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat file that does not exist()', (done) => { - ipfs.files.stat('/test-folder/does-not-exist()', (err, res) => { + ipfsd.api.files.stat('/test-folder/does-not-exist()', (err, res) => { expect(err).to.exist() if (err.code === 0) { return done() @@ -313,7 +313,7 @@ describe('.files (the MFS API part)', function () { return done() } - ipfs.files.read('/test-folder/test-file', (err, stream) => { + ipfsd.api.files.read('/test-folder/test-file', (err, stream) => { expect(err).to.not.exist() let buf = '' stream @@ -331,11 +331,11 @@ describe('.files (the MFS API part)', function () { }) it('files.rm without options', (done) => { - ipfs.files.rm('/test-folder/test-file-2.txt', done) + ipfsd.api.files.rm('/test-folder/test-file-2.txt', done) }) it('files.rm', (done) => { - ipfs.files.rm('/test-folder', {recursive: true}, done) + ipfsd.api.files.rm('/test-folder', {recursive: true}, done) }) }) @@ -343,7 +343,7 @@ describe('.files (the MFS API part)', function () { this.timeout(120 * 1000) it('files.add', () => { - return ipfs.files.add(testfile) + return ipfsd.api.files.add(testfile) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedMultihash) @@ -355,7 +355,7 @@ describe('.files (the MFS API part)', function () { const expectedHash = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK' const options = { 'cid-version': 1, 'raw-leaves': false } - return ipfs.files.add(testfile, options) + return ipfsd.api.files.add(testfile, options) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedHash) @@ -364,7 +364,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add with options', () => { - return ipfs.files.add(testfile, { pin: false }) + return ipfsd.api.files.add(testfile, { pin: false }) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedMultihash) @@ -381,7 +381,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - return ipfs.files.add([file], options) + return ipfsd.api.files.add([file], options) .then((res) => { expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -391,11 +391,11 @@ describe('.files (the MFS API part)', function () { }) it('files.mkdir', () => { - return ipfs.files.mkdir('/test-folder') + return ipfsd.api.files.mkdir('/test-folder') }) it('files.cp', () => { - return ipfs.files + return ipfsd.api.files .cp([ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', '/test-folder/test-file' @@ -403,17 +403,17 @@ describe('.files (the MFS API part)', function () { }) it('files.ls', () => { - return ipfs.files.ls('/test-folder') + return ipfsd.api.files.ls('/test-folder') .then((res) => { expect(res.Entries.length).to.equal(1) }) }) it('files.write', (done) => { - ipfs.files + ipfsd.api.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), {create: true}) .then(() => { - return ipfs.files.read('/test-folder/test-file-2.txt') + return ipfsd.api.files.read('/test-folder/test-file-2.txt') }) .then((stream) => { let buf = '' @@ -433,10 +433,10 @@ describe('.files (the MFS API part)', function () { }) it('files.write without options', (done) => { - ipfs.files + ipfsd.api.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world')) .then(() => { - return ipfs.files.read('/test-folder/test-file-2.txt') + return ipfsd.api.files.read('/test-folder/test-file-2.txt') }) .then((stream) => { let buf = '' @@ -456,7 +456,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat', () => { - return ipfs.files.stat('/test-folder/test-file') + return ipfsd.api.files.stat('/test-folder/test-file') .then((res) => { expect(res).to.deep.equal({ Hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', @@ -469,7 +469,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat file that does not exist()', () => { - return ipfs.files.stat('/test-folder/does-not-exist()') + return ipfsd.api.files.stat('/test-folder/does-not-exist()') .catch((err) => { expect(err).to.exist() expect(err.code).to.be.eql(0) @@ -479,7 +479,7 @@ describe('.files (the MFS API part)', function () { it('files.read', (done) => { if (!isNode) { return done() } - ipfs.files.read('/test-folder/test-file') + ipfsd.api.files.read('/test-folder/test-file') .then((stream) => { let buf = '' stream @@ -497,11 +497,11 @@ describe('.files (the MFS API part)', function () { }) it('files.rm without options', () => { - return ipfs.files.rm('/test-folder/test-file-2.txt') + return ipfsd.api.files.rm('/test-folder/test-file-2.txt') }) it('files.rm', () => { - return ipfs.files.rm('/test-folder', { recursive: true }) + return ipfsd.api.files.rm('/test-folder', { recursive: true }) }) }) }) diff --git a/test/get.spec.js b/test/get.spec.js index 4231a8c72..8bd1c9613 100644 --- a/test/get.spec.js +++ b/test/get.spec.js @@ -44,7 +44,7 @@ describe('.get (specific go-ipfs features)', function () { after((done) => ipfsd.stop(done)) it('no compression args', (done) => { - ipfs.get(smallFile.cid, (err, files) => { + ipfsd.api.get(smallFile.cid, (err, files) => { expect(err).to.not.exist() expect(files).to.be.length(1) @@ -54,7 +54,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('archive true', (done) => { - ipfs.get(smallFile.cid, { archive: true }, (err, files) => { + ipfsd.api.get(smallFile.cid, { archive: true }, (err, files) => { expect(err).to.not.exist() expect(files).to.be.length(1) @@ -64,7 +64,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('err with out of range compression level', (done) => { - ipfs.get(smallFile.cid, { + ipfsd.api.get(smallFile.cid, { compress: true, 'compression-level': 10 }, (err, files) => { @@ -75,7 +75,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('with compression level', (done) => { - ipfs.get(smallFile.cid, { compress: true, 'compression-level': 1 }, done) + ipfsd.api.get(smallFile.cid, { compress: true, 'compression-level': 1 }, done) }) it('add path containing "+"s (for testing get)', (done) => { @@ -84,7 +84,7 @@ describe('.get (specific go-ipfs features)', function () { const filename = 'ti,c64x+mega++mod-pic.txt' const subdir = 'tmp/c++files' const expectedCid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff' - ipfs.add([{ + ipfsd.api.add([{ path: subdir + '/' + filename, content: Buffer.from(subdir + '/' + filename, 'utf-8') }], (err, files) => { @@ -99,7 +99,7 @@ describe('.get (specific go-ipfs features)', function () { const cid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff' let count = 0 - ipfs.get(cid, (err, files) => { + ipfsd.api.get(cid, (err, files) => { expect(err).to.not.exist() files.forEach((file) => { if (file.path !== cid) { diff --git a/test/key.spec.js b/test/key.spec.js index 652dd76c8..4c275c6b0 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -30,7 +30,7 @@ describe('.key', function () { describe('Callback API', () => { describe('.gen', () => { it('create a new rsa key', (done) => { - ipfs.key.gen('foobarsa', { type: 'rsa', size: 2048 }, (err, res) => { + ipfsd.api.key.gen('foobarsa', { type: 'rsa', size: 2048 }, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -38,7 +38,7 @@ describe('.key', function () { }) it('create a new ed25519 key', (done) => { - ipfs.key.gen('bazed', { type: 'ed25519' }, (err, res) => { + ipfsd.api.key.gen('bazed', { type: 'ed25519' }, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -48,7 +48,7 @@ describe('.key', function () { describe('.list', () => { it('both keys show up + self', (done) => { - ipfs.key.list((err, res) => { + ipfsd.api.key.list((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res.length).to.equal(3) @@ -61,13 +61,13 @@ describe('.key', function () { describe('Promise API', () => { describe('.gen', () => { it('create a new rsa key', () => { - return ipfs.key.gen('foobarsa2', {type: 'rsa', size: 2048}).then((res) => { + return ipfsd.api.key.gen('foobarsa2', { type: 'rsa', size: 2048 }).then((res) => { expect(res).to.exist() }) }) it('create a new ed25519 key', () => { - return ipfs.key.gen('bazed2', {type: 'ed25519'}).then((res) => { + return ipfsd.api.key.gen('bazed2', { type: 'ed25519' }).then((res) => { expect(res).to.exist() }) }) @@ -75,7 +75,7 @@ describe('.key', function () { describe('.list', () => { it('4 keys to show up + self', () => { - return ipfs.key.list().then((res) => { + return ipfsd.api.key.list().then((res) => { expect(res).to.exist() expect(res.length).to.equal(5) }) diff --git a/test/log.spec.js b/test/log.spec.js index cdfb7f337..0a1902cc4 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -31,7 +31,7 @@ describe('.log', function () { this.timeout(100 * 1000) it('.log.tail', (done) => { - const req = ipfs.log.tail((err, res) => { + const req = ipfsd.api.log.tail((err, res) => { expect(err).to.not.exist() expect(req).to.exist() @@ -43,7 +43,7 @@ describe('.log', function () { }) it('.log.ls', (done) => { - ipfs.log.ls((err, res) => { + ipfsd.api.log.ls((err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -54,7 +54,7 @@ describe('.log', function () { }) it('.log.level', (done) => { - ipfs.log.level('all', 'error', (err, res) => { + ipfsd.api.log.level('all', 'error', (err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -71,7 +71,7 @@ describe('.log', function () { this.timeout(100 * 1000) it('.log.tail', () => { - return ipfs.log.tail() + return ipfsd.api.log.tail() .then((res) => { res.once('data', (obj) => { expect(obj).to.be.an('object') @@ -80,7 +80,7 @@ describe('.log', function () { }) it('.log.ls', () => { - return ipfs.log.ls() + return ipfsd.api.log.ls() .then((res) => { expect(res).to.exist() @@ -89,7 +89,7 @@ describe('.log', function () { }) it('.log.level', () => { - return ipfs.log.level('all', 'error') + return ipfsd.api.log.level('all', 'error') .then((res) => { expect(res).to.exist() diff --git a/test/name.spec.js b/test/name.spec.js index 9ceb508ea..159ca6351 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -48,7 +48,7 @@ describe('.name', function () { ipfsd.api.id((err, id) => { expect(err).to.not.exist() const ma = id.addresses[0] - other.swarm.connect(ma, cb) + other.api.swarm.connect(ma, cb) }) } ], done) @@ -67,7 +67,7 @@ describe('.name', function () { it('add file for testing', (done) => { const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - ipfs.files.add(testfile, (err, res) => { + ipfsd.api.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -78,7 +78,7 @@ describe('.name', function () { }) it('.name.publish', (done) => { - ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { + ipfsd.api.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { expect(err).to.not.exist() name = res expect(name).to.exist() @@ -87,7 +87,7 @@ describe('.name', function () { }) it('.name.resolve', (done) => { - ipfs.name.resolve(name.name, (err, res) => { + ipfsd.api.name.resolve(name.name, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.be.eql(name.value) @@ -100,7 +100,7 @@ describe('.name', function () { let name it('.name.publish', () => { - return ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') + return ipfsd.api.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') .then((res) => { name = res expect(name).to.exist() @@ -108,7 +108,7 @@ describe('.name', function () { }) it('.name.resolve', () => { - return ipfs.name.resolve(name.name) + return ipfsd.api.name.resolve(name.name) .then((res) => { expect(res).to.exist() expect(res).to.be.eql(name.value) diff --git a/test/ping.spec.js b/test/ping.spec.js index bee554e48..215ca0a96 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -60,7 +60,7 @@ describe.skip('.ping', () => { other.id((err, id) => { expect(err).to.not.exist() - ipfs.ping(id.id, (err, res) => { + ipfsd.api.ping(id.id, (err, res) => { expect(err).to.not.exist() expect(res).to.have.a.property('Success') expect(res).to.have.a.property('Time') @@ -77,7 +77,7 @@ describe.skip('.ping', () => { it('ping another peer', () => { return other.id() .then((id) => { - return ipfs.ping(id.id) + return ipfsd.api.ping(id.id) }) .then((res) => { expect(res).to.have.a.property('Success') diff --git a/test/refs.spec.js b/test/refs.spec.js index 0b0a406cd..0f7eebbff 100644 --- a/test/refs.spec.js +++ b/test/refs.spec.js @@ -80,7 +80,7 @@ describe('.refs', function () { describe('Callback API', () => { it('refs', (done) => { - ipfs.refs(folder, { format: ' ' }, (err, objs) => { + ipfsd.api.refs(folder, { format: ' ' }, (err, objs) => { expect(err).to.not.exist() expect(objs).to.eql(result) done() @@ -90,7 +90,7 @@ describe('.refs', function () { describe('Promise API', () => { it('refs', () => { - return ipfs.refs(folder, {format: ' '}) + return ipfsd.api.refs(folder, { format: ' ' }) .then((objs) => { expect(objs).to.eql(result) }) diff --git a/test/repo.spec.js b/test/repo.spec.js index aa044f606..17576cda8 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -28,7 +28,7 @@ describe('.repo', function () { describe('Callback API', () => { it('.repo.gc', (done) => { - ipfs.repo.gc((err, res) => { + ipfsd.api.repo.gc((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -36,7 +36,7 @@ describe('.repo', function () { }) it('.repo.stat', (done) => { - ipfs.repo.stat((err, res) => { + ipfsd.api.repo.stat((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('NumObjects') @@ -48,11 +48,11 @@ describe('.repo', function () { describe('Promise API', () => { it('.repo.gc', () => { - return ipfs.repo.gc().then((res) => expect(res).to.exist()) + return ipfsd.api.repo.gc().then((res) => expect(res).to.exist()) }) it('.repo.stat', () => { - return ipfs.repo.stat() + return ipfsd.api.repo.stat() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('NumObjects') diff --git a/test/stats.spec.js b/test/stats.spec.js index 67bf6b360..3f49eacfa 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -28,7 +28,7 @@ describe('stats', function () { describe('Callback API', () => { it('.stats.bitswap', (done) => { - ipfs.stats.bitswap((err, res) => { + ipfsd.api.stats.bitswap((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('provideBufLen') @@ -45,7 +45,7 @@ describe('stats', function () { }) it('.stats.bw', (done) => { - ipfs.stats.bw((err, res) => { + ipfsd.api.stats.bw((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('totalIn') @@ -57,7 +57,7 @@ describe('stats', function () { }) it('.stats.repo', (done) => { - ipfs.stats.repo((err, res) => { + ipfsd.api.stats.repo((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('numObjects') @@ -72,7 +72,7 @@ describe('stats', function () { describe('Promise API', () => { it('.stats.bw', () => { - return ipfs.stats.bw() + return ipfsd.api.stats.bw() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('totalIn') @@ -83,7 +83,7 @@ describe('stats', function () { }) it('.stats.repo', () => { - return ipfs.stats.repo() + return ipfsd.api.stats.repo() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('numObjects') @@ -95,7 +95,7 @@ describe('stats', function () { }) it('.stats.bitswap', () => { - return ipfs.stats.bitswap() + return ipfsd.api.stats.bitswap() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('provideBufLen') diff --git a/test/util.spec.js b/test/util.spec.js index 184f3c15b..352eeaf16 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -37,7 +37,7 @@ describe('.util', () => { const rs = fs.createReadStream(tfpath) rs.path = '' // clean the path for testing purposes - ipfs.util.addFromStream(rs, (err, result) => { + ipfsd.api.util.addFromStream(rs, (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -47,7 +47,7 @@ describe('.util', () => { describe('.fsAdd should add', () => { it('a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => { + ipfsd.api.util.addFromFs(filesPath, { recursive: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(8) done() @@ -56,7 +56,7 @@ describe('.util', () => { it('a directory with an odd name', (done) => { const filesPath = path.join(__dirname, '/fixtures/weird name folder [v0]') - ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => { + ipfsd.api.util.addFromFs(filesPath, { recursive: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(8) done() @@ -65,7 +65,7 @@ describe('.util', () => { it('add and ignore a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfs.util.addFromFs(filesPath, { recursive: true, ignore: ['files/**'] }, (err, result) => { + ipfsd.api.util.addFromFs(filesPath, { recursive: true, ignore: ['files/**'] }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.below(9) done() @@ -74,7 +74,7 @@ describe('.util', () => { it('a file', (done) => { const filePath = path.join(__dirname, '/fixtures/testfile.txt') - ipfs.util.addFromFs(filePath, (err, result) => { + ipfsd.api.util.addFromFs(filePath, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.equal(1) expect(result[0].path).to.be.equal('testfile.txt') @@ -84,7 +84,7 @@ describe('.util', () => { it('a hidden file in a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfs.util.addFromFs(filesPath, { recursive: true, hidden: true }, (err, result) => { + ipfsd.api.util.addFromFs(filesPath, { recursive: true, hidden: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(10) expect(result.map(object => object.path)).to.include('test-folder/.hiddenTest.txt') @@ -97,7 +97,7 @@ describe('.util', () => { it('.urlAdd http', function (done) { this.timeout(20 * 1000) - ipfs.util.addFromURL('http://example.com/', (err, result) => { + ipfsd.api.util.addFromURL('http://example.com/', (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -105,7 +105,7 @@ describe('.util', () => { }) it('.urlAdd https', (done) => { - ipfs.util.addFromURL('https://example.com/', (err, result) => { + ipfsd.api.util.addFromURL('https://example.com/', (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -113,7 +113,7 @@ describe('.util', () => { }) it('.urlAdd http with redirection', (done) => { - ipfs.util.addFromURL('http://covers.openlibrary.org/book/id/969165.jpg', (err, result) => { + ipfsd.api.util.addFromURL('http://covers.openlibrary.org/book/id/969165.jpg', (err, result) => { expect(err).to.not.exist() expect(result[0].hash).to.equal('QmaL9zy7YUfvWmtD5ZXp42buP7P4xmZJWFkm78p8FJqgjg') done() From 04eeff5a551b9d2ea7c0db240ab984dd0bf1981e Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 21 Dec 2017 13:04:30 -0600 Subject: [PATCH 05/14] fix: avoid too many changes --- test/bitswap.spec.js | 12 +++---- test/bootstrap.spec.js | 34 +++++++++---------- test/commands.spec.js | 4 +-- test/diag.spec.js | 12 +++---- test/files.spec.js | 76 +++++++++++++++++++++--------------------- test/get.spec.js | 12 +++---- test/key.spec.js | 12 +++---- test/log.spec.js | 12 +++---- test/name.spec.js | 12 +++---- test/ping.spec.js | 4 +-- test/refs.spec.js | 4 +-- test/repo.spec.js | 8 ++--- test/stats.spec.js | 12 +++---- test/util.spec.js | 18 +++++----- 14 files changed, 116 insertions(+), 116 deletions(-) diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index 89ba07a73..ef4c18f23 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -28,7 +28,7 @@ describe('.bitswap', function () { describe('Callback API', () => { it('.wantlist', (done) => { - ipfsd.api.bitswap.wantlist((err, res) => { + ipfs.bitswap.wantlist((err, res) => { expect(err).to.not.exist() expect(res).to.have.to.be.eql({ Keys: null @@ -38,7 +38,7 @@ describe('.bitswap', function () { }) it('.stat', (done) => { - ipfsd.api.bitswap.stat((err, res) => { + ipfs.bitswap.stat((err, res) => { expect(err).to.not.exist() expect(res).to.have.property('BlocksReceived') expect(res).to.have.property('DupBlksReceived') @@ -53,7 +53,7 @@ describe('.bitswap', function () { it('.unwant', (done) => { const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - ipfsd.api.bitswap.unwant(key, (err) => { + ipfs.bitswap.unwant(key, (err) => { expect(err).to.not.exist() done() }) @@ -62,7 +62,7 @@ describe('.bitswap', function () { describe('Promise API', () => { it('.wantlist', () => { - return ipfsd.api.bitswap.wantlist() + return ipfs.bitswap.wantlist() .then((res) => { expect(res).to.have.to.be.eql({ Keys: null @@ -71,7 +71,7 @@ describe('.bitswap', function () { }) it('.stat', () => { - return ipfsd.api.bitswap.stat() + return ipfs.bitswap.stat() .then((res) => { expect(res).to.have.property('BlocksReceived') expect(res).to.have.property('DupBlksReceived') @@ -84,7 +84,7 @@ describe('.bitswap', function () { it('.unwant', () => { const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - return ipfsd.api.bitswap.unwant(key) + return ipfs.bitswap.unwant(key) }) }) }) diff --git a/test/bootstrap.spec.js b/test/bootstrap.spec.js index dd158886e..a0331ba8a 100644 --- a/test/bootstrap.spec.js +++ b/test/bootstrap.spec.js @@ -37,14 +37,14 @@ describe('.bootstrap', function () { describe('.add', () => { it('returns an error when called with an invalid arg', (done) => { - ipfsd.api.bootstrap.add(invalidArg, (err) => { + 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) => { - ipfsd.api.bootstrap.add(validIp4, (err, res) => { + ipfs.bootstrap.add(validIp4, (err, res) => { expect(err).to.not.exist() expect(res).to.be.eql({ Peers: [validIp4] }) peers = res.Peers @@ -55,7 +55,7 @@ describe('.bootstrap', function () { }) it('returns a list of bootstrap peers when called with the default option', (done) => { - ipfsd.api.bootstrap.add({ default: true }, (err, res) => { + ipfs.bootstrap.add({ default: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -67,7 +67,7 @@ describe('.bootstrap', function () { describe('.list', () => { it('returns a list of peers', (done) => { - ipfsd.api.bootstrap.list((err, res) => { + ipfs.bootstrap.list((err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -78,14 +78,14 @@ describe('.bootstrap', function () { describe('.rm', () => { it('returns an error when called with an invalid arg', (done) => { - ipfsd.api.bootstrap.rm(invalidArg, (err) => { + 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) => { - ipfsd.api.bootstrap.rm(null, (err, res) => { + ipfs.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -95,7 +95,7 @@ describe('.bootstrap', function () { }) it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => { - ipfsd.api.bootstrap.rm(null, (err, res) => { + ipfs.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -105,7 +105,7 @@ describe('.bootstrap', function () { }) it('returns list of all peers removed when all option is passed', (done) => { - ipfsd.api.bootstrap.rm(null, { all: true }, (err, res) => { + ipfs.bootstrap.rm(null, { all: true }, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -120,21 +120,21 @@ describe('.bootstrap', function () { describe('.add', () => { it('returns an error when called without args or options', () => { - return ipfsd.api.bootstrap.add(null) + return ipfs.bootstrap.add(null) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns an error when called with an invalid arg', () => { - return ipfsd.api.bootstrap.add(invalidArg) + return ipfs.bootstrap.add(invalidArg) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns a list of peers when called with a valid arg (ip4)', () => { - return ipfsd.api.bootstrap.add(validIp4) + return ipfs.bootstrap.add(validIp4) .then((res) => { expect(res).to.be.eql({ Peers: [validIp4] }) peers = res.Peers @@ -144,7 +144,7 @@ describe('.bootstrap', function () { }) it('returns a list of default peers when called with the default option', () => { - return ipfsd.api.bootstrap.add(null, { default: true }) + return ipfs.bootstrap.add(null, { default: true }) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -155,7 +155,7 @@ describe('.bootstrap', function () { describe('.list', () => { it('returns a list of peers', () => { - return ipfsd.api.bootstrap.list() + return ipfs.bootstrap.list() .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -165,14 +165,14 @@ describe('.bootstrap', function () { describe('.rm', () => { it('returns an error when called with an invalid arg', () => { - return ipfsd.api.bootstrap.rm(invalidArg) + return ipfs.bootstrap.rm(invalidArg) .catch((err) => { expect(err).to.be.an.instanceof(Error) }) }) it('returns empty list when called without an arg or options', () => { - return ipfsd.api.bootstrap.rm(null) + return ipfs.bootstrap.rm(null) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -181,7 +181,7 @@ describe('.bootstrap', function () { }) it('returns list containing the peer removed when called with a valid arg (ip4)', () => { - return ipfsd.api.bootstrap.rm(null) + return ipfs.bootstrap.rm(null) .then((res) => { peers = res.Peers expect(peers).to.exist() @@ -190,7 +190,7 @@ describe('.bootstrap', function () { }) it('returns list of all peers removed when all option is passed', () => { - return ipfsd.api.bootstrap.rm(null, { all: true }) + return ipfs.bootstrap.rm(null, { all: true }) .then((res) => { peers = res.Peers expect(peers).to.exist() diff --git a/test/commands.spec.js b/test/commands.spec.js index ab82c6b34..09e8db6e7 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -27,7 +27,7 @@ describe('.commands', function () { after((done) => ipfsd.stop(done)) it('lists commands', (done) => { - ipfsd.api.commands((err, res) => { + ipfs.commands((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -36,7 +36,7 @@ describe('.commands', function () { describe('promise', () => { it('lists commands', () => { - return ipfsd.api.commands() + return ipfs.commands() .then((res) => { expect(res).to.exist() }) diff --git a/test/diag.spec.js b/test/diag.spec.js index 5b5a8f017..f862693c5 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -35,7 +35,7 @@ describe('.diag', function () { describe('Callback API', () => { // Disabled in go-ipfs 0.4.10 it.skip('.diag.net', (done) => { - ipfsd.api.diag.net((err, res) => { + ipfs.diag.net((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -43,7 +43,7 @@ describe('.diag', function () { }) it('.diag.sys', (done) => { - ipfsd.api.diag.sys((err, res) => { + ipfs.diag.sys((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('memory') @@ -53,7 +53,7 @@ describe('.diag', function () { }) it('.diag.cmds', (done) => { - ipfsd.api.diag.cmds((err, res) => { + ipfs.diag.cmds((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -64,12 +64,12 @@ describe('.diag', function () { describe('Promise API', () => { // Disabled in go-ipfs 0.4.10 it.skip('.diag.net', () => { - return ipfsd.api.diag.net() + return ipfs.diag.net() .then((res) => expect(res).to.exist()) }) it('.diag.sys', () => { - return ipfsd.api.diag.sys() + return ipfs.diag.sys() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('memory') @@ -78,7 +78,7 @@ describe('.diag', function () { }) it('.diag.cmds', () => { - return ipfsd.api.diag.cmds() + return ipfs.diag.cmds() .then((res) => expect(res).to.exist()) }) }) diff --git a/test/files.spec.js b/test/files.spec.js index a28016634..93ddb8a31 100644 --- a/test/files.spec.js +++ b/test/files.spec.js @@ -53,7 +53,7 @@ describe('.files (the MFS API part)', function () { this.timeout(120 * 1000) it('add file for testing', (done) => { - ipfsd.api.files.add(testfile, (err, res) => { + ipfs.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -81,7 +81,7 @@ describe('.files (the MFS API part)', function () { const expectedCid = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK' const options = { 'cid-version': 1, 'raw-leaves': false } - ipfsd.api.files.add(testfile, options, (err, res) => { + ipfs.files.add(testfile, options, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -92,7 +92,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add with options', (done) => { - ipfsd.api.files.add(testfile, { pin: false }, (err, res) => { + ipfs.files.add(testfile, { pin: false }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -111,7 +111,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - ipfsd.api.files.add([file], options, (err, res) => { + ipfs.files.add([file], options, (err, res) => { if (err) return done(err) expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -130,7 +130,7 @@ describe('.files (the MFS API part)', function () { progress = p } - ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -151,7 +151,7 @@ describe('.files (the MFS API part)', function () { } // TODO: needs to be using a big file - ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -172,7 +172,7 @@ describe('.files (the MFS API part)', function () { } // TODO: needs to be using a directory - ipfsd.api.files.add(testfile, { progress: progressHandler }, (err, res) => { + ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -184,7 +184,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add without progress options', (done) => { - ipfsd.api.files.add(testfile, (err, res) => { + ipfs.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -201,7 +201,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - ipfsd.api.files.add([file], options, (err, res) => { + ipfs.files.add([file], options, (err, res) => { if (err) return done(err) expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -212,15 +212,15 @@ describe('.files (the MFS API part)', function () { }) it('files.mkdir', (done) => { - ipfsd.api.files.mkdir('/test-folder', done) + ipfs.files.mkdir('/test-folder', done) }) it('files.flush', (done) => { - ipfsd.api.files.flush('/', done) + ipfs.files.flush('/', done) }) it('files.cp', (done) => { - ipfsd.api.files.cp([ + ipfs.files.cp([ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', '/test-folder/test-file' ], (err) => { @@ -230,7 +230,7 @@ describe('.files (the MFS API part)', function () { }) it('files.ls', (done) => { - ipfsd.api.files.ls('/test-folder', (err, res) => { + ipfs.files.ls('/test-folder', (err, res) => { expect(err).to.not.exist() expect(res.Entries.length).to.equal(1) done() @@ -238,11 +238,11 @@ describe('.files (the MFS API part)', function () { }) it('files.write', (done) => { - ipfsd.api.files + ipfs.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), {create: true}, (err) => { expect(err).to.not.exist() - ipfsd.api.files.read('/test-folder/test-file-2.txt', (err, stream) => { + ipfs.files.read('/test-folder/test-file-2.txt', (err, stream) => { expect(err).to.not.exist() let buf = '' @@ -260,11 +260,11 @@ describe('.files (the MFS API part)', function () { }) it('files.write without options', (done) => { - ipfsd.api.files + ipfs.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), (err) => { expect(err).to.not.exist() - ipfsd.api.files.read('/test-folder/test-file-2.txt', (err, stream) => { + ipfs.files.read('/test-folder/test-file-2.txt', (err, stream) => { expect(err).to.not.exist() let buf = '' @@ -284,7 +284,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat', (done) => { - ipfsd.api.files.stat('/test-folder/test-file', (err, res) => { + ipfs.files.stat('/test-folder/test-file', (err, res) => { expect(err).to.not.exist() expect(res).to.deep.equal({ Hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', @@ -299,7 +299,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat file that does not exist()', (done) => { - ipfsd.api.files.stat('/test-folder/does-not-exist()', (err, res) => { + ipfs.files.stat('/test-folder/does-not-exist()', (err, res) => { expect(err).to.exist() if (err.code === 0) { return done() @@ -313,7 +313,7 @@ describe('.files (the MFS API part)', function () { return done() } - ipfsd.api.files.read('/test-folder/test-file', (err, stream) => { + ipfs.files.read('/test-folder/test-file', (err, stream) => { expect(err).to.not.exist() let buf = '' stream @@ -331,11 +331,11 @@ describe('.files (the MFS API part)', function () { }) it('files.rm without options', (done) => { - ipfsd.api.files.rm('/test-folder/test-file-2.txt', done) + ipfs.files.rm('/test-folder/test-file-2.txt', done) }) it('files.rm', (done) => { - ipfsd.api.files.rm('/test-folder', {recursive: true}, done) + ipfs.files.rm('/test-folder', {recursive: true}, done) }) }) @@ -343,7 +343,7 @@ describe('.files (the MFS API part)', function () { this.timeout(120 * 1000) it('files.add', () => { - return ipfsd.api.files.add(testfile) + return ipfs.files.add(testfile) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedMultihash) @@ -355,7 +355,7 @@ describe('.files (the MFS API part)', function () { const expectedHash = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK' const options = { 'cid-version': 1, 'raw-leaves': false } - return ipfsd.api.files.add(testfile, options) + return ipfs.files.add(testfile, options) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedHash) @@ -364,7 +364,7 @@ describe('.files (the MFS API part)', function () { }) it('files.add with options', () => { - return ipfsd.api.files.add(testfile, { pin: false }) + return ipfs.files.add(testfile, { pin: false }) .then((res) => { expect(res).to.have.length(1) expect(res[0].hash).to.equal(expectedMultihash) @@ -381,7 +381,7 @@ describe('.files (the MFS API part)', function () { } const options = { hash: name, 'raw-leaves': false } - return ipfsd.api.files.add([file], options) + return ipfs.files.add([file], options) .then((res) => { expect(res).to.have.length(1) const cid = new CID(res[0].hash) @@ -391,11 +391,11 @@ describe('.files (the MFS API part)', function () { }) it('files.mkdir', () => { - return ipfsd.api.files.mkdir('/test-folder') + return ipfs.files.mkdir('/test-folder') }) it('files.cp', () => { - return ipfsd.api.files + return ipfs.files .cp([ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', '/test-folder/test-file' @@ -403,17 +403,17 @@ describe('.files (the MFS API part)', function () { }) it('files.ls', () => { - return ipfsd.api.files.ls('/test-folder') + return ipfs.files.ls('/test-folder') .then((res) => { expect(res.Entries.length).to.equal(1) }) }) it('files.write', (done) => { - ipfsd.api.files + ipfs.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world'), {create: true}) .then(() => { - return ipfsd.api.files.read('/test-folder/test-file-2.txt') + return ipfs.files.read('/test-folder/test-file-2.txt') }) .then((stream) => { let buf = '' @@ -433,10 +433,10 @@ describe('.files (the MFS API part)', function () { }) it('files.write without options', (done) => { - ipfsd.api.files + ipfs.files .write('/test-folder/test-file-2.txt', Buffer.from('hello world')) .then(() => { - return ipfsd.api.files.read('/test-folder/test-file-2.txt') + return ipfs.files.read('/test-folder/test-file-2.txt') }) .then((stream) => { let buf = '' @@ -456,7 +456,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat', () => { - return ipfsd.api.files.stat('/test-folder/test-file') + return ipfs.files.stat('/test-folder/test-file') .then((res) => { expect(res).to.deep.equal({ Hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', @@ -469,7 +469,7 @@ describe('.files (the MFS API part)', function () { }) it('files.stat file that does not exist()', () => { - return ipfsd.api.files.stat('/test-folder/does-not-exist()') + return ipfs.files.stat('/test-folder/does-not-exist()') .catch((err) => { expect(err).to.exist() expect(err.code).to.be.eql(0) @@ -479,7 +479,7 @@ describe('.files (the MFS API part)', function () { it('files.read', (done) => { if (!isNode) { return done() } - ipfsd.api.files.read('/test-folder/test-file') + ipfs.files.read('/test-folder/test-file') .then((stream) => { let buf = '' stream @@ -497,11 +497,11 @@ describe('.files (the MFS API part)', function () { }) it('files.rm without options', () => { - return ipfsd.api.files.rm('/test-folder/test-file-2.txt') + return ipfs.files.rm('/test-folder/test-file-2.txt') }) it('files.rm', () => { - return ipfsd.api.files.rm('/test-folder', { recursive: true }) + return ipfs.files.rm('/test-folder', { recursive: true }) }) }) }) diff --git a/test/get.spec.js b/test/get.spec.js index 8bd1c9613..4231a8c72 100644 --- a/test/get.spec.js +++ b/test/get.spec.js @@ -44,7 +44,7 @@ describe('.get (specific go-ipfs features)', function () { after((done) => ipfsd.stop(done)) it('no compression args', (done) => { - ipfsd.api.get(smallFile.cid, (err, files) => { + ipfs.get(smallFile.cid, (err, files) => { expect(err).to.not.exist() expect(files).to.be.length(1) @@ -54,7 +54,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('archive true', (done) => { - ipfsd.api.get(smallFile.cid, { archive: true }, (err, files) => { + ipfs.get(smallFile.cid, { archive: true }, (err, files) => { expect(err).to.not.exist() expect(files).to.be.length(1) @@ -64,7 +64,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('err with out of range compression level', (done) => { - ipfsd.api.get(smallFile.cid, { + ipfs.get(smallFile.cid, { compress: true, 'compression-level': 10 }, (err, files) => { @@ -75,7 +75,7 @@ describe('.get (specific go-ipfs features)', function () { }) it('with compression level', (done) => { - ipfsd.api.get(smallFile.cid, { compress: true, 'compression-level': 1 }, done) + ipfs.get(smallFile.cid, { compress: true, 'compression-level': 1 }, done) }) it('add path containing "+"s (for testing get)', (done) => { @@ -84,7 +84,7 @@ describe('.get (specific go-ipfs features)', function () { const filename = 'ti,c64x+mega++mod-pic.txt' const subdir = 'tmp/c++files' const expectedCid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff' - ipfsd.api.add([{ + ipfs.add([{ path: subdir + '/' + filename, content: Buffer.from(subdir + '/' + filename, 'utf-8') }], (err, files) => { @@ -99,7 +99,7 @@ describe('.get (specific go-ipfs features)', function () { const cid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff' let count = 0 - ipfsd.api.get(cid, (err, files) => { + ipfs.get(cid, (err, files) => { expect(err).to.not.exist() files.forEach((file) => { if (file.path !== cid) { diff --git a/test/key.spec.js b/test/key.spec.js index 4c275c6b0..652dd76c8 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -30,7 +30,7 @@ describe('.key', function () { describe('Callback API', () => { describe('.gen', () => { it('create a new rsa key', (done) => { - ipfsd.api.key.gen('foobarsa', { type: 'rsa', size: 2048 }, (err, res) => { + ipfs.key.gen('foobarsa', { type: 'rsa', size: 2048 }, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -38,7 +38,7 @@ describe('.key', function () { }) it('create a new ed25519 key', (done) => { - ipfsd.api.key.gen('bazed', { type: 'ed25519' }, (err, res) => { + ipfs.key.gen('bazed', { type: 'ed25519' }, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -48,7 +48,7 @@ describe('.key', function () { describe('.list', () => { it('both keys show up + self', (done) => { - ipfsd.api.key.list((err, res) => { + ipfs.key.list((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res.length).to.equal(3) @@ -61,13 +61,13 @@ describe('.key', function () { describe('Promise API', () => { describe('.gen', () => { it('create a new rsa key', () => { - return ipfsd.api.key.gen('foobarsa2', { type: 'rsa', size: 2048 }).then((res) => { + return ipfs.key.gen('foobarsa2', {type: 'rsa', size: 2048}).then((res) => { expect(res).to.exist() }) }) it('create a new ed25519 key', () => { - return ipfsd.api.key.gen('bazed2', { type: 'ed25519' }).then((res) => { + return ipfs.key.gen('bazed2', {type: 'ed25519'}).then((res) => { expect(res).to.exist() }) }) @@ -75,7 +75,7 @@ describe('.key', function () { describe('.list', () => { it('4 keys to show up + self', () => { - return ipfsd.api.key.list().then((res) => { + return ipfs.key.list().then((res) => { expect(res).to.exist() expect(res.length).to.equal(5) }) diff --git a/test/log.spec.js b/test/log.spec.js index 0a1902cc4..cdfb7f337 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -31,7 +31,7 @@ describe('.log', function () { this.timeout(100 * 1000) it('.log.tail', (done) => { - const req = ipfsd.api.log.tail((err, res) => { + const req = ipfs.log.tail((err, res) => { expect(err).to.not.exist() expect(req).to.exist() @@ -43,7 +43,7 @@ describe('.log', function () { }) it('.log.ls', (done) => { - ipfsd.api.log.ls((err, res) => { + ipfs.log.ls((err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -54,7 +54,7 @@ describe('.log', function () { }) it('.log.level', (done) => { - ipfsd.api.log.level('all', 'error', (err, res) => { + ipfs.log.level('all', 'error', (err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -71,7 +71,7 @@ describe('.log', function () { this.timeout(100 * 1000) it('.log.tail', () => { - return ipfsd.api.log.tail() + return ipfs.log.tail() .then((res) => { res.once('data', (obj) => { expect(obj).to.be.an('object') @@ -80,7 +80,7 @@ describe('.log', function () { }) it('.log.ls', () => { - return ipfsd.api.log.ls() + return ipfs.log.ls() .then((res) => { expect(res).to.exist() @@ -89,7 +89,7 @@ describe('.log', function () { }) it('.log.level', () => { - return ipfsd.api.log.level('all', 'error') + return ipfs.log.level('all', 'error') .then((res) => { expect(res).to.exist() diff --git a/test/name.spec.js b/test/name.spec.js index 159ca6351..9ceb508ea 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -48,7 +48,7 @@ describe('.name', function () { ipfsd.api.id((err, id) => { expect(err).to.not.exist() const ma = id.addresses[0] - other.api.swarm.connect(ma, cb) + other.swarm.connect(ma, cb) }) } ], done) @@ -67,7 +67,7 @@ describe('.name', function () { it('add file for testing', (done) => { const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - ipfsd.api.files.add(testfile, (err, res) => { + ipfs.files.add(testfile, (err, res) => { expect(err).to.not.exist() expect(res).to.have.length(1) @@ -78,7 +78,7 @@ describe('.name', function () { }) it('.name.publish', (done) => { - ipfsd.api.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { + ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { expect(err).to.not.exist() name = res expect(name).to.exist() @@ -87,7 +87,7 @@ describe('.name', function () { }) it('.name.resolve', (done) => { - ipfsd.api.name.resolve(name.name, (err, res) => { + ipfs.name.resolve(name.name, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.be.eql(name.value) @@ -100,7 +100,7 @@ describe('.name', function () { let name it('.name.publish', () => { - return ipfsd.api.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') + return ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') .then((res) => { name = res expect(name).to.exist() @@ -108,7 +108,7 @@ describe('.name', function () { }) it('.name.resolve', () => { - return ipfsd.api.name.resolve(name.name) + return ipfs.name.resolve(name.name) .then((res) => { expect(res).to.exist() expect(res).to.be.eql(name.value) diff --git a/test/ping.spec.js b/test/ping.spec.js index 215ca0a96..bee554e48 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -60,7 +60,7 @@ describe.skip('.ping', () => { other.id((err, id) => { expect(err).to.not.exist() - ipfsd.api.ping(id.id, (err, res) => { + ipfs.ping(id.id, (err, res) => { expect(err).to.not.exist() expect(res).to.have.a.property('Success') expect(res).to.have.a.property('Time') @@ -77,7 +77,7 @@ describe.skip('.ping', () => { it('ping another peer', () => { return other.id() .then((id) => { - return ipfsd.api.ping(id.id) + return ipfs.ping(id.id) }) .then((res) => { expect(res).to.have.a.property('Success') diff --git a/test/refs.spec.js b/test/refs.spec.js index 0f7eebbff..0b0a406cd 100644 --- a/test/refs.spec.js +++ b/test/refs.spec.js @@ -80,7 +80,7 @@ describe('.refs', function () { describe('Callback API', () => { it('refs', (done) => { - ipfsd.api.refs(folder, { format: ' ' }, (err, objs) => { + ipfs.refs(folder, { format: ' ' }, (err, objs) => { expect(err).to.not.exist() expect(objs).to.eql(result) done() @@ -90,7 +90,7 @@ describe('.refs', function () { describe('Promise API', () => { it('refs', () => { - return ipfsd.api.refs(folder, { format: ' ' }) + return ipfs.refs(folder, {format: ' '}) .then((objs) => { expect(objs).to.eql(result) }) diff --git a/test/repo.spec.js b/test/repo.spec.js index 17576cda8..aa044f606 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -28,7 +28,7 @@ describe('.repo', function () { describe('Callback API', () => { it('.repo.gc', (done) => { - ipfsd.api.repo.gc((err, res) => { + ipfs.repo.gc((err, res) => { expect(err).to.not.exist() expect(res).to.exist() done() @@ -36,7 +36,7 @@ describe('.repo', function () { }) it('.repo.stat', (done) => { - ipfsd.api.repo.stat((err, res) => { + ipfs.repo.stat((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('NumObjects') @@ -48,11 +48,11 @@ describe('.repo', function () { describe('Promise API', () => { it('.repo.gc', () => { - return ipfsd.api.repo.gc().then((res) => expect(res).to.exist()) + return ipfs.repo.gc().then((res) => expect(res).to.exist()) }) it('.repo.stat', () => { - return ipfsd.api.repo.stat() + return ipfs.repo.stat() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('NumObjects') diff --git a/test/stats.spec.js b/test/stats.spec.js index 3f49eacfa..67bf6b360 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -28,7 +28,7 @@ describe('stats', function () { describe('Callback API', () => { it('.stats.bitswap', (done) => { - ipfsd.api.stats.bitswap((err, res) => { + ipfs.stats.bitswap((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('provideBufLen') @@ -45,7 +45,7 @@ describe('stats', function () { }) it('.stats.bw', (done) => { - ipfsd.api.stats.bw((err, res) => { + ipfs.stats.bw((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('totalIn') @@ -57,7 +57,7 @@ describe('stats', function () { }) it('.stats.repo', (done) => { - ipfsd.api.stats.repo((err, res) => { + ipfs.stats.repo((err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.a.property('numObjects') @@ -72,7 +72,7 @@ describe('stats', function () { describe('Promise API', () => { it('.stats.bw', () => { - return ipfsd.api.stats.bw() + return ipfs.stats.bw() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('totalIn') @@ -83,7 +83,7 @@ describe('stats', function () { }) it('.stats.repo', () => { - return ipfsd.api.stats.repo() + return ipfs.stats.repo() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('numObjects') @@ -95,7 +95,7 @@ describe('stats', function () { }) it('.stats.bitswap', () => { - return ipfsd.api.stats.bitswap() + return ipfs.stats.bitswap() .then((res) => { expect(res).to.exist() expect(res).to.have.a.property('provideBufLen') diff --git a/test/util.spec.js b/test/util.spec.js index 352eeaf16..184f3c15b 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -37,7 +37,7 @@ describe('.util', () => { const rs = fs.createReadStream(tfpath) rs.path = '' // clean the path for testing purposes - ipfsd.api.util.addFromStream(rs, (err, result) => { + ipfs.util.addFromStream(rs, (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -47,7 +47,7 @@ describe('.util', () => { describe('.fsAdd should add', () => { it('a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfsd.api.util.addFromFs(filesPath, { recursive: true }, (err, result) => { + ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(8) done() @@ -56,7 +56,7 @@ describe('.util', () => { it('a directory with an odd name', (done) => { const filesPath = path.join(__dirname, '/fixtures/weird name folder [v0]') - ipfsd.api.util.addFromFs(filesPath, { recursive: true }, (err, result) => { + ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(8) done() @@ -65,7 +65,7 @@ describe('.util', () => { it('add and ignore a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfsd.api.util.addFromFs(filesPath, { recursive: true, ignore: ['files/**'] }, (err, result) => { + ipfs.util.addFromFs(filesPath, { recursive: true, ignore: ['files/**'] }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.below(9) done() @@ -74,7 +74,7 @@ describe('.util', () => { it('a file', (done) => { const filePath = path.join(__dirname, '/fixtures/testfile.txt') - ipfsd.api.util.addFromFs(filePath, (err, result) => { + ipfs.util.addFromFs(filePath, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.equal(1) expect(result[0].path).to.be.equal('testfile.txt') @@ -84,7 +84,7 @@ describe('.util', () => { it('a hidden file in a directory', (done) => { const filesPath = path.join(__dirname, '/fixtures/test-folder') - ipfsd.api.util.addFromFs(filesPath, { recursive: true, hidden: true }, (err, result) => { + ipfs.util.addFromFs(filesPath, { recursive: true, hidden: true }, (err, result) => { expect(err).to.not.exist() expect(result.length).to.be.above(10) expect(result.map(object => object.path)).to.include('test-folder/.hiddenTest.txt') @@ -97,7 +97,7 @@ describe('.util', () => { it('.urlAdd http', function (done) { this.timeout(20 * 1000) - ipfsd.api.util.addFromURL('http://example.com/', (err, result) => { + ipfs.util.addFromURL('http://example.com/', (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -105,7 +105,7 @@ describe('.util', () => { }) it('.urlAdd https', (done) => { - ipfsd.api.util.addFromURL('https://example.com/', (err, result) => { + ipfs.util.addFromURL('https://example.com/', (err, result) => { expect(err).to.not.exist() expect(result.length).to.equal(1) done() @@ -113,7 +113,7 @@ describe('.util', () => { }) it('.urlAdd http with redirection', (done) => { - ipfsd.api.util.addFromURL('http://covers.openlibrary.org/book/id/969165.jpg', (err, result) => { + ipfs.util.addFromURL('http://covers.openlibrary.org/book/id/969165.jpg', (err, result) => { expect(err).to.not.exist() expect(result[0].hash).to.equal('QmaL9zy7YUfvWmtD5ZXp42buP7P4xmZJWFkm78p8FJqgjg') done() From f628dab5a6ade27e025f78ba3ca998a92cc51b01 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 16 Jan 2018 09:41:09 -0600 Subject: [PATCH 06/14] chore: upping ipfsd-ctl version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93efacc57..cd0279035 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "gulp": "^3.9.1", "interface-ipfs-core": "~0.40.0", "hapi": "^16.6.2", - "ipfsd-ctl": "~0.26.0", + "ipfsd-ctl": "~0.27.0", "pre-commit": "^1.2.2", "socket.io": "^2.0.4", "socket.io-client": "^2.0.4", From 9fa47086ba3694068c5ca3cc4bffe0f3f8b8ae97 Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 18 Jan 2018 16:37:19 -0800 Subject: [PATCH 07/14] chore: bump interface-ipfs-core --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cd0279035..5858492af 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "eslint-plugin-react": "^7.5.1", "go-ipfs-dep": "^0.4.13", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.40.0", + "interface-ipfs-core": "~0.41.0", "hapi": "^16.6.2", "ipfsd-ctl": "~0.27.0", "pre-commit": "^1.2.2", From 74ecf1ccb0747ad384b9dbccf46d562dfb9154ec Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 18 Jan 2018 20:25:55 -0600 Subject: [PATCH 08/14] fix: timeouts --- .aegir.js | 6 ++---- package.json | 5 +++-- test/name.spec.js | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.aegir.js b/.aegir.js index 58b0db315..15d99090e 100644 --- a/.aegir.js +++ b/.aegir.js @@ -14,9 +14,7 @@ module.exports = { singleRun: true }, hooks: { - browser: { - pre: server.start.bind(server), - post: server.stop.bind(server) - } + pre: server.start.bind(server), + post: server.stop.bind(server) } } diff --git a/package.json b/package.json index 5858492af..58ab6abdd 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,10 @@ "http": "stream-http" }, "scripts": { - "test": "aegir test ", - "test:node": "aegir test -t node ", + "test": "aegir test", + "test:node": "aegir test -t node", "test:browser": "aegir test -t browser", + "test:webworker": "aegir test -t webworker", "lint": "aegir lint", "build": "aegir build", "release": "aegir release ", diff --git a/test/name.spec.js b/test/name.spec.js index 9ceb508ea..d4b621e22 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -99,7 +99,8 @@ describe('.name', function () { describe('Promise API', () => { let name - it('.name.publish', () => { + it('.name.publish', function () { + this.timeout(80 * 1000) return ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') .then((res) => { name = res From 01d7c16cd055cf482b212c64013727fc29c59caa Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 18 Jan 2018 18:51:57 -0800 Subject: [PATCH 09/14] clean bitswap tests --- test/bitswap.spec.js | 74 +++++++++-------------------- test/stats.spec.js | 111 +++++++++++++------------------------------ 2 files changed, 56 insertions(+), 129 deletions(-) diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index ef4c18f23..580df522b 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -26,65 +26,35 @@ describe('.bitswap', function () { after((done) => ipfsd.stop(done)) - describe('Callback API', () => { - it('.wantlist', (done) => { - ipfs.bitswap.wantlist((err, res) => { - expect(err).to.not.exist() - expect(res).to.have.to.be.eql({ - Keys: null - }) - done() - }) - }) - - it('.stat', (done) => { - ipfs.bitswap.stat((err, res) => { - expect(err).to.not.exist() - expect(res).to.have.property('BlocksReceived') - expect(res).to.have.property('DupBlksReceived') - expect(res).to.have.property('DupDataReceived') - expect(res).to.have.property('Peers') - expect(res).to.have.property('ProvideBufLen') - expect(res).to.have.property('Wantlist') - - done() - }) - }) - - it('.unwant', (done) => { - const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - ipfs.bitswap.unwant(key, (err) => { - expect(err).to.not.exist() - done() + it('.wantlist', (done) => { + ipfs.bitswap.wantlist((err, res) => { + expect(err).to.not.exist() + expect(res).to.have.to.eql({ + Keys: null }) + done() }) }) - describe('Promise API', () => { - it('.wantlist', () => { - return ipfs.bitswap.wantlist() - .then((res) => { - expect(res).to.have.to.be.eql({ - Keys: null - }) - }) - }) + it('.stat', (done) => { + ipfs.bitswap.stat((err, res) => { + expect(err).to.not.exist() + expect(res).to.have.property('BlocksReceived') + expect(res).to.have.property('DupBlksReceived') + expect(res).to.have.property('DupDataReceived') + expect(res).to.have.property('Peers') + expect(res).to.have.property('ProvideBufLen') + expect(res).to.have.property('Wantlist') - it('.stat', () => { - return ipfs.bitswap.stat() - .then((res) => { - expect(res).to.have.property('BlocksReceived') - expect(res).to.have.property('DupBlksReceived') - expect(res).to.have.property('DupDataReceived') - expect(res).to.have.property('Peers') - expect(res).to.have.property('ProvideBufLen') - expect(res).to.have.property('Wantlist') - }) + done() }) + }) - it('.unwant', () => { - const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - return ipfs.bitswap.unwant(key) + it('.unwant', (done) => { + const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' + ipfs.bitswap.unwant(key, (err) => { + expect(err).to.not.exist() + done() }) }) }) diff --git a/test/stats.spec.js b/test/stats.spec.js index 67bf6b360..9a86ab844 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -26,88 +26,45 @@ describe('stats', function () { after((done) => ipfsd.stop(done)) - describe('Callback API', () => { - it('.stats.bitswap', (done) => { - ipfs.stats.bitswap((err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - expect(res).to.have.a.property('provideBufLen') - expect(res).to.have.a.property('wantlist') - expect(res).to.have.a.property('peers') - expect(res).to.have.a.property('blocksReceived') - expect(res).to.have.a.property('dataReceived') - expect(res).to.have.a.property('blocksSent') - expect(res).to.have.a.property('dataSent') - expect(res).to.have.a.property('dupBlksReceived') - expect(res).to.have.a.property('dupDataReceived') - done() - }) - }) - - it('.stats.bw', (done) => { - ipfs.stats.bw((err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - expect(res).to.have.a.property('totalIn') - expect(res).to.have.a.property('totalOut') - expect(res).to.have.a.property('rateIn') - expect(res).to.have.a.property('rateOut') - done() - }) - }) - - it('.stats.repo', (done) => { - ipfs.stats.repo((err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - expect(res).to.have.a.property('numObjects') - expect(res).to.have.a.property('repoSize') - expect(res).to.have.a.property('repoPath') - expect(res).to.have.a.property('version') - expect(res).to.have.a.property('storageMax') - done() - }) + it('.stats.bitswap', (done) => { + ipfs.stats.bitswap((err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() + expect(res).to.have.a.property('provideBufLen') + expect(res).to.have.a.property('wantlist') + expect(res).to.have.a.property('peers') + expect(res).to.have.a.property('blocksReceived') + expect(res).to.have.a.property('dataReceived') + expect(res).to.have.a.property('blocksSent') + expect(res).to.have.a.property('dataSent') + expect(res).to.have.a.property('dupBlksReceived') + expect(res).to.have.a.property('dupDataReceived') + done() }) }) - describe('Promise API', () => { - it('.stats.bw', () => { - return ipfs.stats.bw() - .then((res) => { - expect(res).to.exist() - expect(res).to.have.a.property('totalIn') - expect(res).to.have.a.property('totalOut') - expect(res).to.have.a.property('rateIn') - expect(res).to.have.a.property('rateOut') - }) - }) - - it('.stats.repo', () => { - return ipfs.stats.repo() - .then((res) => { - expect(res).to.exist() - expect(res).to.have.a.property('numObjects') - expect(res).to.have.a.property('repoSize') - expect(res).to.have.a.property('repoPath') - expect(res).to.have.a.property('version') - expect(res).to.have.a.property('storageMax') - }) + it('.stats.bw', (done) => { + ipfs.stats.bw((err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() + expect(res).to.have.a.property('totalIn') + expect(res).to.have.a.property('totalOut') + expect(res).to.have.a.property('rateIn') + expect(res).to.have.a.property('rateOut') + done() }) + }) - it('.stats.bitswap', () => { - return ipfs.stats.bitswap() - .then((res) => { - expect(res).to.exist() - expect(res).to.have.a.property('provideBufLen') - expect(res).to.have.a.property('wantlist') - expect(res).to.have.a.property('peers') - expect(res).to.have.a.property('blocksReceived') - expect(res).to.have.a.property('dataReceived') - expect(res).to.have.a.property('blocksSent') - expect(res).to.have.a.property('dataSent') - expect(res).to.have.a.property('dupBlksReceived') - expect(res).to.have.a.property('dupDataReceived') - }) + it('.stats.repo', (done) => { + ipfs.stats.repo((err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() + expect(res).to.have.a.property('numObjects') + expect(res).to.have.a.property('repoSize') + expect(res).to.have.a.property('repoPath') + expect(res).to.have.a.property('version') + expect(res).to.have.a.property('storageMax') + done() }) }) }) From af4dd754fedb35c3f193d731035ce58d5813a42a Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 18 Jan 2018 21:21:17 -0600 Subject: [PATCH 10/14] feat: use the current ipfs-api --- test/bitswap.spec.js | 8 +++++--- test/bootstrap.spec.js | 8 +++++--- test/commands.spec.js | 8 +++++--- test/diag.spec.js | 8 +++++--- test/files.spec.js | 8 +++++--- test/fixtures/test-folder/hello-link | 0 test/get.spec.js | 18 ++++++++++++------ test/key.spec.js | 12 +++++++----- test/log.spec.js | 8 +++++--- test/name.spec.js | 8 +++++--- test/ping.spec.js | 8 +++++--- test/pubsub-in-browser.spec.js | 8 +++++--- test/refs.spec.js | 12 +++++++----- test/repo.spec.js | 8 +++++--- test/stats.spec.js | 8 +++++--- test/util.spec.js | 8 +++++--- 16 files changed, 86 insertions(+), 52 deletions(-) mode change 100644 => 120000 test/fixtures/test-folder/hello-link diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index 580df522b..46051e258 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -16,10 +18,10 @@ describe('.bitswap', function () { before((done) => { this.timeout(20 * 1000) // slow CI - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) diff --git a/test/bootstrap.spec.js b/test/bootstrap.spec.js index a0331ba8a..4cc7e3221 100644 --- a/test/bootstrap.spec.js +++ b/test/bootstrap.spec.js @@ -7,6 +7,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -20,10 +22,10 @@ describe('.bootstrap', function () { let ipfs before((done) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) diff --git a/test/commands.spec.js b/test/commands.spec.js index 09e8db6e7..5e2b3804d 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -16,10 +18,10 @@ describe('.commands', function () { let ipfs before((done) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) diff --git a/test/diag.spec.js b/test/diag.spec.js index f862693c5..5f68a3e95 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -7,6 +7,8 @@ const expect = chai.expect chai.use(dirtyChai) const os = require('os') +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -22,10 +24,10 @@ describe('.diag', function () { let ipfs before((done) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) diff --git a/test/files.spec.js b/test/files.spec.js index 93ddb8a31..6f67a0708 100644 --- a/test/files.spec.js +++ b/test/files.spec.js @@ -11,6 +11,8 @@ const loadFixture = require('aegir/fixtures') const mh = require('multihashes') const CID = require('cids') +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -39,10 +41,10 @@ describe('.files (the MFS API part)', function () { const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' before((done) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) diff --git a/test/fixtures/test-folder/hello-link b/test/fixtures/test-folder/hello-link deleted file mode 100644 index 50b07e9e7..000000000 --- a/test/fixtures/test-folder/hello-link +++ /dev/null @@ -1 +0,0 @@ -files/hello.txt \ No newline at end of file diff --git a/test/fixtures/test-folder/hello-link b/test/fixtures/test-folder/hello-link new file mode 120000 index 000000000..50b07e9e7 --- /dev/null +++ b/test/fixtures/test-folder/hello-link @@ -0,0 +1 @@ +files/hello.txt \ No newline at end of file diff --git a/test/get.spec.js b/test/get.spec.js index 4231a8c72..3cd9e99c6 100644 --- a/test/get.spec.js +++ b/test/get.spec.js @@ -11,6 +11,8 @@ const isNode = require('detect-node') const series = require('async/series') const loadFixture = require('aegir/fixtures') +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -31,13 +33,13 @@ describe('.get (specific go-ipfs features)', function () { before((done) => { series([ - (cb) => df.spawn((err, node) => { + (cb) => df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) cb() }), - (cb) => ipfsd.api.files.add(smallFile.data, cb) + (cb) => ipfs.files.add(smallFile.data, cb) ], done) }) @@ -79,7 +81,9 @@ describe('.get (specific go-ipfs features)', function () { }) it('add path containing "+"s (for testing get)', (done) => { - if (!isNode) { return done() } + if (!isNode) { + return done() + } const filename = 'ti,c64x+mega++mod-pic.txt' const subdir = 'tmp/c++files' @@ -95,7 +99,9 @@ describe('.get (specific go-ipfs features)', function () { }) it('get path containing "+"s', (done) => { - if (!isNode) { return done() } + if (!isNode) { + return done() + } const cid = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff' let count = 0 diff --git a/test/key.spec.js b/test/key.spec.js index 652dd76c8..3db9a9953 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -7,6 +7,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -17,10 +19,10 @@ describe('.key', function () { let ipfs before((done) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) @@ -61,13 +63,13 @@ describe('.key', function () { describe('Promise API', () => { describe('.gen', () => { it('create a new rsa key', () => { - return ipfs.key.gen('foobarsa2', {type: 'rsa', size: 2048}).then((res) => { + return ipfs.key.gen('foobarsa2', { type: 'rsa', size: 2048 }).then((res) => { expect(res).to.exist() }) }) it('create a new ed25519 key', () => { - return ipfs.key.gen('bazed2', {type: 'ed25519'}).then((res) => { + return ipfs.key.gen('bazed2', { type: 'ed25519' }).then((res) => { expect(res).to.exist() }) }) diff --git a/test/log.spec.js b/test/log.spec.js index cdfb7f337..38dc7d710 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -7,6 +7,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -17,10 +19,10 @@ describe('.log', function () { let ipfs before((done) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) diff --git a/test/name.spec.js b/test/name.spec.js index d4b621e22..8018bdeda 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -11,6 +11,8 @@ const isNode = require('detect-node') const series = require('async/series') const loadFixture = require('aegir/fixtures') +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -29,10 +31,10 @@ describe('.name', function () { before((done) => { series([ (cb) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) cb() }) }, diff --git a/test/ping.spec.js b/test/ping.spec.js index bee554e48..e2bcc44ff 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -9,6 +9,8 @@ chai.use(dirtyChai) const parallel = require('async/parallel') const series = require('async/series') +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -22,10 +24,10 @@ describe.skip('.ping', () => { this.timeout(20 * 1000) // slow CI series([ (cb) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) cb() }) }, diff --git a/test/pubsub-in-browser.spec.js b/test/pubsub-in-browser.spec.js index 3e7dcc0f6..992e567f9 100644 --- a/test/pubsub-in-browser.spec.js +++ b/test/pubsub-in-browser.spec.js @@ -32,6 +32,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -50,10 +52,10 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun let ipfsd before((done) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfs = node.api - ipfsd = node + ipfs = _ipfsd.api + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) diff --git a/test/refs.spec.js b/test/refs.spec.js index 0b0a406cd..d6ca6572d 100644 --- a/test/refs.spec.js +++ b/test/refs.spec.js @@ -10,6 +10,8 @@ const waterfall = require('async/waterfall') const path = require('path') const fs = require('fs') +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -38,10 +40,10 @@ describe('.refs', function () { waterfall([ (cb) => df.spawn(cb), - (node, cb) => { - ipfsd = node - ipfs = node.api - ipfsd.api.util.addFromFs(filesPath, { recursive: true }, cb) + (_ipfsd, cb) => { + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) + ipfs.util.addFromFs(filesPath, { recursive: true }, cb) }, (hashes, cb) => { folder = hashes[hashes.length - 1].hash @@ -90,7 +92,7 @@ describe('.refs', function () { describe('Promise API', () => { it('refs', () => { - return ipfs.refs(folder, {format: ' '}) + return ipfs.refs(folder, { format: ' ' }) .then((objs) => { expect(objs).to.eql(result) }) diff --git a/test/repo.spec.js b/test/repo.spec.js index aa044f606..9507918de 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -16,10 +18,10 @@ describe('.repo', function () { let ipfsd before((done) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) diff --git a/test/stats.spec.js b/test/stats.spec.js index 9a86ab844..1f1619157 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -6,6 +6,8 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -16,10 +18,10 @@ describe('stats', function () { let ipfsd before((done) => { - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) diff --git a/test/util.spec.js b/test/util.spec.js index 184f3c15b..89b81414b 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -10,6 +10,8 @@ const isNode = require('detect-node') const path = require('path') const fs = require('fs') +const IPFSApi = require('../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() @@ -22,10 +24,10 @@ describe('.util', () => { before(function (done) { this.timeout(20 * 1000) // slow CI - df.spawn((err, node) => { + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfsd = node - ipfs = node.api + ipfsd = _ipfsd + ipfs = IPFSApi(_ipfsd.apiAddr) done() }) }) From d32b03df4a0f5be6e5e56d97439570b7b27a2459 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 18 Jan 2018 22:13:49 -0600 Subject: [PATCH 11/14] fix: setup interface test node in ipfs-api --- test/interface/block.spec.js | 18 +++++++++++++++++- test/interface/config.spec.js | 18 +++++++++++++++++- test/interface/dht.spec.js | 18 +++++++++++++++++- test/interface/files.spec.js | 18 +++++++++++++++++- test/interface/generic.spec.js | 18 +++++++++++++++++- test/interface/key.spec.js | 18 +++++++++++++++++- test/interface/object.spec.js | 18 +++++++++++++++++- test/interface/pin.spec.js | 18 +++++++++++++++++- test/interface/pubsub.spec.js | 19 ++++++++++++++++++- test/interface/swarm.spec.js | 28 +++++++++++++++++++++++++++- test/name.spec.js | 3 ++- 11 files changed, 183 insertions(+), 11 deletions(-) diff --git a/test/interface/block.spec.js b/test/interface/block.spec.js index 76a305720..0aeecca6a 100644 --- a/test/interface/block.spec.js +++ b/test/interface/block.spec.js @@ -3,13 +3,29 @@ 'use strict' const test = require('interface-ipfs-core') +const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() +let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/interface/config.spec.js b/test/interface/config.spec.js index 64305131e..01c0bbec3 100644 --- a/test/interface/config.spec.js +++ b/test/interface/config.spec.js @@ -3,13 +3,29 @@ 'use strict' const test = require('interface-ipfs-core') +const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() +let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/interface/dht.spec.js b/test/interface/dht.spec.js index 202aa4dd6..1151674f4 100644 --- a/test/interface/dht.spec.js +++ b/test/interface/dht.spec.js @@ -2,13 +2,29 @@ 'use strict' const test = require('interface-ipfs-core') +const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() +let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/interface/files.spec.js b/test/interface/files.spec.js index 9bf84fe25..6322fc8d8 100644 --- a/test/interface/files.spec.js +++ b/test/interface/files.spec.js @@ -3,13 +3,29 @@ 'use strict' const test = require('interface-ipfs-core') +const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() +let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/interface/generic.spec.js b/test/interface/generic.spec.js index 69d1f579d..59057582c 100644 --- a/test/interface/generic.spec.js +++ b/test/interface/generic.spec.js @@ -3,13 +3,29 @@ 'use strict' const test = require('interface-ipfs-core') +const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() +let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/interface/key.spec.js b/test/interface/key.spec.js index b7c8f2985..9567537ca 100644 --- a/test/interface/key.spec.js +++ b/test/interface/key.spec.js @@ -3,13 +3,29 @@ 'use strict' const test = require('interface-ipfs-core') +const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() +let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/interface/object.spec.js b/test/interface/object.spec.js index affa0d6ae..4544fdb24 100644 --- a/test/interface/object.spec.js +++ b/test/interface/object.spec.js @@ -3,13 +3,29 @@ 'use strict' const test = require('interface-ipfs-core') +const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() +let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/interface/pin.spec.js b/test/interface/pin.spec.js index d434dba77..496816716 100644 --- a/test/interface/pin.spec.js +++ b/test/interface/pin.spec.js @@ -3,13 +3,29 @@ 'use strict' const test = require('interface-ipfs-core') +const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() +let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/interface/pubsub.spec.js b/test/interface/pubsub.spec.js index 0eeb0714f..f4a8c8803 100644 --- a/test/interface/pubsub.spec.js +++ b/test/interface/pubsub.spec.js @@ -5,13 +5,30 @@ const test = require('interface-ipfs-core') const isNode = require('detect-node') +const IPFSApi = require('../../src') + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() if (isNode) { + let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (cb) => { + df.spawn({ args: ['--enable-pubsub-experiment'] }, (err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/interface/swarm.spec.js b/test/interface/swarm.spec.js index ebbeaeb01..5368a1831 100644 --- a/test/interface/swarm.spec.js +++ b/test/interface/swarm.spec.js @@ -3,13 +3,39 @@ 'use strict' const test = require('interface-ipfs-core') +const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() +let ipfsd = null const common = { setup: function (callback) { - callback(null, df) + callback(null, { + spawnNode: (repoPath, config, cb) => { + if (typeof repoPath === 'function') { + cb = repoPath + repoPath = undefined + } + + if (typeof config === 'function') { + cb = config + config = undefined + } + + df.spawn({ repoPath, config }, (err, _ipfsd) => { + if (err) { + return cb(err) + } + + ipfsd = _ipfsd + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + }, + teardown: function (callback) { + ipfsd.stop(callback) } } diff --git a/test/name.spec.js b/test/name.spec.js index 8018bdeda..b1441a9a3 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -79,7 +79,8 @@ describe('.name', function () { }) }) - it('.name.publish', (done) => { + it('.name.publish', function (done) { + this.timeout(50 * 1000) ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { expect(err).to.not.exist() name = res From 43f48917e8c1d3bd18e32f9d363764e45ee0a599 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Thu, 18 Jan 2018 22:55:52 -0600 Subject: [PATCH 12/14] feat: destroy multiple nodes --- test/interface/block.spec.js | 8 +++++--- test/interface/config.spec.js | 8 +++++--- test/interface/dht.spec.js | 8 +++++--- test/interface/files.spec.js | 8 +++++--- test/interface/generic.spec.js | 8 +++++--- test/interface/key.spec.js | 8 +++++--- test/interface/object.spec.js | 8 +++++--- test/interface/pin.spec.js | 8 +++++--- test/interface/pubsub.spec.js | 23 +++++++++++++---------- test/interface/swarm.spec.js | 8 +++++--- 10 files changed, 58 insertions(+), 37 deletions(-) diff --git a/test/interface/block.spec.js b/test/interface/block.spec.js index 0aeecca6a..5a1883088 100644 --- a/test/interface/block.spec.js +++ b/test/interface/block.spec.js @@ -3,12 +3,14 @@ 'use strict' const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() -let ipfsd = null +const nodes = [] const common = { setup: function (callback) { callback(null, { @@ -18,14 +20,14 @@ const common = { return cb(err) } - ipfsd = _ipfsd + nodes.push(_ipfsd) cb(null, IPFSApi(_ipfsd.apiAddr)) }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/interface/config.spec.js b/test/interface/config.spec.js index 01c0bbec3..91f551a7d 100644 --- a/test/interface/config.spec.js +++ b/test/interface/config.spec.js @@ -3,12 +3,14 @@ 'use strict' const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() -let ipfsd = null +const nodes = [] const common = { setup: function (callback) { callback(null, { @@ -18,14 +20,14 @@ const common = { return cb(err) } - ipfsd = _ipfsd + nodes.push(_ipfsd) cb(null, IPFSApi(_ipfsd.apiAddr)) }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/interface/dht.spec.js b/test/interface/dht.spec.js index 1151674f4..1ae3081fc 100644 --- a/test/interface/dht.spec.js +++ b/test/interface/dht.spec.js @@ -2,12 +2,14 @@ 'use strict' const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() -let ipfsd = null +const nodes = [] const common = { setup: function (callback) { callback(null, { @@ -17,14 +19,14 @@ const common = { return cb(err) } - ipfsd = _ipfsd + nodes.push(_ipfsd) cb(null, IPFSApi(_ipfsd.apiAddr)) }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/interface/files.spec.js b/test/interface/files.spec.js index 6322fc8d8..c58b9d5e8 100644 --- a/test/interface/files.spec.js +++ b/test/interface/files.spec.js @@ -3,12 +3,14 @@ 'use strict' const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() -let ipfsd = null +const nodes = [] const common = { setup: function (callback) { callback(null, { @@ -18,14 +20,14 @@ const common = { return cb(err) } - ipfsd = _ipfsd + nodes.push(_ipfsd) cb(null, IPFSApi(_ipfsd.apiAddr)) }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/interface/generic.spec.js b/test/interface/generic.spec.js index 59057582c..31a6e66e8 100644 --- a/test/interface/generic.spec.js +++ b/test/interface/generic.spec.js @@ -3,12 +3,14 @@ 'use strict' const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() -let ipfsd = null +const nodes = [] const common = { setup: function (callback) { callback(null, { @@ -18,14 +20,14 @@ const common = { return cb(err) } - ipfsd = _ipfsd + nodes.push(_ipfsd) cb(null, IPFSApi(_ipfsd.apiAddr)) }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/interface/key.spec.js b/test/interface/key.spec.js index 9567537ca..6fd3510f5 100644 --- a/test/interface/key.spec.js +++ b/test/interface/key.spec.js @@ -3,12 +3,14 @@ 'use strict' const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() -let ipfsd = null +const nodes = [] const common = { setup: function (callback) { callback(null, { @@ -18,14 +20,14 @@ const common = { return cb(err) } - ipfsd = _ipfsd + nodes.push(_ipfsd) cb(null, IPFSApi(_ipfsd.apiAddr)) }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/interface/object.spec.js b/test/interface/object.spec.js index 4544fdb24..be4ffa70c 100644 --- a/test/interface/object.spec.js +++ b/test/interface/object.spec.js @@ -3,12 +3,14 @@ 'use strict' const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() -let ipfsd = null +const nodes = [] const common = { setup: function (callback) { callback(null, { @@ -18,14 +20,14 @@ const common = { return cb(err) } - ipfsd = _ipfsd + nodes.push(_ipfsd) cb(null, IPFSApi(_ipfsd.apiAddr)) }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/interface/pin.spec.js b/test/interface/pin.spec.js index 496816716..d72d008b3 100644 --- a/test/interface/pin.spec.js +++ b/test/interface/pin.spec.js @@ -3,12 +3,14 @@ 'use strict' const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() -let ipfsd = null +const nodes = [] const common = { setup: function (callback) { callback(null, { @@ -18,14 +20,14 @@ const common = { return cb(err) } - ipfsd = _ipfsd + nodes.push(_ipfsd) cb(null, IPFSApi(_ipfsd.apiAddr)) }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/interface/pubsub.spec.js b/test/interface/pubsub.spec.js index f4a8c8803..4499bcbce 100644 --- a/test/interface/pubsub.spec.js +++ b/test/interface/pubsub.spec.js @@ -5,30 +5,33 @@ const test = require('interface-ipfs-core') const isNode = require('detect-node') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() if (isNode) { - let ipfsd = null + const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn({ args: ['--enable-pubsub-experiment'] }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - ipfsd = _ipfsd - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) + df.spawn({ args: ['--enable-pubsub-experiment'] }, + (err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/interface/swarm.spec.js b/test/interface/swarm.spec.js index 5368a1831..6d04fbcd8 100644 --- a/test/interface/swarm.spec.js +++ b/test/interface/swarm.spec.js @@ -3,12 +3,14 @@ 'use strict' const test = require('interface-ipfs-core') +const parallel = require('async/parallel') + const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create() -let ipfsd = null +const nodes = [] const common = { setup: function (callback) { callback(null, { @@ -28,14 +30,14 @@ const common = { return cb(err) } - ipfsd = _ipfsd + nodes.push(_ipfsd) cb(null, IPFSApi(_ipfsd.apiAddr)) }) } }) }, teardown: function (callback) { - ipfsd.stop(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } From ff36cefde740c978120dd3033d06f0b6a65285f3 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 19 Jan 2018 20:45:14 -0600 Subject: [PATCH 13/14] various fixes --- test/name.spec.js | 2 +- test/pubsub-in-browser.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/name.spec.js b/test/name.spec.js index b1441a9a3..4cf1088f9 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -80,7 +80,7 @@ describe('.name', function () { }) it('.name.publish', function (done) { - this.timeout(50 * 1000) + this.timeout(100 * 1000) ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { expect(err).to.not.exist() name = res diff --git a/test/pubsub-in-browser.spec.js b/test/pubsub-in-browser.spec.js index 992e567f9..818b477bb 100644 --- a/test/pubsub-in-browser.spec.js +++ b/test/pubsub-in-browser.spec.js @@ -54,7 +54,7 @@ describe('.pubsub-browser (pubsub not supported in the browsers currently)', fun before((done) => { df.spawn((err, _ipfsd) => { expect(err).to.not.exist() - ipfs = _ipfsd.api + ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) done() }) From a6765d7c07de0a858d7d19df89ecd9ac3e595e0b Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 23 Jan 2018 11:18:30 -0600 Subject: [PATCH 14/14] fix: increase browserNoActivityTimeout --- .aegir.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.aegir.js b/.aegir.js index 15d99090e..7f287dd89 100644 --- a/.aegir.js +++ b/.aegir.js @@ -11,6 +11,7 @@ module.exports = { served: true, included: false }], + browserNoActivityTimeout: 100 * 1000, singleRun: true }, hooks: {