From b4df97645308b465c3a08ce4d15078183d92a300 Mon Sep 17 00:00:00 2001 From: victorbjelkholm Date: Thu, 22 Feb 2018 16:45:03 +0100 Subject: [PATCH 01/12] testing: Add Jenkins + fix possible port collisions --- .aegir.js | 1 + ci/Jenkinsfile | 2 ++ test/cli/daemon.js | 22 +++++++++------ test/core/bitswap.spec.js | 41 +++++++++++++++++++--------- test/fixtures/go-ipfs-repo/config | 6 ++-- test/gateway/index.js | 5 ++++ test/http-api/extra/block.js | 7 ++++- test/http-api/extra/bootstrap.js | 7 ++++- test/http-api/extra/config.js | 7 ++++- test/http-api/extra/dns.js | 7 ++++- test/http-api/extra/id.js | 7 ++++- test/http-api/extra/object.js | 7 ++++- test/http-api/extra/utils/get-ctl.js | 5 ++++ test/http-api/extra/version.js | 7 ++++- test/http-api/index.js | 37 +++++++++++++++++++------ test/utils/platforms.js | 16 +++++++++++ 16 files changed, 144 insertions(+), 40 deletions(-) create mode 100644 ci/Jenkinsfile create mode 100644 test/http-api/extra/utils/get-ctl.js create mode 100644 test/utils/platforms.js diff --git a/.aegir.js b/.aegir.js index e254dd4812..8fe6f90d9d 100644 --- a/.aegir.js +++ b/.aegir.js @@ -3,6 +3,7 @@ const createServer = require('ipfsd-ctl').createServer const server = createServer() + module.exports = { karma: { files: [{ diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile new file mode 100644 index 0000000000..a7da2e54f3 --- /dev/null +++ b/ci/Jenkinsfile @@ -0,0 +1,2 @@ +// Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories. +javascript() diff --git a/test/cli/daemon.js b/test/cli/daemon.js index ae4bf9caf3..bf1493c103 100644 --- a/test/cli/daemon.js +++ b/test/cli/daemon.js @@ -4,6 +4,7 @@ const expect = require('chai').expect const clean = require('../utils/clean') const ipfsCmd = require('../utils/ipfs-exec') +const isWindows = require('../utils/platforms').isWindows const pull = require('pull-stream') const toPull = require('stream-to-pull-stream') const os = require('os') @@ -11,8 +12,6 @@ const path = require('path') const hat = require('hat') const fs = require('fs') -const isWindows = os.platform() === 'win32' - const checkLock = (repo, cb) => { // skip on windows // https://github.com/ipfs/js-ipfsd-ctl/pull/155#issuecomment-326983530 @@ -28,9 +27,13 @@ const checkLock = (repo, cb) => { } function testSignal (ipfs, sig) { - let proc = null return ipfs('init').then(() => { - proc = ipfs('daemon') + return ipfs('config', 'Addresses', JSON.stringify({ + API: '/ip4/127.0.0.1/tcp/0', + Gateway: '/ip4/127.0.0.1/tcp/0' + }), '--json') + }).then(() => { + const proc = ipfs('daemon') return new Promise((resolve, reject) => { pull( toPull(proc.stdout), @@ -77,6 +80,7 @@ describe('daemon', () => { ipfs('init').then(() => { return ipfs('config', 'Addresses', JSON.stringify({ + Swarm: [], API: '/ip4/127.0.0.1/tcp/0', Gateway: '/ip4/127.0.0.1/tcp/0' }), '--json') @@ -85,10 +89,12 @@ describe('daemon', () => { }).then((res) => { expect(res).to.have.string('Daemon is ready') done() - }).catch((err) => done(err)) + }).catch(err => done(err)) }) - it('should handle SIGINT gracefully', function (done) { + const skipOnWindows = isWindows() ? it.skip : it + + skipOnWindows('should handle SIGINT gracefully', function (done) { this.timeout(100 * 1000) testSignal(ipfs, 'SIGINT').then(() => { @@ -96,7 +102,7 @@ describe('daemon', () => { }).catch(done) }) - it('should handle SIGTERM gracefully', function (done) { + skipOnWindows('should handle SIGTERM gracefully', function (done) { this.timeout(100 * 1000) testSignal(ipfs, 'SIGTERM').then(() => { @@ -105,7 +111,7 @@ describe('daemon', () => { }) it('gives error if user hasn\'t run init before', function (done) { - this.timeout(100 * 1000) + this.timeout(30 * 1000) const expectedError = 'no initialized ipfs repo found in ' + repoPath diff --git a/test/core/bitswap.spec.js b/test/core/bitswap.spec.js index edf703bc6f..028790e9b3 100644 --- a/test/core/bitswap.spec.js +++ b/test/core/bitswap.spec.js @@ -17,14 +17,17 @@ const multihashing = require('multihashing-async') const CID = require('cids') const IPFSFactory = require('ipfsd-ctl') -const fDaemon = IPFSFactory.create({ type: 'js' }) -const fInProc = IPFSFactory.create({ type: 'proc' }) // This gets replaced by '../utils/create-repo-browser.js' in the browser const createTempRepo = require('../utils/create-repo-nodejs.js') const IPFS = require('../../src/core') +// TODO bitswap tests on windows is failing, missing proper shutdown of daemon +// https://github.com/ipfs/js-ipfsd-ctl/pull/205 +const isWindows = require('../utils/platforms').isWindows +const skipOnWindows = isWindows() ? describe.skip : describe + function makeBlock (callback) { const d = Buffer.from(`IPFS is awesome ${Math.random()}`) @@ -67,7 +70,7 @@ function connectNodes (remoteNode, inProcNode, callback) { let nodes = [] -function addNode (inProcNode, callback) { +function addNode (fDaemon, inProcNode, callback) { fDaemon.spawn({ exec: './src/cli/bin.js', initOptions: { bits: 512 }, @@ -89,10 +92,19 @@ function addNode (inProcNode, callback) { }) } -describe('bitswap', function () { +skipOnWindows('bitswap', function () { this.timeout(80 * 1000) let inProcNode // Node spawned inside this process + let fDaemon + let fInProc + + before(function () { + // AEGIR_TEST_PORT is assigned in .aegir.js + const port = process.env.AEGIR_TEST_PORT + fDaemon = IPFSFactory.create({ type: 'js', port }) + fInProc = IPFSFactory.create({ type: 'proc', port }) + }) beforeEach(function (done) { this.timeout(60 * 1000) @@ -132,7 +144,7 @@ describe('bitswap', function () { }) afterEach(function (done) { - this.timeout(80 * 1000) + this.timeout(160 * 1000) const tasks = nodes.map((node) => (cb) => node.stop(cb)) parallel(tasks, (err) => { expect(err).to.not.exist() @@ -143,14 +155,14 @@ describe('bitswap', function () { describe('transfer a block between', () => { it('2 peers', function (done) { - this.timeout(80 * 1000) + this.timeout(160 * 1000) let remoteNode let block waterfall([ (cb) => parallel([ (cb) => makeBlock(cb), - (cb) => addNode(inProcNode, cb) + (cb) => addNode(fDaemon, inProcNode, cb) ], cb), (res, cb) => { block = res[0] @@ -167,7 +179,7 @@ describe('bitswap', function () { }) it('3 peers', function (done) { - this.timeout(80 * 1000) + this.timeout(240 * 1000) let blocks const remoteNodes = [] @@ -178,11 +190,11 @@ describe('bitswap', function () { blocks = _blocks cb() }), - (cb) => addNode(inProcNode, (err, _ipfs) => { + (cb) => addNode(fDaemon, inProcNode, (err, _ipfs) => { remoteNodes.push(_ipfs) cb(err) }), - (cb) => addNode(inProcNode, (err, _ipfs) => { + (cb) => addNode(fDaemon, inProcNode, (err, _ipfs) => { remoteNodes.push(_ipfs) cb(err) }), @@ -213,14 +225,17 @@ describe('bitswap', function () { }) }) - describe('transfer a file between', () => { + describe('transfer a file between', function () { + this.timeout(160 * 1000) + it('2 peers', (done) => { // TODO make this test more interesting (10Mb file) + // TODO remove randomness from the test const file = Buffer.from(`I love IPFS <3 ${Math.random()}`) waterfall([ // 0. Start node - (cb) => addNode(inProcNode, cb), + (cb) => addNode(fDaemon, inProcNode, cb), // 1. Add file to tmp instance (remote, cb) => { remote.files.add([{ path: 'awesome.txt', content: file }], cb) @@ -239,7 +254,7 @@ describe('bitswap', function () { let node before(function (done) { - this.timeout(40 * 1000) + this.timeout(80 * 1000) node = new IPFS({ repo: createTempRepo(), diff --git a/test/fixtures/go-ipfs-repo/config b/test/fixtures/go-ipfs-repo/config index 7498da51bf..e5d9f80cbc 100644 --- a/test/fixtures/go-ipfs-repo/config +++ b/test/fixtures/go-ipfs-repo/config @@ -14,10 +14,10 @@ }, "Addresses":{ "Swarm":[ - "/ip4/127.0.0.1/tcp/9999", - "/ip4/127.0.0.1/tcp/9990/ws" + "/ip4/127.0.0.1/tcp/0", + "/ip4/127.0.0.1/tcp/0/ws" ], - "API":"/ip4/127.0.0.1/tcp/6001", + "API":"/ip4/127.0.0.1/tcp/0", "Gateway":"/ip4/127.0.0.1/tcp/0" }, "Mounts":{ diff --git a/test/gateway/index.js b/test/gateway/index.js index 8b9eb1c3ab..84ce39914a 100644 --- a/test/gateway/index.js +++ b/test/gateway/index.js @@ -33,6 +33,11 @@ describe('HTTP Gateway', function () { const repoPath = path.join(os.tmpdir(), '/ipfs-' + hat()) http.api = new API(repoPath, { + Addresses: { + Swarm: ['/ip4/127.0.0.1/tcp/0'], + API: '/ip4/127.0.0.1/tcp/0', + Gateway: '/ip4/127.0.0.1/tcp/0' + }, Bootstrap: [], Discovery: { MDNS: { diff --git a/test/http-api/extra/block.js b/test/http-api/extra/block.js index dd66c99836..d75712321d 100644 --- a/test/http-api/extra/block.js +++ b/test/http-api/extra/block.js @@ -8,8 +8,13 @@ chai.use(dirtyChai) const multihash = require('multihashes') const waterfall = require('async/waterfall') +const getCtl = require('./utils/get-ctl.js') -module.exports = (ctl) => { +module.exports = (http) => { + let ctl = null + before(() => { + ctl = getCtl(http) + }) describe('.block', () => { describe('.put', () => { it('updates value', (done) => { diff --git a/test/http-api/extra/bootstrap.js b/test/http-api/extra/bootstrap.js index 1c6ad4ca60..a0ab204cf4 100644 --- a/test/http-api/extra/bootstrap.js +++ b/test/http-api/extra/bootstrap.js @@ -5,8 +5,13 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const getCtl = require('./utils/get-ctl.js') -module.exports = (ctl) => { +module.exports = (http) => { + let ctl = null + before(() => { + ctl = getCtl(http) + }) describe('.bootstrap', () => { const invalidArg = 'this/Is/So/Invalid/' const validIp4 = '/ip4/101.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z' diff --git a/test/http-api/extra/config.js b/test/http-api/extra/config.js index 2a8b9081ed..6f4dcc868f 100644 --- a/test/http-api/extra/config.js +++ b/test/http-api/extra/config.js @@ -8,8 +8,13 @@ chai.use(dirtyChai) const fs = require('fs') const path = require('path') +const getCtl = require('./utils/get-ctl.js') -module.exports = (ctl) => { +module.exports = (http) => { + let ctl = null + before(() => { + ctl = getCtl(http) + }) describe('.config', () => { const configPath = path.join(__dirname, '../../repo-tests-run/config') diff --git a/test/http-api/extra/dns.js b/test/http-api/extra/dns.js index bb6ab6046f..f787d4cbf8 100644 --- a/test/http-api/extra/dns.js +++ b/test/http-api/extra/dns.js @@ -5,8 +5,13 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const getCtl = require('./utils/get-ctl.js') -module.exports = (ctl) => { +module.exports = (http) => { + let ctl = null + before(() => { + ctl = getCtl(http) + }) describe('.dns', () => { it('resolve ipfs.io dns', (done) => { ctl.dns('ipfs.io', (err, result) => { diff --git a/test/http-api/extra/id.js b/test/http-api/extra/id.js index 2e7b75e5d7..d0635da7a9 100644 --- a/test/http-api/extra/id.js +++ b/test/http-api/extra/id.js @@ -5,8 +5,13 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const getCtl = require('./utils/get-ctl.js') -module.exports = (ctl) => { +module.exports = (http) => { + let ctl = null + before(() => { + ctl = getCtl(http) + }) describe('.id', () => { it('get the identity', (done) => { ctl.id((err, result) => { diff --git a/test/http-api/extra/object.js b/test/http-api/extra/object.js index 913e0b3d08..d24a836867 100644 --- a/test/http-api/extra/object.js +++ b/test/http-api/extra/object.js @@ -10,6 +10,7 @@ chai.use(dirtyChai) const fs = require('fs') const dagPB = require('ipld-dag-pb') const DAGLink = dagPB.DAGLink +const getCtl = require('./utils/get-ctl.js') function asJson (cb) { return (err, result) => { @@ -19,7 +20,11 @@ function asJson (cb) { } } -module.exports = (ctl) => { +module.exports = (http) => { + let ctl = null + before(() => { + ctl = getCtl(http) + }) describe('.object', () => { it('.new', (done) => { ctl.object.new(asJson((err, res) => { diff --git a/test/http-api/extra/utils/get-ctl.js b/test/http-api/extra/utils/get-ctl.js new file mode 100644 index 0000000000..5867370928 --- /dev/null +++ b/test/http-api/extra/utils/get-ctl.js @@ -0,0 +1,5 @@ +'use strict' +const APIctl = require('ipfs-api') +module.exports = (http) => { + return APIctl(http.api.apiMultiaddr) +} diff --git a/test/http-api/extra/version.js b/test/http-api/extra/version.js index 0b5ec17136..2adb18ecd9 100644 --- a/test/http-api/extra/version.js +++ b/test/http-api/extra/version.js @@ -5,8 +5,13 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const getCtl = require('./utils/get-ctl.js') -module.exports = (ctl) => { +module.exports = (http) => { + let ctl = null + before(() => { + ctl = getCtl(http) + }) describe('.version', () => { it('get the version', (done) => { ctl.version((err, result) => { diff --git a/test/http-api/index.js b/test/http-api/index.js index 1fa11622ad..99c5a86adc 100644 --- a/test/http-api/index.js +++ b/test/http-api/index.js @@ -8,7 +8,6 @@ const expect = chai.expect chai.use(dirtyChai) const hat = require('hat') const API = require('../../src/http') -const APIctl = require('ipfs-api') const ncp = require('ncp').ncp const path = require('path') const clean = require('../utils/clean') @@ -19,9 +18,7 @@ describe('HTTP API', () => { let http = {} - before(function (done) { - this.timeout(60 * 1000) - + const startHttpAPI = (cb) => { const options = { pass: hat(), enablePubsubExperiment: true @@ -29,9 +26,27 @@ describe('HTTP API', () => { http.api = new API(repoTests, null, options) ncp(repoExample, repoTests, (err) => { - expect(err).to.not.exist() + if (err) { + return cb(err) + } + + http.api.start(false, (err) => { + if (err) { + return cb(err) + } + cb(null, http) + }) + }) + } - http.api.start(false, done) + before(function (done) { + this.timeout(60 * 1000) + startHttpAPI((err, _http) => { + if (err) { + throw err + } + http = _http + done() }) }) @@ -52,9 +67,13 @@ describe('HTTP API', () => { }) describe('## extra tests with ipfs-api', () => { - const ctl = APIctl('/ip4/127.0.0.1/tcp/6001') - fs.readdirSync(path.join(__dirname, '/extra')) - .forEach((file) => require('./extra/' + file)(ctl)) + .forEach((file) => { + // TODO(victor) want to make all this loading of tests proper, but for now + if (file.includes('utils')) { + return + } + require('./extra/' + file)(http) + }) }) }) diff --git a/test/utils/platforms.js b/test/utils/platforms.js new file mode 100644 index 0000000000..584452f97e --- /dev/null +++ b/test/utils/platforms.js @@ -0,0 +1,16 @@ +'use strict' + +const os = require('os') +const current = os.platform() + +module.exports = { + isWindows: () => { + return current === 'win32' + }, + isMacOS: () => { + return current === 'darwin' + }, + isLinux: () => { + return current === 'linux' + } +} From a9f089a37f7d53b6b3e2ca4bbbd702d51f5e605e Mon Sep 17 00:00:00 2001 From: victorbjelkholm Date: Fri, 23 Feb 2018 16:44:50 +0100 Subject: [PATCH 02/12] Reset timeouts --- test/cli/daemon.js | 2 +- test/core/bitswap.spec.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/cli/daemon.js b/test/cli/daemon.js index bf1493c103..fe43944f59 100644 --- a/test/cli/daemon.js +++ b/test/cli/daemon.js @@ -111,7 +111,7 @@ describe('daemon', () => { }) it('gives error if user hasn\'t run init before', function (done) { - this.timeout(30 * 1000) + this.timeout(100 * 1000) const expectedError = 'no initialized ipfs repo found in ' + repoPath diff --git a/test/core/bitswap.spec.js b/test/core/bitswap.spec.js index 028790e9b3..5f109ba847 100644 --- a/test/core/bitswap.spec.js +++ b/test/core/bitswap.spec.js @@ -144,7 +144,7 @@ skipOnWindows('bitswap', function () { }) afterEach(function (done) { - this.timeout(160 * 1000) + this.timeout(80 * 1000) const tasks = nodes.map((node) => (cb) => node.stop(cb)) parallel(tasks, (err) => { expect(err).to.not.exist() @@ -155,7 +155,7 @@ skipOnWindows('bitswap', function () { describe('transfer a block between', () => { it('2 peers', function (done) { - this.timeout(160 * 1000) + this.timeout(80 * 1000) let remoteNode let block @@ -179,7 +179,7 @@ skipOnWindows('bitswap', function () { }) it('3 peers', function (done) { - this.timeout(240 * 1000) + this.timeout(80 * 1000) let blocks const remoteNodes = [] @@ -254,7 +254,7 @@ skipOnWindows('bitswap', function () { let node before(function (done) { - this.timeout(80 * 1000) + this.timeout(40 * 1000) node = new IPFS({ repo: createTempRepo(), From 4416e6d6c4baf9f5404cefaa7f665252d9391642 Mon Sep 17 00:00:00 2001 From: victorbjelkholm Date: Fri, 23 Feb 2018 17:08:59 +0100 Subject: [PATCH 03/12] Remove aegir port --- test/core/bitswap.spec.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/core/bitswap.spec.js b/test/core/bitswap.spec.js index 5f109ba847..d9c9db978c 100644 --- a/test/core/bitswap.spec.js +++ b/test/core/bitswap.spec.js @@ -100,10 +100,8 @@ skipOnWindows('bitswap', function () { let fInProc before(function () { - // AEGIR_TEST_PORT is assigned in .aegir.js - const port = process.env.AEGIR_TEST_PORT - fDaemon = IPFSFactory.create({ type: 'js', port }) - fInProc = IPFSFactory.create({ type: 'proc', port }) + fDaemon = IPFSFactory.create({ type: 'js' }) + fInProc = IPFSFactory.create({ type: 'proc' }) }) beforeEach(function (done) { From 52cb801c806194f57a5434221e33bfaa0367c0ae Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Mon, 26 Feb 2018 06:58:29 -0600 Subject: [PATCH 04/12] feat: rework http-api tests to use ipfsd-ctl (#1234) * feat: rework http-api tests to use ipfsd-ctl * fix: copy repo * fix: revert fixture changes * fix: revert fixture changes * fix: remove unused todo --- test/http-api/extra/block.js | 37 ++++++++++----- test/http-api/extra/bootstrap.js | 50 +++++++++++++------- test/http-api/extra/config.js | 81 +++++++++++++++++++++++--------- test/http-api/extra/dns.js | 26 +++++++--- test/http-api/extra/id.js | 56 ++++++++++++++++++---- test/http-api/extra/index.js | 16 +++++++ test/http-api/extra/object.js | 81 ++++++++++++++++++-------------- test/http-api/extra/version.js | 26 +++++++--- test/http-api/index.js | 80 ++----------------------------- test/http-api/interface/block.js | 4 +- test/http-api/interface/index.js | 10 ++++ test/http-api/spec/index.js | 63 +++++++++++++++++++++++++ 12 files changed, 343 insertions(+), 187 deletions(-) create mode 100644 test/http-api/extra/index.js create mode 100644 test/http-api/interface/index.js create mode 100644 test/http-api/spec/index.js diff --git a/test/http-api/extra/block.js b/test/http-api/extra/block.js index d75712321d..642d626a68 100644 --- a/test/http-api/extra/block.js +++ b/test/http-api/extra/block.js @@ -8,13 +8,26 @@ chai.use(dirtyChai) const multihash = require('multihashes') const waterfall = require('async/waterfall') -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra block', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.block', () => { describe('.put', () => { it('updates value', (done) => { @@ -25,7 +38,7 @@ module.exports = (http) => { } waterfall([ - (cb) => ctl.block.put(data, cb), + (cb) => ipfs.block.put(data, cb), (block, cb) => { expect(block.cid.multihash).to.eql( multihash.fromB58String(expectedResult.key) @@ -38,14 +51,14 @@ module.exports = (http) => { describe('.get', () => { it('returns error for request with invalid argument', (done) => { - ctl.block.get('invalid', (err, result) => { + ipfs.block.get('invalid', (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.block.get('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', (err, result) => { + ipfs.block.get('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', (err, result) => { expect(err).to.not.exist() expect(result.data.toString()) .to.equal('hello world\n') @@ -56,21 +69,21 @@ module.exports = (http) => { describe('.stat', () => { it('returns error for request without argument', (done) => { - ctl.block.stat(null, (err, result) => { + ipfs.block.stat(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.block.stat('invalid', (err, result) => { + ipfs.block.stat('invalid', (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.block.stat('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', (err, result) => { + ipfs.block.stat('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', (err, result) => { expect(err).to.not.exist() expect(result.key) .to.equal('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp') @@ -80,4 +93,4 @@ module.exports = (http) => { }) }) }) -} +}) diff --git a/test/http-api/extra/bootstrap.js b/test/http-api/extra/bootstrap.js index a0ab204cf4..b14075393c 100644 --- a/test/http-api/extra/bootstrap.js +++ b/test/http-api/extra/bootstrap.js @@ -1,3 +1,4 @@ +/* eslint max-nested-callbacks: ["error", 8] */ /* eslint-env mocha */ 'use strict' @@ -5,13 +6,26 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra bootstrap', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.bootstrap', () => { const invalidArg = 'this/Is/So/Invalid/' const validIp4 = '/ip4/101.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z' @@ -21,14 +35,14 @@ module.exports = (http) => { this.timeout(40 * 1000) it('returns an error when called with an invalid arg', (done) => { - ctl.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) => { - ctl.bootstrap.add(validIp4, (err, res) => { + ipfs.bootstrap.add(validIp4, (err, res) => { expect(err).to.not.exist() expect(res).to.be.eql({ Peers: [validIp4] }) done() @@ -36,20 +50,20 @@ module.exports = (http) => { }) it('prevents duplicate inserts of bootstrap peers', () => { - return ctl + return ipfs .bootstrap .rm(null, { all: true }) .then((res) => { expect(res.Peers.length).to.equal(0) - return ctl.bootstrap.add(validIp4) + return ipfs.bootstrap.add(validIp4) }) .then(res => { expect(res).to.be.eql({ Peers: [validIp4] }) - return ctl.bootstrap.add(validIp4) + return ipfs.bootstrap.add(validIp4) }) .then((res) => { expect(res).to.be.eql({ Peers: [validIp4] }) - return ctl.bootstrap.list() + return ipfs.bootstrap.list() }) .then((res) => { expect(res).to.exist() @@ -60,7 +74,7 @@ module.exports = (http) => { }) it('returns a list of bootstrap peers when called with the default option', (done) => { - ctl.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() @@ -72,7 +86,7 @@ module.exports = (http) => { describe('.list', () => { it('returns a list of peers', (done) => { - ctl.bootstrap.list((err, res) => { + ipfs.bootstrap.list((err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -83,14 +97,14 @@ module.exports = (http) => { describe('.rm', () => { it('returns an error when called with an invalid arg', (done) => { - ctl.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) => { - ctl.bootstrap.rm(null, (err, res) => { + ipfs.bootstrap.rm(null, (err, res) => { expect(err).to.not.exist() peers = res.Peers expect(peers).to.exist() @@ -100,7 +114,7 @@ module.exports = (http) => { }) it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => { - ctl.bootstrap.rm(validIp4, (err, res) => { + ipfs.bootstrap.rm(validIp4, (err, res) => { expect(err).to.not.exist() peers = res.Peers @@ -111,7 +125,7 @@ module.exports = (http) => { }) it('returns list of all peers removed when all option is passed', (done) => { - ctl.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,4 +134,4 @@ module.exports = (http) => { }) }) }) -} +}) diff --git a/test/http-api/extra/config.js b/test/http-api/extra/config.js index 6f4dcc868f..0d9ae6e907 100644 --- a/test/http-api/extra/config.js +++ b/test/http-api/extra/config.js @@ -6,33 +6,72 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) +const ncp = require('ncp').ncp +const rimraf = require('rimraf') +const waterfall = require('async/waterfall') + const fs = require('fs') const path = require('path') -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) - }) - describe('.config', () => { - const configPath = path.join(__dirname, '../../repo-tests-run/config') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra config', () => { + const repoExample = path.join(__dirname, '../../fixtures/go-ipfs-repo') + const repoTests = path.join(__dirname, '../../repo-tests-run') + + let updatedConfig = null + + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + + ncp(repoExample, repoTests, (err) => { + expect(err).to.not.exist() + + waterfall([ + (cb) => df.spawn({ + repoPath: repoTests, + initOptions: { bits: 512 }, + disposable: false, + start: true + }, cb), + (_ipfsd, cb) => { + ipfsd = _ipfsd + ipfsd.start(cb) + } + ], (err) => { + expect(err).to.not.exist() + ipfs = ipfsd.api + + updatedConfig = () => { + const file = fs.readFileSync(path.join(__dirname, '../../repo-tests-run/config')) + return JSON.parse(file, 'utf8') + } - let updatedConfig + done() + }) + }) + }) - before(() => { - updatedConfig = () => JSON.parse(fs.readFileSync(configPath, 'utf8')) + after((done) => { + rimraf(repoTests, (err) => { + expect(err).to.not.exist() + ipfsd.stop(done) }) + }) + describe('.config', () => { it('.get returns error for request with invalid argument', (done) => { - ctl.config.get('kittens', (err, res) => { + ipfs.config.get('kittens', (err, res) => { expect(err).to.exist() done() }) }) it('.get returns value for request with argument', (done) => { - ctl.config.get('API.HTTPHeaders', (err, value) => { + ipfs.config.get('API.HTTPHeaders', (err, value) => { expect(err).not.to.exist() expect(value).to.equal(null) done() @@ -40,35 +79,35 @@ module.exports = (http) => { }) it('.set updates value for request with both args', (done) => { - ctl.config.set('Datastore.Path', 'kitten', (err) => { + ipfs.config.set('Datastore.Path', 'kitten', (err) => { expect(err).not.to.exist() done() }) }) it('.set returns error for request with both args and JSON flag with invalid JSON argument', (done) => { - ctl.config.set('Datastore.Path', 'kitten', { json: true }, (err) => { + ipfs.config.set('Datastore.Path', 'kitten', { json: true }, (err) => { expect(err).to.exist() done() }) }) it('.set updates value for request with both args and bool flag and true argument', (done) => { - ctl.config.set('Datastore.Path', true, (err) => { + ipfs.config.set('Datastore.Path', true, (err) => { expect(err).not.to.exist() done() }) }) it('.set updates value for request with both args and bool flag and false argument', (done) => { - ctl.config.set('Datastore.Path', false, (err) => { + ipfs.config.set('Datastore.Path', false, (err) => { expect(err).not.to.exist() done() }) }) it('.get updatedConfig', (done) => { - ctl.config.get((err, config) => { + ipfs.config.get((err, config) => { expect(err).not.to.exist() expect(config).to.be.eql(updatedConfig()) done() @@ -81,7 +120,7 @@ module.exports = (http) => { it('returns error if the config is invalid', (done) => { const filePath = 'test/fixtures/test-data/badconfig' - ctl.config.replace(filePath, (err) => { + ipfs.config.replace(filePath, (err) => { expect(err).to.exist() done() }) @@ -91,7 +130,7 @@ module.exports = (http) => { const filePath = 'test/fixtures/test-data/otherconfig' const expectedConfig = JSON.parse(fs.readFileSync(filePath, 'utf8')) - ctl.config.replace(filePath, (err) => { + ipfs.config.replace(filePath, (err) => { expect(err).not.to.exist() expect(expectedConfig).to.deep.equal(updatedConfig()) done() @@ -99,4 +138,4 @@ module.exports = (http) => { }) }) }) -} +}) diff --git a/test/http-api/extra/dns.js b/test/http-api/extra/dns.js index f787d4cbf8..365dca73a2 100644 --- a/test/http-api/extra/dns.js +++ b/test/http-api/extra/dns.js @@ -5,20 +5,32 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra dns', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.dns', () => { it('resolve ipfs.io dns', (done) => { - ctl.dns('ipfs.io', (err, result) => { + ipfs.dns('ipfs.io', (err, result) => { expect(err).to.not.exist() expect(result).to.exist() done() }) }) }) -} +}) diff --git a/test/http-api/extra/id.js b/test/http-api/extra/id.js index d0635da7a9..3ee69bc4a1 100644 --- a/test/http-api/extra/id.js +++ b/test/http-api/extra/id.js @@ -5,16 +5,56 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const ncp = require('ncp').ncp +const rimraf = require('rimraf') +const waterfall = require('async/waterfall') +const path = require('path') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra id', () => { + const repoExample = path.join(__dirname, '../../fixtures/go-ipfs-repo') + const repoTests = path.join(__dirname, '../../repo-tests-run') + + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + + ncp(repoExample, repoTests, (err) => { + expect(err).to.not.exist() + + waterfall([ + (cb) => df.spawn({ + repoPath: path.join(__dirname, '../../fixtures/go-ipfs-repo'), + initOptions: { bits: 512 }, + disposable: false, + start: true + }, cb), + (_ipfsd, cb) => { + ipfsd = _ipfsd + ipfsd.start(cb) + } + ], (err) => { + expect(err).to.not.exist() + ipfs = ipfsd.api + done() + }) + }) }) + + after((done) => { + rimraf(repoTests, (err) => { + expect(err).to.not.exist() + ipfsd.stop(done) + }) + }) + describe('.id', () => { it('get the identity', (done) => { - ctl.id((err, result) => { + ipfs.id((err, result) => { expect(err).to.not.exist() expect(result.id).to.equal(idResult.ID) expect(result.publicKey).to.equal(idResult.PublicKey) @@ -26,12 +66,12 @@ module.exports = (http) => { }) }) }) -} +}) const idResult = { ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A', PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=', - Addresses: [ '/ip4/0.0.0.0/tcp/0' ], + Addresses: ['/ip4/0.0.0.0/tcp/0'], AgentVersion: 'js-ipfs', ProtocolVersion: '9000' } diff --git a/test/http-api/extra/index.js b/test/http-api/extra/index.js new file mode 100644 index 0000000000..fff181e750 --- /dev/null +++ b/test/http-api/extra/index.js @@ -0,0 +1,16 @@ +/* eslint-env mocha */ +'use strict' + +const fs = require('fs') +const path = require('path') + +describe('## extra tests with ipfs-api', () => { + fs.readdirSync(path.join(__dirname)) + .forEach((file) => { + // TODO(victor) want to make all this loading of tests proper, but for now + if (file.includes('utils') || file.includes('index.js')) { + return + } + require(`./${file}`) + }) +}) diff --git a/test/http-api/extra/object.js b/test/http-api/extra/object.js index d24a836867..eced7f28f6 100644 --- a/test/http-api/extra/object.js +++ b/test/http-api/extra/object.js @@ -10,7 +10,9 @@ chai.use(dirtyChai) const fs = require('fs') const dagPB = require('ipld-dag-pb') const DAGLink = dagPB.DAGLink -const getCtl = require('./utils/get-ctl.js') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) function asJson (cb) { return (err, result) => { @@ -20,14 +22,25 @@ function asJson (cb) { } } -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +describe('extra object', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.object', () => { it('.new', (done) => { - ctl.object.new(asJson((err, res) => { + ipfs.object.new(asJson((err, res) => { expect(err).to.not.exist() expect(res.multihash) .to.equal('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n') @@ -38,21 +51,21 @@ module.exports = (http) => { describe('.get', () => { it('returns error for request without argument', (done) => { - ctl.object.get(null, (err, result) => { + ipfs.object.get(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.object.get('invalid', {enc: 'base58'}, (err, result) => { + ipfs.object.get('invalid', { enc: 'base58' }, (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.object.get('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n', {enc: 'base58'}, asJson((err, res) => { + ipfs.object.get('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n', { enc: 'base58' }, asJson((err, res) => { expect(err).to.not.exist() expect(res.links).to.be.eql([]) expect(res.data).to.eql(Buffer.from('')) @@ -65,7 +78,7 @@ module.exports = (http) => { it('returns error if the node is invalid', (done) => { const filePath = 'test/fixtures/test-data/badnode.json' - ctl.object.put(filePath, {enc: 'json'}, (err) => { + ipfs.object.put(filePath, { enc: 'json' }, (err) => { expect(err).to.exist() done() }) @@ -84,7 +97,7 @@ module.exports = (http) => { size: 68 } - ctl.object.put(filePath, {enc: 'json'}, asJson((err, res) => { + ipfs.object.put(filePath, { enc: 'json' }, asJson((err, res) => { expect(err).to.not.exist() expect(res).to.eql(expectedResult) done() @@ -94,21 +107,21 @@ module.exports = (http) => { describe('.stat', () => { it('returns error for request without argument', (done) => { - ctl.object.stat(null, (err, result) => { + ipfs.object.stat(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.object.stat('invalid', {enc: 'base58'}, (err, result) => { + ipfs.object.stat('invalid', { enc: 'base58' }, (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.object.stat('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', {enc: 'base58'}, (err, result) => { + ipfs.object.stat('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', { enc: 'base58' }, (err, result) => { expect(err).to.not.exist() expect(result.Hash).to.equal('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm') expect(result.NumLinks).to.equal(1) @@ -123,21 +136,21 @@ module.exports = (http) => { describe('.data', () => { it('returns error for request without argument', (done) => { - ctl.object.data(null, (err, result) => { + ipfs.object.data(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.object.data('invalid', {enc: 'base58'}, (err, result) => { + ipfs.object.data('invalid', { enc: 'base58' }, (err, result) => { expect(err).to.exist() done() }) }) it('returns value', (done) => { - ctl.object.data('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', {enc: 'base58'}, (err, result) => { + ipfs.object.data('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', { enc: 'base58' }, (err, result) => { expect(err).to.not.exist() expect(result.toString()).to.equal('another') done() @@ -147,14 +160,14 @@ module.exports = (http) => { describe('.links', () => { it('returns error for request without argument', (done) => { - ctl.object.links(null, (err, result) => { + ipfs.object.links(null, (err, result) => { expect(err).to.exist() done() }) }) it('returns error for request with invalid argument', (done) => { - ctl.object.links('invalid', {enc: 'base58'}, (err, result) => { + ipfs.object.links('invalid', { enc: 'base58' }, (err, result) => { expect(err).to.exist() done() }) @@ -167,7 +180,7 @@ module.exports = (http) => { size: 8 } - ctl.object.links('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', {enc: 'base58'}, (err, result) => { + ipfs.object.links('QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm', { enc: 'base58' }, (err, result) => { expect(err).to.not.exist() expect(result[0].toJSON()).to.deep.equal(expectedResult) done() @@ -177,7 +190,7 @@ module.exports = (http) => { describe('.patch.appendData', () => { it('returns error for request without key & data', (done) => { - ctl.object.patch.appendData(null, null, (err) => { + ipfs.object.patch.appendData(null, null, (err) => { expect(err).to.exist() done() }) @@ -186,7 +199,7 @@ module.exports = (http) => { it('returns error for request without data', (done) => { const filePath = 'test/fixtures/test-data/badnode.json' - ctl.object.patch.appendData(null, filePath, (err) => { + ipfs.object.patch.appendData(null, filePath, (err) => { expect(err).to.exist() done() }) @@ -202,7 +215,7 @@ module.exports = (http) => { size: 19 } - ctl.object.patch.appendData(key, filePath, {enc: 'base58'}, asJson((err, res) => { + ipfs.object.patch.appendData(key, filePath, { enc: 'base58' }, asJson((err, res) => { expect(err).to.not.exist() expect(res).to.eql(expectedResult) done() @@ -212,7 +225,7 @@ module.exports = (http) => { describe('.patch.setData', () => { it('returns error for request without key & data', (done) => { - ctl.object.patch.setData(null, null, (err) => { + ipfs.object.patch.setData(null, null, (err) => { expect(err).to.exist() done() }) @@ -221,7 +234,7 @@ module.exports = (http) => { it('returns error for request without data', (done) => { const filePath = 'test/fixtures/test-data/badnode.json' - ctl.object.patch.setData(null, filePath, (err) => { + ipfs.object.patch.setData(null, filePath, (err) => { expect(err).to.exist() done() }) @@ -237,7 +250,7 @@ module.exports = (http) => { size: 19 } - ctl.object.patch.setData(key, filePath, {enc: 'base58'}, asJson((err, res) => { + ipfs.object.patch.setData(key, filePath, { enc: 'base58' }, asJson((err, res) => { expect(err).to.not.exist() expect(res).to.eql(expectedResult) done() @@ -247,14 +260,14 @@ module.exports = (http) => { describe('.patch.addLink', () => { it('returns error for request without arguments', (done) => { - ctl.object.patch.addLink(null, null, null, (err) => { + ipfs.object.patch.addLink(null, null, null, (err) => { expect(err).to.exist() done() }) }) it('returns error for request only one invalid argument', (done) => { - ctl.object.patch.addLink('invalid', null, null, (err) => { + ipfs.object.patch.addLink('invalid', null, null, (err) => { expect(err).to.exist() done() }) @@ -265,7 +278,7 @@ module.exports = (http) => { const name = '' const ref = 'QmTz3oc4gdpRMKP2sdGUPZTAGRngqjsi99BPoztyP53JMM' const link = new DAGLink(name, 2, ref) - ctl.object.patch.addLink(root, link, {enc: 'base58'}, (err) => { + ipfs.object.patch.addLink(root, link, { enc: 'base58' }, (err) => { expect(err).to.exist() done() }) @@ -276,7 +289,7 @@ module.exports = (http) => { const name = 'foo' const ref = 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn' const link = new DAGLink(name, 10, ref) - ctl.object.patch.addLink(root, link, {enc: 'base58'}, asJson((err, res) => { + ipfs.object.patch.addLink(root, link, { enc: 'base58' }, asJson((err, res) => { expect(err).not.to.exist() expect(res.multihash).to.equal('QmdVHE8fUD6FLNLugtNxqDFyhaCgdob372hs6BYEe75VAK') expect(res.links[0]).to.eql({ @@ -291,14 +304,14 @@ module.exports = (http) => { describe('.patch.rmLink', () => { it('returns error for request without arguments', (done) => { - ctl.object.patch.rmLink(null, null, (err) => { + ipfs.object.patch.rmLink(null, null, (err) => { expect(err).to.exist() done() }) }) it('returns error for request only one invalid argument', (done) => { - ctl.object.patch.rmLink('invalid', null, (err) => { + ipfs.object.patch.rmLink('invalid', null, (err) => { expect(err).to.exist() done() }) @@ -308,11 +321,11 @@ module.exports = (http) => { const root = '' const link = 'foo' - ctl.object.patch.rmLink(root, link, (err) => { + ipfs.object.patch.rmLink(root, link, (err) => { expect(err).to.exist() done() }) }) }) }) -} +}) diff --git a/test/http-api/extra/version.js b/test/http-api/extra/version.js index 2adb18ecd9..8a22deff0d 100644 --- a/test/http-api/extra/version.js +++ b/test/http-api/extra/version.js @@ -5,16 +5,28 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const getCtl = require('./utils/get-ctl.js') -module.exports = (http) => { - let ctl = null - before(() => { - ctl = getCtl(http) +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) + +describe('extra version', () => { + let ipfs = null + let ipfsd = null + before(function (done) { + this.timeout(20 * 1000) + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = ipfsd.api + done() + }) }) + + after((done) => ipfsd.stop(done)) + describe('.version', () => { it('get the version', (done) => { - ctl.version((err, result) => { + ipfs.version((err, result) => { expect(err).to.not.exist() expect(result).to.have.a.property('version') expect(result).to.have.a.property('commit') @@ -23,4 +35,4 @@ module.exports = (http) => { }) }) }) -} +}) diff --git a/test/http-api/index.js b/test/http-api/index.js index 99c5a86adc..0d6941e9dd 100644 --- a/test/http-api/index.js +++ b/test/http-api/index.js @@ -1,79 +1,5 @@ -/* eslint-env mocha */ 'use strict' -const fs = require('fs') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) -const hat = require('hat') -const API = require('../../src/http') -const ncp = require('ncp').ncp -const path = require('path') -const clean = require('../utils/clean') - -describe('HTTP API', () => { - const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo') - const repoTests = path.join(__dirname, '../repo-tests-run') - - let http = {} - - const startHttpAPI = (cb) => { - const options = { - pass: hat(), - enablePubsubExperiment: true - } - http.api = new API(repoTests, null, options) - - ncp(repoExample, repoTests, (err) => { - if (err) { - return cb(err) - } - - http.api.start(false, (err) => { - if (err) { - return cb(err) - } - cb(null, http) - }) - }) - } - - before(function (done) { - this.timeout(60 * 1000) - startHttpAPI((err, _http) => { - if (err) { - throw err - } - http = _http - done() - }) - }) - - after((done) => http.api.stop((err) => { - expect(err).to.not.exist() - clean(repoTests) - done() - })) - - describe('## http-api spec tests', () => { - fs.readdirSync(path.join(__dirname, '/spec')) - .forEach((file) => require('./spec/' + file)(http)) - }) - - describe('## interface-ipfs-core over ipfs-api', () => { - fs.readdirSync(path.join(__dirname, '/interface')) - .forEach((file) => require('./interface/' + file)) - }) - - describe('## extra tests with ipfs-api', () => { - fs.readdirSync(path.join(__dirname, '/extra')) - .forEach((file) => { - // TODO(victor) want to make all this loading of tests proper, but for now - if (file.includes('utils')) { - return - } - require('./extra/' + file)(http) - }) - }) -}) +require('./spec') +require('./interface') +require('./extra') diff --git a/test/http-api/interface/block.js b/test/http-api/interface/block.js index a3a7717f03..ef9e63f370 100644 --- a/test/http-api/interface/block.js +++ b/test/http-api/interface/block.js @@ -12,9 +12,7 @@ const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn({ - initOptions: { bits: 512 } - }, (err, _ipfsd) => { + df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/http-api/interface/index.js b/test/http-api/interface/index.js new file mode 100644 index 0000000000..7239f09e3a --- /dev/null +++ b/test/http-api/interface/index.js @@ -0,0 +1,10 @@ +/* eslint-env mocha */ +'use strict' + +const fs = require('fs') +const path = require('path') + +describe('## interface-ipfs-core over ipfs-api', () => { + fs.readdirSync(path.join(__dirname)) + .forEach((file) => file !== 'index.js' && require(`./${file}`)) +}) diff --git a/test/http-api/spec/index.js b/test/http-api/spec/index.js new file mode 100644 index 0000000000..24d94ebc4e --- /dev/null +++ b/test/http-api/spec/index.js @@ -0,0 +1,63 @@ +/* eslint-env mocha */ +'use strict' + +const fs = require('fs') +const chai = require('chai') +const dirtyChai = require('dirty-chai') +const expect = chai.expect +chai.use(dirtyChai) +const hat = require('hat') +const API = require('../../../src/http/index') +const ncp = require('ncp').ncp +const path = require('path') +const clean = require('../../utils/clean') + +describe('HTTP API', () => { + const repoExample = path.join(__dirname, '../../fixtures/go-ipfs-repo') + const repoTests = path.join(__dirname, '../../repo-tests-run') + + let http = {} + + const startHttpAPI = (cb) => { + const options = { + pass: hat(), + enablePubsubExperiment: true + } + http.api = new API(repoTests, null, options) + + ncp(repoExample, repoTests, (err) => { + if (err) { + return cb(err) + } + + http.api.start(false, (err) => { + if (err) { + return cb(err) + } + cb(null, http) + }) + }) + } + + before(function (done) { + this.timeout(60 * 1000) + startHttpAPI((err, _http) => { + if (err) { + throw err + } + http = _http + done() + }) + }) + + after((done) => http.api.stop((err) => { + expect(err).to.not.exist() + clean(repoTests) + done() + })) + + describe('## http-api spec tests', () => { + fs.readdirSync(path.join(__dirname)) + .forEach((file) => file !== 'index.js' && require(`./${file}`)(http)) + }) +}) From 6c2a09bd64cd1e229cd16b140b137677b82cd42c Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 26 Feb 2018 08:14:23 -0500 Subject: [PATCH 05/12] chore: reorg http-api tests --- test/fixtures/go-ipfs-repo/blocks/_README | 8 -- test/fixtures/go-ipfs-repo/config | 112 ++++++++++-------- test/fixtures/go-ipfs-repo/datastore/CURRENT | 2 +- test/fixtures/go-ipfs-repo/datastore/LOG | 30 +---- test/fixtures/go-ipfs-repo/datastore/LOG.old | 39 ++++-- .../{MANIFEST-000014 => MANIFEST-000015} | Bin 314 -> 323 bytes test/http-api/{extra => }/block.js | 3 +- test/http-api/{extra => }/bootstrap.js | 2 +- test/http-api/{extra => }/config.js | 8 +- test/http-api/{extra => }/dns.js | 2 +- test/http-api/extra/index.js | 16 --- test/http-api/{extra => }/id.js | 8 +- test/http-api/index.js | 10 +- test/http-api/{spec => inject}/bitswap.js | 0 test/http-api/{spec => inject}/block.js | 0 test/http-api/{spec => inject}/bootstrap.js | 0 test/http-api/{spec => inject}/config.js | 0 test/http-api/{spec => inject}/dns.js | 0 test/http-api/{spec => inject}/files.js | 0 test/http-api/{spec => inject}/id.js | 0 test/http-api/{spec => inject}/index.js | 0 test/http-api/{spec => inject}/object.js | 0 test/http-api/{spec => inject}/pubsub.js | 0 test/http-api/{spec => inject}/version.js | 0 test/http-api/{extra => }/object.js | 2 +- test/http-api/{extra => }/utils/get-ctl.js | 2 + test/http-api/{extra => }/version.js | 2 +- 27 files changed, 115 insertions(+), 131 deletions(-) rename test/fixtures/go-ipfs-repo/datastore/{MANIFEST-000014 => MANIFEST-000015} (79%) rename test/http-api/{extra => }/block.js (98%) rename test/http-api/{extra => }/bootstrap.js (99%) rename test/http-api/{extra => }/config.js (94%) rename test/http-api/{extra => }/dns.js (95%) delete mode 100644 test/http-api/extra/index.js rename test/http-api/{extra => }/id.js (89%) rename test/http-api/{spec => inject}/bitswap.js (100%) rename test/http-api/{spec => inject}/block.js (100%) rename test/http-api/{spec => inject}/bootstrap.js (100%) rename test/http-api/{spec => inject}/config.js (100%) rename test/http-api/{spec => inject}/dns.js (100%) rename test/http-api/{spec => inject}/files.js (100%) rename test/http-api/{spec => inject}/id.js (100%) rename test/http-api/{spec => inject}/index.js (100%) rename test/http-api/{spec => inject}/object.js (100%) rename test/http-api/{spec => inject}/pubsub.js (100%) rename test/http-api/{spec => inject}/version.js (100%) rename test/http-api/{extra => }/object.js (99%) rename test/http-api/{extra => }/utils/get-ctl.js (98%) rename test/http-api/{extra => }/version.js (96%) diff --git a/test/fixtures/go-ipfs-repo/blocks/_README b/test/fixtures/go-ipfs-repo/blocks/_README index 23cb090956..ac3b6034c3 100644 --- a/test/fixtures/go-ipfs-repo/blocks/_README +++ b/test/fixtures/go-ipfs-repo/blocks/_README @@ -6,25 +6,17 @@ All the object files are placed in a tree of directories, based on a function of the CID. This is a form of sharding similar to the objects directory in git repositories. Previously, we used prefixes, we now use the next-to-last two charters. - func NextToLast(base32cid string) { nextToLastLen := 2 offset := len(base32cid) - nextToLastLen - 1 return str[offset : offset+nextToLastLen] } - For example, an object with a base58 CIDv1 of - zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f - has a base32 CIDv1 of - BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA - and will be placed at - SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data - with 'SC' being the last-to-next two characters and the 'B' at the beginning of the CIDv1 string is the multibase prefix that is not stored in the filename. diff --git a/test/fixtures/go-ipfs-repo/config b/test/fixtures/go-ipfs-repo/config index e5d9f80cbc..00f467f95f 100644 --- a/test/fixtures/go-ipfs-repo/config +++ b/test/fixtures/go-ipfs-repo/config @@ -1,52 +1,52 @@ -{ - "Identity":{ - "PeerID":"QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A", - "PrivKey":"CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAECggEAZtju/bcKvKFPz0mkHiaJcpycy9STKphorpCT83srBVQi59CdFU6Mj+aL/xt0kCPMVigJw8P3/YCEJ9J+rS8BsoWE+xWUEsJvtXoT7vzPHaAtM3ci1HZd302Mz1+GgS8Epdx+7F5p80XAFLDUnELzOzKftvWGZmWfSeDnslwVONkL/1VAzwKy7Ce6hk4SxRE7l2NE2OklSHOzCGU1f78ZzVYKSnS5Ag9YrGjOAmTOXDbKNKN/qIorAQ1bovzGoCwx3iGIatQKFOxyVCyO1PsJYT7JO+kZbhBWRRE+L7l+ppPER9bdLFxs1t5CrKc078h+wuUr05S1P1JjXk68pk3+kQKBgQDeK8AR11373Mzib6uzpjGzgNRMzdYNuExWjxyxAzz53NAR7zrPHvXvfIqjDScLJ4NcRO2TddhXAfZoOPVH5k4PJHKLBPKuXZpWlookCAyENY7+Pd55S8r+a+MusrMagYNljb5WbVTgN8cgdpim9lbbIFlpN6SZaVjLQL3J8TWH6wKBgQDSChzItkqWX11CNstJ9zJyUE20I7LrpyBJNgG1gtvz3ZMUQCn3PxxHtQzN9n1P0mSSYs+jBKPuoSyYLt1wwe10/lpgL4rkKWU3/m1Myt0tveJ9WcqHh6tzcAbb/fXpUFT/o4SWDimWkPkuCb+8j//2yiXk0a/T2f36zKMuZvujqQKBgC6B7BAQDG2H2B/ijofp12ejJU36nL98gAZyqOfpLJ+FeMz4TlBDQ+phIMhnHXA5UkdDapQ+zA3SrFk+6yGk9Vw4Hf46B+82SvOrSbmnMa+PYqKYIvUzR4gg34rL/7AhwnbEyD5hXq4dHwMNsIDq+l2elPjwm/U9V0gdAl2+r50HAoGALtsKqMvhv8HucAMBPrLikhXP/8um8mMKFMrzfqZ+otxfHzlhI0L08Bo3jQrb0Z7ByNY6M8epOmbCKADsbWcVre/AAY0ZkuSZK/CaOXNX/AhMKmKJh8qAOPRY02LIJRBCpfS4czEdnfUhYV/TYiFNnKRj57PPYZdTzUsxa/yVTmECgYBr7slQEjb5Onn5mZnGDh+72BxLNdgwBkhO0OCdpdISqk0F0Pxby22DFOKXZEpiyI9XYP1C8wPiJsShGm2yEwBPWXnrrZNWczaVuCbXHrZkWQogBDG3HGXNdU4MAWCyiYlyinIBpPpoAJZSzpGLmWbMWh28+RJS6AQX6KHrK1o2uw==" +{ + "Identity": { + "PeerID": "QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A", + "PrivKey": "CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAECggEAZtju/bcKvKFPz0mkHiaJcpycy9STKphorpCT83srBVQi59CdFU6Mj+aL/xt0kCPMVigJw8P3/YCEJ9J+rS8BsoWE+xWUEsJvtXoT7vzPHaAtM3ci1HZd302Mz1+GgS8Epdx+7F5p80XAFLDUnELzOzKftvWGZmWfSeDnslwVONkL/1VAzwKy7Ce6hk4SxRE7l2NE2OklSHOzCGU1f78ZzVYKSnS5Ag9YrGjOAmTOXDbKNKN/qIorAQ1bovzGoCwx3iGIatQKFOxyVCyO1PsJYT7JO+kZbhBWRRE+L7l+ppPER9bdLFxs1t5CrKc078h+wuUr05S1P1JjXk68pk3+kQKBgQDeK8AR11373Mzib6uzpjGzgNRMzdYNuExWjxyxAzz53NAR7zrPHvXvfIqjDScLJ4NcRO2TddhXAfZoOPVH5k4PJHKLBPKuXZpWlookCAyENY7+Pd55S8r+a+MusrMagYNljb5WbVTgN8cgdpim9lbbIFlpN6SZaVjLQL3J8TWH6wKBgQDSChzItkqWX11CNstJ9zJyUE20I7LrpyBJNgG1gtvz3ZMUQCn3PxxHtQzN9n1P0mSSYs+jBKPuoSyYLt1wwe10/lpgL4rkKWU3/m1Myt0tveJ9WcqHh6tzcAbb/fXpUFT/o4SWDimWkPkuCb+8j//2yiXk0a/T2f36zKMuZvujqQKBgC6B7BAQDG2H2B/ijofp12ejJU36nL98gAZyqOfpLJ+FeMz4TlBDQ+phIMhnHXA5UkdDapQ+zA3SrFk+6yGk9Vw4Hf46B+82SvOrSbmnMa+PYqKYIvUzR4gg34rL/7AhwnbEyD5hXq4dHwMNsIDq+l2elPjwm/U9V0gdAl2+r50HAoGALtsKqMvhv8HucAMBPrLikhXP/8um8mMKFMrzfqZ+otxfHzlhI0L08Bo3jQrb0Z7ByNY6M8epOmbCKADsbWcVre/AAY0ZkuSZK/CaOXNX/AhMKmKJh8qAOPRY02LIJRBCpfS4czEdnfUhYV/TYiFNnKRj57PPYZdTzUsxa/yVTmECgYBr7slQEjb5Onn5mZnGDh+72BxLNdgwBkhO0OCdpdISqk0F0Pxby22DFOKXZEpiyI9XYP1C8wPiJsShGm2yEwBPWXnrrZNWczaVuCbXHrZkWQogBDG3HGXNdU4MAWCyiYlyinIBpPpoAJZSzpGLmWbMWh28+RJS6AQX6KHrK1o2uw==" }, - "Datastore":{ - "Type":"", - "Path":"", - "StorageMax":"", - "StorageGCWatermark":0, - "GCPeriod":"", - "Params":null, - "NoSync":false + "Datastore": { + "Type": "", + "Path": "", + "StorageMax": "", + "StorageGCWatermark": 0, + "GCPeriod": "", + "Params": null, + "NoSync": false }, - "Addresses":{ - "Swarm":[ + "Addresses": { + "Swarm": [ "/ip4/127.0.0.1/tcp/0", "/ip4/127.0.0.1/tcp/0/ws" ], - "API":"/ip4/127.0.0.1/tcp/0", - "Gateway":"/ip4/127.0.0.1/tcp/0" + "API": "/ip4/127.0.0.1/tcp/0", + "Gateway": "/ip4/127.0.0.1/tcp/0" }, - "Mounts":{ - "IPFS":"/ipfs", - "IPNS":"/ipns", - "FuseAllowOther":false + "Mounts": { + "IPFS": "/ipfs", + "IPNS": "/ipns", + "FuseAllowOther": false }, - "Version":{ - "Current":"0.4.0-dev", - "Check":"error", - "CheckDate":"0001-01-01T00:00:00Z", - "CheckPeriod":"172800000000000", - "AutoUpdate":"minor" + "Version": { + "Current": "0.4.0-dev", + "Check": "error", + "CheckDate": "0001-01-01T00:00:00Z", + "CheckPeriod": "172800000000000", + "AutoUpdate": "minor" }, - "Discovery":{ - "MDNS":{ - "Enabled":false, - "Interval":10 + "Discovery": { + "MDNS": { + "Enabled": false, + "Interval": 10 }, "webRTCStar": { "Enabled": false } }, - "Ipns":{ - "RepublishPeriod":"", - "RecordLifetime":"", - "ResolveCacheSize":128 + "Ipns": { + "RepublishPeriod": "", + "RecordLifetime": "", + "ResolveCacheSize": 128 }, - "Bootstrap":[ + "Bootstrap": [ "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z", "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", @@ -67,16 +67,16 @@ "/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic", "/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6" ], - "Tour":{ - "Last":"" + "Tour": { + "Last": "" }, - "Gateway":{ - "HTTPHeaders":null, - "RootRedirect":"", - "Writable":false + "Gateway": { + "HTTPHeaders": null, + "RootRedirect": "", + "Writable": false }, - "SupernodeRouting":{ - "Servers":[ + "SupernodeRouting": { + "Servers": [ "/ip4/104.236.176.52/tcp/4002/ipfs/QmXdb7tWTxdFEQEFgWBqkuYSrZd3mXrC7HxkD4krGNYx2U", "/ip4/104.236.179.241/tcp/4002/ipfs/QmVRqViDByUxjUMoPnjurjKvZhaEMFDtK35FJXHAM4Lkj6", "/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH", @@ -87,15 +87,23 @@ "/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN" ] }, - "API":{ - "HTTPHeaders":null + "API": { + "HTTPHeaders": null }, - "Swarm":{ - "AddrFilters":null + "Swarm": { + "AddrFilters": null }, - "Log":{ - "MaxSizeMB":250, - "MaxBackups":1, - "MaxAgeDays":0 + "Log": { + "MaxSizeMB": 250, + "MaxBackups": 1, + "MaxAgeDays": 0 + }, + "Keychain": { + "dek": { + "keyLength": 64, + "iterationCount": 10000, + "salt": "co5EbMmrhFwmhHjedZU73zhL", + "hash": "sha2-512" + } } -} +} \ No newline at end of file diff --git a/test/fixtures/go-ipfs-repo/datastore/CURRENT b/test/fixtures/go-ipfs-repo/datastore/CURRENT index 23b73d9100..42c62b673a 100644 --- a/test/fixtures/go-ipfs-repo/datastore/CURRENT +++ b/test/fixtures/go-ipfs-repo/datastore/CURRENT @@ -1 +1 @@ -MANIFEST-000014 +MANIFEST-000015 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG b/test/fixtures/go-ipfs-repo/datastore/LOG index 96e7909dfc..15709837f7 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG +++ b/test/fixtures/go-ipfs-repo/datastore/LOG @@ -1,29 +1 @@ -=============== Aug 25, 2016 (CEST) =============== -17:21:42.391799 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -17:21:42.393115 db@open opening -17:21:42.399749 db@janitor F·5 G·1 -17:21:42.399774 db@janitor removing manifest-4 -17:21:42.399904 db@open done T·6.754896ms -=============== Aug 25, 2016 (CEST) =============== -17:36:56.009638 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -17:36:56.009849 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50] -17:36:56.009874 db@open opening -17:36:56.009943 journal@recovery F·1 -17:36:56.010918 journal@recovery recovering @8 -17:36:56.012317 memdb@flush created L0@10 N·4 S·1KiB "/ip..\xf6\xe4\xa9,d12":"/pk..TOA,v9" -17:36:56.013451 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] -17:36:56.014779 db@janitor F·5 G·0 -17:36:56.014815 db@open done T·4.928147ms -17:36:56.030081 db@close closing -17:36:56.030223 db@close done T·138.943µs -=============== Aug 25, 2016 (CEST) =============== -17:37:32.735975 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -17:37:32.736209 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] -17:37:32.736230 db@open opening -17:37:32.736304 journal@recovery F·1 -17:37:32.737385 journal@recovery recovering @11 -17:37:32.738575 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] -17:37:32.739466 db@janitor F·5 G·0 -17:37:32.739492 db@open done T·3.248709ms -17:37:51.684973 db@close closing -17:37:51.685242 db@close done T·168.908µs +2018/02/26-08:13:54.065997 70000aad6000 Delete type=3 #14 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG.old b/test/fixtures/go-ipfs-repo/datastore/LOG.old index 863b68fd57..96e7909dfc 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG.old +++ b/test/fixtures/go-ipfs-repo/datastore/LOG.old @@ -1,10 +1,29 @@ -=============== Dec 10, 2015 (PST) =============== -07:50:02.056578 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -07:50:02.057231 db@open opening -07:50:02.057312 journal@recovery F·1 -07:50:02.057514 journal@recovery recovering @3 -07:50:02.058921 mem@flush created L0@5 N·4 S·1KiB "/ip..\xf6\xe4\xa9,v5":"/pk..\xf6\xe4\xa9,v6" -07:50:02.059983 db@janitor F·4 G·0 -07:50:02.060001 db@open done T·2.755926ms -07:50:02.073183 db@close closing -07:50:02.073285 db@close done T·97.522µs +=============== Aug 25, 2016 (CEST) =============== +17:21:42.391799 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +17:21:42.393115 db@open opening +17:21:42.399749 db@janitor F·5 G·1 +17:21:42.399774 db@janitor removing manifest-4 +17:21:42.399904 db@open done T·6.754896ms +=============== Aug 25, 2016 (CEST) =============== +17:36:56.009638 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +17:36:56.009849 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50] +17:36:56.009874 db@open opening +17:36:56.009943 journal@recovery F·1 +17:36:56.010918 journal@recovery recovering @8 +17:36:56.012317 memdb@flush created L0@10 N·4 S·1KiB "/ip..\xf6\xe4\xa9,d12":"/pk..TOA,v9" +17:36:56.013451 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] +17:36:56.014779 db@janitor F·5 G·0 +17:36:56.014815 db@open done T·4.928147ms +17:36:56.030081 db@close closing +17:36:56.030223 db@close done T·138.943µs +=============== Aug 25, 2016 (CEST) =============== +17:37:32.735975 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +17:37:32.736209 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] +17:37:32.736230 db@open opening +17:37:32.736304 journal@recovery F·1 +17:37:32.737385 journal@recovery recovering @11 +17:37:32.738575 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] +17:37:32.739466 db@janitor F·5 G·0 +17:37:32.739492 db@open done T·3.248709ms +17:37:51.684973 db@close closing +17:37:51.685242 db@close done T·168.908µs diff --git a/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014 b/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000015 similarity index 79% rename from test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014 rename to test/fixtures/go-ipfs-repo/datastore/MANIFEST-000015 index bda0ce84e55dad819ef3e95a12373f69463ecfaa..8c8a1fd7b1c3a045dbc3d360d5aafa688a972da5 100644 GIT binary patch delta 60 zcmdnRbeKtb!S{pwx{QpBQaPz*sW~Z0dQO!kspXl)sm}Si1&Kw8CHX}gH3b>@jsFO4 Q;9y{665wQD7G&WC0D3nO`Tzg` delta 56 zcmX@iw2MiXchf2XV@5_sshrfZ)SQ$gJ*Uc&)bh;YROkHMg2bZ4lKdhjUS@t4UUmkq M?-LhlO$>Yt0Qo!;LjV8( diff --git a/test/http-api/extra/block.js b/test/http-api/block.js similarity index 98% rename from test/http-api/extra/block.js rename to test/http-api/block.js index 642d626a68..d0133bbc67 100644 --- a/test/http-api/extra/block.js +++ b/test/http-api/block.js @@ -12,9 +12,10 @@ const waterfall = require('async/waterfall') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) -describe('extra block', () => { +describe('block endpoint', () => { let ipfs = null let ipfsd = null + before(function (done) { this.timeout(20 * 1000) diff --git a/test/http-api/extra/bootstrap.js b/test/http-api/bootstrap.js similarity index 99% rename from test/http-api/extra/bootstrap.js rename to test/http-api/bootstrap.js index b14075393c..98a3610609 100644 --- a/test/http-api/extra/bootstrap.js +++ b/test/http-api/bootstrap.js @@ -10,7 +10,7 @@ chai.use(dirtyChai) const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) -describe('extra bootstrap', () => { +describe('bootstrap endpoint', () => { let ipfs = null let ipfsd = null before(function (done) { diff --git a/test/http-api/extra/config.js b/test/http-api/config.js similarity index 94% rename from test/http-api/extra/config.js rename to test/http-api/config.js index 0d9ae6e907..6bae487caa 100644 --- a/test/http-api/extra/config.js +++ b/test/http-api/config.js @@ -16,9 +16,9 @@ const path = require('path') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) -describe('extra config', () => { - const repoExample = path.join(__dirname, '../../fixtures/go-ipfs-repo') - const repoTests = path.join(__dirname, '../../repo-tests-run') +describe('config endpoint', () => { + const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo') + const repoTests = path.join(__dirname, '../repo-tests-run') let updatedConfig = null @@ -46,7 +46,7 @@ describe('extra config', () => { ipfs = ipfsd.api updatedConfig = () => { - const file = fs.readFileSync(path.join(__dirname, '../../repo-tests-run/config')) + const file = fs.readFileSync(path.join(__dirname, '../repo-tests-run/config')) return JSON.parse(file, 'utf8') } diff --git a/test/http-api/extra/dns.js b/test/http-api/dns.js similarity index 95% rename from test/http-api/extra/dns.js rename to test/http-api/dns.js index 365dca73a2..3d8b1e669d 100644 --- a/test/http-api/extra/dns.js +++ b/test/http-api/dns.js @@ -9,7 +9,7 @@ chai.use(dirtyChai) const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) -describe('extra dns', () => { +describe('dns endpoint', () => { let ipfs = null let ipfsd = null before(function (done) { diff --git a/test/http-api/extra/index.js b/test/http-api/extra/index.js deleted file mode 100644 index fff181e750..0000000000 --- a/test/http-api/extra/index.js +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-env mocha */ -'use strict' - -const fs = require('fs') -const path = require('path') - -describe('## extra tests with ipfs-api', () => { - fs.readdirSync(path.join(__dirname)) - .forEach((file) => { - // TODO(victor) want to make all this loading of tests proper, but for now - if (file.includes('utils') || file.includes('index.js')) { - return - } - require(`./${file}`) - }) -}) diff --git a/test/http-api/extra/id.js b/test/http-api/id.js similarity index 89% rename from test/http-api/extra/id.js rename to test/http-api/id.js index 3ee69bc4a1..4300be7fce 100644 --- a/test/http-api/extra/id.js +++ b/test/http-api/id.js @@ -14,9 +14,9 @@ const path = require('path') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) -describe('extra id', () => { - const repoExample = path.join(__dirname, '../../fixtures/go-ipfs-repo') - const repoTests = path.join(__dirname, '../../repo-tests-run') +describe('id endpoint', () => { + const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo') + const repoTests = path.join(__dirname, '../repo-tests-run') let ipfs = null let ipfsd = null @@ -28,7 +28,7 @@ describe('extra id', () => { waterfall([ (cb) => df.spawn({ - repoPath: path.join(__dirname, '../../fixtures/go-ipfs-repo'), + repoPath: path.join(__dirname, '../fixtures/go-ipfs-repo'), initOptions: { bits: 512 }, disposable: false, start: true diff --git a/test/http-api/index.js b/test/http-api/index.js index 0d6941e9dd..44d48f7f1f 100644 --- a/test/http-api/index.js +++ b/test/http-api/index.js @@ -1,5 +1,11 @@ 'use strict' -require('./spec') require('./interface') -require('./extra') +require('./inject') +require('./block') +require('./bootstrap') +require('./config') +require('./dns') +require('./id') +require('./object') +require('./version') diff --git a/test/http-api/spec/bitswap.js b/test/http-api/inject/bitswap.js similarity index 100% rename from test/http-api/spec/bitswap.js rename to test/http-api/inject/bitswap.js diff --git a/test/http-api/spec/block.js b/test/http-api/inject/block.js similarity index 100% rename from test/http-api/spec/block.js rename to test/http-api/inject/block.js diff --git a/test/http-api/spec/bootstrap.js b/test/http-api/inject/bootstrap.js similarity index 100% rename from test/http-api/spec/bootstrap.js rename to test/http-api/inject/bootstrap.js diff --git a/test/http-api/spec/config.js b/test/http-api/inject/config.js similarity index 100% rename from test/http-api/spec/config.js rename to test/http-api/inject/config.js diff --git a/test/http-api/spec/dns.js b/test/http-api/inject/dns.js similarity index 100% rename from test/http-api/spec/dns.js rename to test/http-api/inject/dns.js diff --git a/test/http-api/spec/files.js b/test/http-api/inject/files.js similarity index 100% rename from test/http-api/spec/files.js rename to test/http-api/inject/files.js diff --git a/test/http-api/spec/id.js b/test/http-api/inject/id.js similarity index 100% rename from test/http-api/spec/id.js rename to test/http-api/inject/id.js diff --git a/test/http-api/spec/index.js b/test/http-api/inject/index.js similarity index 100% rename from test/http-api/spec/index.js rename to test/http-api/inject/index.js diff --git a/test/http-api/spec/object.js b/test/http-api/inject/object.js similarity index 100% rename from test/http-api/spec/object.js rename to test/http-api/inject/object.js diff --git a/test/http-api/spec/pubsub.js b/test/http-api/inject/pubsub.js similarity index 100% rename from test/http-api/spec/pubsub.js rename to test/http-api/inject/pubsub.js diff --git a/test/http-api/spec/version.js b/test/http-api/inject/version.js similarity index 100% rename from test/http-api/spec/version.js rename to test/http-api/inject/version.js diff --git a/test/http-api/extra/object.js b/test/http-api/object.js similarity index 99% rename from test/http-api/extra/object.js rename to test/http-api/object.js index eced7f28f6..dfde75d3d4 100644 --- a/test/http-api/extra/object.js +++ b/test/http-api/object.js @@ -22,7 +22,7 @@ function asJson (cb) { } } -describe('extra object', () => { +describe('object endpoint', () => { let ipfs = null let ipfsd = null before(function (done) { diff --git a/test/http-api/extra/utils/get-ctl.js b/test/http-api/utils/get-ctl.js similarity index 98% rename from test/http-api/extra/utils/get-ctl.js rename to test/http-api/utils/get-ctl.js index 5867370928..8ece0fc51c 100644 --- a/test/http-api/extra/utils/get-ctl.js +++ b/test/http-api/utils/get-ctl.js @@ -1,5 +1,7 @@ 'use strict' + const APIctl = require('ipfs-api') + module.exports = (http) => { return APIctl(http.api.apiMultiaddr) } diff --git a/test/http-api/extra/version.js b/test/http-api/version.js similarity index 96% rename from test/http-api/extra/version.js rename to test/http-api/version.js index 8a22deff0d..2f0d1b2925 100644 --- a/test/http-api/extra/version.js +++ b/test/http-api/version.js @@ -9,7 +9,7 @@ chai.use(dirtyChai) const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) -describe('extra version', () => { +describe('version endpoint', () => { let ipfs = null let ipfsd = null before(function (done) { From a77fb5805a699aaeb86faf4df397d0b916d23a7f Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 26 Feb 2018 08:16:41 -0500 Subject: [PATCH 06/12] test: remove unused util --- test/http-api/utils/get-ctl.js | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 test/http-api/utils/get-ctl.js diff --git a/test/http-api/utils/get-ctl.js b/test/http-api/utils/get-ctl.js deleted file mode 100644 index 8ece0fc51c..0000000000 --- a/test/http-api/utils/get-ctl.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -const APIctl = require('ipfs-api') - -module.exports = (http) => { - return APIctl(http.api.apiMultiaddr) -} From d16727d0b5d999fe92529f730029dc904e0e684f Mon Sep 17 00:00:00 2001 From: David Dias Date: Tue, 27 Feb 2018 08:32:16 -0500 Subject: [PATCH 07/12] chore: update gitignore --- .gitignore | 6 ++-- test/fixtures/go-ipfs-repo/datastore/CURRENT | 2 +- test/fixtures/go-ipfs-repo/datastore/LOG | 2 +- test/fixtures/go-ipfs-repo/datastore/LOG.old | 30 +----------------- .../{MANIFEST-000015 => MANIFEST-000017} | Bin 323 -> 323 bytes 5 files changed, 6 insertions(+), 34 deletions(-) rename test/fixtures/go-ipfs-repo/datastore/{MANIFEST-000015 => MANIFEST-000017} (91%) diff --git a/.gitignore b/.gitignore index 7455bdffdb..a68f6491c0 100644 --- a/.gitignore +++ b/.gitignore @@ -34,9 +34,9 @@ node_modules lib dist -test/test-data/go-ipfs-repo/LOCK -test/test-data/go-ipfs-repo/LOG -test/test-data/go-ipfs-repo/LOG.old +test/fixtures/go-ipfs-repo/LOCK +test/fixtures/go-ipfs-repo/LOG +test/fixtures/go-ipfs-repo/LOG.old # while testing npm5 package-lock.json diff --git a/test/fixtures/go-ipfs-repo/datastore/CURRENT b/test/fixtures/go-ipfs-repo/datastore/CURRENT index 42c62b673a..056df57bb7 100644 --- a/test/fixtures/go-ipfs-repo/datastore/CURRENT +++ b/test/fixtures/go-ipfs-repo/datastore/CURRENT @@ -1 +1 @@ -MANIFEST-000015 +MANIFEST-000017 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG b/test/fixtures/go-ipfs-repo/datastore/LOG index 15709837f7..f009994607 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG +++ b/test/fixtures/go-ipfs-repo/datastore/LOG @@ -1 +1 @@ -2018/02/26-08:13:54.065997 70000aad6000 Delete type=3 #14 +2018/02/27-08:48:29.247686 7000091b5000 Delete type=3 #15 diff --git a/test/fixtures/go-ipfs-repo/datastore/LOG.old b/test/fixtures/go-ipfs-repo/datastore/LOG.old index 96e7909dfc..15709837f7 100644 --- a/test/fixtures/go-ipfs-repo/datastore/LOG.old +++ b/test/fixtures/go-ipfs-repo/datastore/LOG.old @@ -1,29 +1 @@ -=============== Aug 25, 2016 (CEST) =============== -17:21:42.391799 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -17:21:42.393115 db@open opening -17:21:42.399749 db@janitor F·5 G·1 -17:21:42.399774 db@janitor removing manifest-4 -17:21:42.399904 db@open done T·6.754896ms -=============== Aug 25, 2016 (CEST) =============== -17:36:56.009638 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -17:36:56.009849 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50] -17:36:56.009874 db@open opening -17:36:56.009943 journal@recovery F·1 -17:36:56.010918 journal@recovery recovering @8 -17:36:56.012317 memdb@flush created L0@10 N·4 S·1KiB "/ip..\xf6\xe4\xa9,d12":"/pk..TOA,v9" -17:36:56.013451 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] -17:36:56.014779 db@janitor F·5 G·0 -17:36:56.014815 db@open done T·4.928147ms -17:36:56.030081 db@close closing -17:36:56.030223 db@close done T·138.943µs -=============== Aug 25, 2016 (CEST) =============== -17:37:32.735975 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -17:37:32.736209 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] -17:37:32.736230 db@open opening -17:37:32.736304 journal@recovery F·1 -17:37:32.737385 journal@recovery recovering @11 -17:37:32.738575 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75] -17:37:32.739466 db@janitor F·5 G·0 -17:37:32.739492 db@open done T·3.248709ms -17:37:51.684973 db@close closing -17:37:51.685242 db@close done T·168.908µs +2018/02/26-08:13:54.065997 70000aad6000 Delete type=3 #14 diff --git a/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000015 b/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000017 similarity index 91% rename from test/fixtures/go-ipfs-repo/datastore/MANIFEST-000015 rename to test/fixtures/go-ipfs-repo/datastore/MANIFEST-000017 index 8c8a1fd7b1c3a045dbc3d360d5aafa688a972da5..fb6bc82f413acedd0bc88da0ecde34ce80ba3ea9 100644 GIT binary patch delta 23 ecmX@ibeL&_2_t`^l=)r`21X_!P6lRS7G3~H=>$6f delta 23 ecmX@ibeL&_2_wJpAHfYA42( Date: Tue, 27 Feb 2018 11:28:30 -0600 Subject: [PATCH 08/12] fix: copy repo for tests --- test/http-api/config.js | 12 ++++++------ test/http-api/id.js | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/http-api/config.js b/test/http-api/config.js index 6bae487caa..66b4b05929 100644 --- a/test/http-api/config.js +++ b/test/http-api/config.js @@ -18,7 +18,7 @@ const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) describe('config endpoint', () => { const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo') - const repoTests = path.join(__dirname, '../repo-tests-run') + const repoPath = path.join(__dirname, '../repo-tests-run') let updatedConfig = null @@ -27,12 +27,12 @@ describe('config endpoint', () => { before(function (done) { this.timeout(20 * 1000) - ncp(repoExample, repoTests, (err) => { + ncp(repoExample, repoPath, (err) => { expect(err).to.not.exist() waterfall([ (cb) => df.spawn({ - repoPath: repoTests, + repoPath: repoPath, initOptions: { bits: 512 }, disposable: false, start: true @@ -46,8 +46,8 @@ describe('config endpoint', () => { ipfs = ipfsd.api updatedConfig = () => { - const file = fs.readFileSync(path.join(__dirname, '../repo-tests-run/config')) - return JSON.parse(file, 'utf8') + const config = fs.readFileSync(path.join(__dirname, '../repo-tests-run/config')) + return JSON.parse(config, 'utf8') } done() @@ -56,7 +56,7 @@ describe('config endpoint', () => { }) after((done) => { - rimraf(repoTests, (err) => { + rimraf(repoPath, (err) => { expect(err).to.not.exist() ipfsd.stop(done) }) diff --git a/test/http-api/id.js b/test/http-api/id.js index 4300be7fce..3947c268db 100644 --- a/test/http-api/id.js +++ b/test/http-api/id.js @@ -16,19 +16,19 @@ const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) describe('id endpoint', () => { const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo') - const repoTests = path.join(__dirname, '../repo-tests-run') + const repoPath = path.join(__dirname, '../repo-tests-run') let ipfs = null let ipfsd = null before(function (done) { this.timeout(20 * 1000) - ncp(repoExample, repoTests, (err) => { + ncp(repoExample, repoPath, (err) => { expect(err).to.not.exist() waterfall([ (cb) => df.spawn({ - repoPath: path.join(__dirname, '../fixtures/go-ipfs-repo'), + repoPath: repoPath, initOptions: { bits: 512 }, disposable: false, start: true @@ -46,7 +46,7 @@ describe('id endpoint', () => { }) after((done) => { - rimraf(repoTests, (err) => { + rimraf(repoPath, (err) => { expect(err).to.not.exist() ipfsd.stop(done) }) From 72fdde43e28926e23ca38947a3095d5cf86b05ec Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 27 Feb 2018 14:13:44 -0600 Subject: [PATCH 09/12] fix: skip failing tests on windows --- test/http-api/config.js | 5 ++++- test/http-api/id.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/http-api/config.js b/test/http-api/config.js index 66b4b05929..0d14504d1a 100644 --- a/test/http-api/config.js +++ b/test/http-api/config.js @@ -10,13 +10,16 @@ const ncp = require('ncp').ncp const rimraf = require('rimraf') const waterfall = require('async/waterfall') +const isWindows = require('../utils/platforms').isWindows +const skipOnWindows = isWindows() ? describe.skip : describe + const fs = require('fs') const path = require('path') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) -describe('config endpoint', () => { +skipOnWindows('config endpoint', () => { const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo') const repoPath = path.join(__dirname, '../repo-tests-run') diff --git a/test/http-api/id.js b/test/http-api/id.js index 3947c268db..055badf72b 100644 --- a/test/http-api/id.js +++ b/test/http-api/id.js @@ -11,10 +11,13 @@ const rimraf = require('rimraf') const waterfall = require('async/waterfall') const path = require('path') +const isWindows = require('../utils/platforms').isWindows +const skipOnWindows = isWindows() ? describe.skip : describe + const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) -describe('id endpoint', () => { +skipOnWindows('id endpoint', () => { const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo') const repoPath = path.join(__dirname, '../repo-tests-run') From 5925ecc2b364fad09d50c6135854e14469758779 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 27 Feb 2018 14:47:31 -0600 Subject: [PATCH 10/12] fix: `Addresses.Swarm is empty` since we cant stop daemon on windows --- test/cli/daemon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/daemon.js b/test/cli/daemon.js index fe43944f59..dc50c0baaf 100644 --- a/test/cli/daemon.js +++ b/test/cli/daemon.js @@ -75,7 +75,7 @@ describe('daemon', () => { afterEach(() => clean(repoPath)) - it('do not crash if Addresses.Swarm is empty', function (done) { + skipOnWindows('do not crash if Addresses.Swarm is empty', function (done) { this.timeout(100 * 1000) ipfs('init').then(() => { From fe9e06e196138b3ae2dd4f0c9647f6d2f115e9bf Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 27 Feb 2018 14:51:50 -0600 Subject: [PATCH 11/12] fix: move skipOnWindows to top --- test/cli/daemon.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/cli/daemon.js b/test/cli/daemon.js index dc50c0baaf..a98ad6710d 100644 --- a/test/cli/daemon.js +++ b/test/cli/daemon.js @@ -12,6 +12,9 @@ const path = require('path') const hat = require('hat') const fs = require('fs') +const skipOnWindows = isWindows() ? it.skip : it + + const checkLock = (repo, cb) => { // skip on windows // https://github.com/ipfs/js-ipfsd-ctl/pull/155#issuecomment-326983530 @@ -65,6 +68,7 @@ function testSignal (ipfs, sig) { } describe('daemon', () => { + let repoPath let ipfs @@ -92,8 +96,6 @@ describe('daemon', () => { }).catch(err => done(err)) }) - const skipOnWindows = isWindows() ? it.skip : it - skipOnWindows('should handle SIGINT gracefully', function (done) { this.timeout(100 * 1000) From 2b3b21c24c3ad845900a2bd2de900b86b64578cb Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Tue, 27 Feb 2018 15:02:32 -0600 Subject: [PATCH 12/12] lint --- test/cli/daemon.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/cli/daemon.js b/test/cli/daemon.js index a98ad6710d..3245400320 100644 --- a/test/cli/daemon.js +++ b/test/cli/daemon.js @@ -14,7 +14,6 @@ const fs = require('fs') const skipOnWindows = isWindows() ? it.skip : it - const checkLock = (repo, cb) => { // skip on windows // https://github.com/ipfs/js-ipfsd-ctl/pull/155#issuecomment-326983530 @@ -68,7 +67,6 @@ function testSignal (ipfs, sig) { } describe('daemon', () => { - let repoPath let ipfs