diff --git a/README.md b/README.md index 1615f7da97..fcb7f37bec 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ js-ipfs ======= -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) ![Build Status](https://travis-ci.org/ipfs/js-ipfs.svg?style=flat-square)](https://travis-ci.org/ipfs/js-ipfs) ![](https://img.shields.io/badge/coverage-%3F-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/ipfs/js-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) ![Build Status](https://travis-ci.org/ipfs/js-ipfs.svg?style=flat-square)](https://travis-ci.org/ipfs/js-ipfs) ![](https://img.shields.io/badge/coverage-75%25-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/ipfs/js-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) > IPFS JavaScript implementation entry point and roadmap diff --git a/package.json b/package.json index 9b95b1537a..17123f2f27 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,12 @@ "main": "src/index.js", "scripts": { "lint": "standard", - "coverage": "istanbul cover --print both -- _mocha tests/*-test.js", - "test": "mocha tests/*-test.js" + "coverage": "istanbul cover --print both -- _mocha tests/test-*/test-*.js", + "test": "mocha tests/test-*/test-*.js" }, "pre-commit": [ - "lint" + "lint", + "test" ], "repository": { "type": "git", @@ -29,20 +30,19 @@ "homepage": "https://github.com/ipfs/js-ipfs#readme", "devDependencies": { "chai": "^3.4.1", - "ipfsd-ctl": "^0.6.1", "istanbul": "^0.4.1", "mocha": "^2.3.4", "ncp": "^2.0.0", + "nexpect": "^0.5.0", "pre-commit": "^1.1.2", "rimraf": "^2.4.4", "standard": "^5.3.1" }, "dependencies": { - "hapi": "^11.1.4", - "ipfs-api": "^2.7.0", - "ipfs-repo": "^0.1.0", - "peer-id": "^0.4.0", - "peer-info": "^0.4.0", + "boom": "^3.1.1", + "debug": "^2.2.0", + "hapi": "^12.0.0", + "ipfs-repo": "^0.2.2", "ronin": "^0.3.11" } } diff --git a/src/cli/bin.js b/src/cli/bin.js index 05885ce332..4e78c38bb9 100755 --- a/src/cli/bin.js +++ b/src/cli/bin.js @@ -1,8 +1,10 @@ #! /usr/bin/env node -var ronin = require('ronin') +'use strict' -var cli = ronin(__dirname) +const ronin = require('ronin') + +const cli = ronin(__dirname) cli.run() diff --git a/src/cli/commands/add.js b/src/cli/commands/add.js index deedf71f28..160f94228c 100644 --- a/src/cli/commands/add.js +++ b/src/cli/commands/add.js @@ -1,7 +1,9 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/commands.js b/src/cli/commands/commands.js index deedf71f28..160f94228c 100644 --- a/src/cli/commands/commands.js +++ b/src/cli/commands/commands.js @@ -1,7 +1,9 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/daemon.js b/src/cli/commands/daemon.js index deedf71f28..f4ab32e09c 100644 --- a/src/cli/commands/daemon.js +++ b/src/cli/commands/daemon.js @@ -1,7 +1,18 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command +const httpAPI = require('../../http-api') +const debug = require('debug') +const log = debug('cli:daemon') +log.error = debug('cli:damon:error') module.exports = Command.extend({ - desc: '', + desc: 'Start a long-running daemon process', - run: function (name) {} + run: name => { + httpAPI.start((err) => { + if (err) { return log.error(err) } + log('daemon started') + }) + } }) diff --git a/src/cli/commands/dns.js b/src/cli/commands/dns.js index deedf71f28..160f94228c 100644 --- a/src/cli/commands/dns.js +++ b/src/cli/commands/dns.js @@ -1,7 +1,9 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/get.js b/src/cli/commands/get.js index deedf71f28..cb1b1d172f 100644 --- a/src/cli/commands/get.js +++ b/src/cli/commands/get.js @@ -1,7 +1,7 @@ -var Command = require('ronin').Command +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/id.js b/src/cli/commands/id.js index 52bc904f9d..ba477a5ffd 100644 --- a/src/cli/commands/id.js +++ b/src/cli/commands/id.js @@ -1,5 +1,8 @@ -var Command = require('ronin').Command -var IPFS = require('../../ipfs-core') +const Command = require('ronin').Command +const IPFS = require('../../ipfs-core') +const debug = require('debug') +const log = debug('cli:id') +log.error = debug('cli:id:error') module.exports = Command.extend({ desc: 'Shows IPFS Node ID info', @@ -11,12 +14,10 @@ module.exports = Command.extend({ } }, - run: function (name) { - var node = new IPFS() - node.id(function (err, id) { - if (err) { - return console.error(err) - } + run: name => { + const node = new IPFS() + node.id((err, id) => { + if (err) { return log.error(err) } console.log(id) }) } diff --git a/src/cli/commands/init.js b/src/cli/commands/init.js index c669732925..7c0e39e3e9 100644 --- a/src/cli/commands/init.js +++ b/src/cli/commands/init.js @@ -1,11 +1,10 @@ -var Command = require('ronin').Command -// var help = require('../src/help-menu.js') +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: 'Initialize ipfs local configuration', - // help: help, - options: { bits: { type: 'number', @@ -25,7 +24,5 @@ module.exports = Command.extend({ } }, - run: function (name) { - console.log('NA - https://github.com/ipfs/js-ipfs/tree/jsipfs#getting-jsipfs-ready') - } + run: name => {} }) diff --git a/src/cli/commands/ls.js b/src/cli/commands/ls.js index deedf71f28..160f94228c 100644 --- a/src/cli/commands/ls.js +++ b/src/cli/commands/ls.js @@ -1,7 +1,9 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/mount.js b/src/cli/commands/mount.js index deedf71f28..160f94228c 100644 --- a/src/cli/commands/mount.js +++ b/src/cli/commands/mount.js @@ -1,7 +1,9 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/ping.js b/src/cli/commands/ping.js index deedf71f28..160f94228c 100644 --- a/src/cli/commands/ping.js +++ b/src/cli/commands/ping.js @@ -1,7 +1,9 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/refs.js b/src/cli/commands/refs.js index deedf71f28..160f94228c 100644 --- a/src/cli/commands/refs.js +++ b/src/cli/commands/refs.js @@ -1,7 +1,9 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/resolve.js b/src/cli/commands/resolve.js index deedf71f28..160f94228c 100644 --- a/src/cli/commands/resolve.js +++ b/src/cli/commands/resolve.js @@ -1,7 +1,9 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/update.js b/src/cli/commands/update.js index deedf71f28..160f94228c 100644 --- a/src/cli/commands/update.js +++ b/src/cli/commands/update.js @@ -1,7 +1,9 @@ -var Command = require('ronin').Command +'use strict' + +const Command = require('ronin').Command module.exports = Command.extend({ desc: '', - run: function (name) {} + run: name => {} }) diff --git a/src/cli/commands/version.js b/src/cli/commands/version.js index 34cf53e9c5..337c2f55fa 100644 --- a/src/cli/commands/version.js +++ b/src/cli/commands/version.js @@ -1,5 +1,10 @@ -var Command = require('ronin').Command -var IPFS = require('../../ipfs-core') +'use strict' + +const Command = require('ronin').Command +const IPFS = require('../../ipfs-core') +const debug = require('debug') +const log = debug('cli:version') +log.error = debug('cli:version:error') module.exports = Command.extend({ desc: 'Shows IPFS version information', @@ -20,12 +25,11 @@ module.exports = Command.extend({ } }, - run: function (name) { + run: (name) => { var node = new IPFS() - node.version(function (err, version) { - if (err) { - return console.error(err) - } + node.version((err, version) => { + if (err) { return log.error(err) } + console.log(version) }) } diff --git a/src/http-api/index.js b/src/http-api/index.js index e69de29bb2..fdf88ee32b 100644 --- a/src/http-api/index.js +++ b/src/http-api/index.js @@ -0,0 +1,40 @@ +'use strict' + +const Hapi = require('hapi') +const IPFS = require('../ipfs-core') +const debug = require('debug') +const log = debug('api') +log.error = debug('api:error') + +exports = module.exports + +exports.start = callback => { + // start IPFS and exports.ipfs = new IPFS() + + exports.ipfs = new IPFS() + + var server = exports.server = new Hapi.Server({ + connections: { + routes: { + cors: true + } + } + }) + + server.connection({ + port: 9000 + }) + + // load routes + require('./routes/version.js') + + server.start(err => { + if (err) { return callback(err) } + log('server started: ' + server.info.uri) + callback() + }) +} + +exports.stop = () => { + +} diff --git a/src/http-api/resources/index.js b/src/http-api/resources/index.js new file mode 100644 index 0000000000..85867b265c --- /dev/null +++ b/src/http-api/resources/index.js @@ -0,0 +1 @@ +exports.version = require('./version') diff --git a/src/http-api/resources/version.js b/src/http-api/resources/version.js new file mode 100644 index 0000000000..d598e8882e --- /dev/null +++ b/src/http-api/resources/version.js @@ -0,0 +1,14 @@ +'use strict' + +const ipfs = require('./../index.js').ipfs +const boom = require('boom') + +exports = module.exports + +exports.get = (request, reply) => { + ipfs.version((err, version) => { + if (err) { return reply(boom.badRequest(err)) } + return reply(version) + }) +} + diff --git a/src/http-api/routes/version.js b/src/http-api/routes/version.js new file mode 100644 index 0000000000..95a878d285 --- /dev/null +++ b/src/http-api/routes/version.js @@ -0,0 +1,10 @@ +'use strict' + +const server = require('./../index.js').server +const resources = require('./../resources') + +server.route({ + method: 'GET', + path: '/api/v0/version', + handler: resources.version.get +}) diff --git a/src/ipfs-core/config.js b/src/ipfs-core/config.js index 1bcfce9dd7..5a29168d0b 100644 --- a/src/ipfs-core/config.js +++ b/src/ipfs-core/config.js @@ -1,4 +1,6 @@ -var os = require('os') +'use strict' + +const os = require('os') exports = module.exports diff --git a/src/ipfs-core/index.js b/src/ipfs-core/index.js index 4fa57991bf..bc409ef712 100644 --- a/src/ipfs-core/index.js +++ b/src/ipfs-core/index.js @@ -1,99 +1,79 @@ -// var ipfsAPIclt = require('ipfs-api') -// var extend = require('extend') -// var PeerId = require('peer-id') -// var PeerInfo = require('peer-info') -var config = require('./config') -var IPFSRepo = require('ipfs-repo') +'use strict' + +const config = require('./config') +const IPFSRepo = require('ipfs-repo') exports = module.exports = IPFS exports.config = config function IPFS () { - var self = this - - if (!(self instanceof IPFS)) { + if (!(this instanceof IPFS)) { throw new Error('Must be instantiated with new') } - var opts = { - url: 'public-writable-node' - } - - if (process.env.NODE_ENV === 'dev') { - opts.url = '/ip4/127.0.0.1/tcp/5001' - } - - if (process.env.NODE_ENV === 'test') { - opts.url = process.env.APIURL - } - - // var api = ipfsAPIclt(config.url) - // extend(self, api) - var repo = new IPFSRepo(config.repoPath) - self.daemon = function (callback) { + this.daemon = callback => { // 1. read repo to get peer data } - self.version = function (opts, callback) { + this.version = (opts, callback) => { if (typeof opts === 'function') { callback = opts opts = {} } - repoExists(callback) - repo.config.read(function (err, config) { - if (err) { - return callback(err) - } - callback(null, config.Version.Current) + repo.exists((err, exists) => { + if (err) { return callback(err) } + + repo.config.get((err, config) => { + if (err) { return callback(err) } + + callback(null, config.Version.Current) + }) }) } - self.id = function (opts, callback) { + this.id = (opts, callback) => { if (typeof opts === 'function') { callback = opts opts = {} } - repoExists(callback) - - repo.config.read(function (err, config) { - if (err) { - return callback(err) - } - callback(null, { - ID: config.Identity.PeerID, - // TODO needs https://github.com/diasdavid/js-peer-id/blob/master/src/index.js#L76 - PublicKey: '', - Addresses: config.Addresses, - AgentVersion: 'js-ipfs', - ProtocolVersion: '9000' + repo.exists((err, exists) => { + if (err) { return callback(err) } + + repo.config.read((err, config) => { + if (err) { + return callback(err) + } + callback(null, { + ID: config.Identity.PeerID, + // TODO needs https://github.com/diasdavid/js-peer-id/blob/master/src/index.js#L76 + PublicKey: '', + Addresses: config.Addresses, + AgentVersion: 'js-ipfs', + ProtocolVersion: '9000' + }) }) }) } - self.repo = { - init: function (bits, force, empty, callback) { + this.repo = { + init: (bits, force, empty, callback) => { // 1. check if repo already exists }, - version: function (opts, callback) { + version: (opts, callback) => { if (typeof opts === 'function') { callback = opts opts = {} } - repoExists(callback) - - repo.version.read(callback) + repo.exists((err, res) => { + if (err) { return callback(err) } + repo.version.read(callback) + }) }, gc: function () {} } - - function repoExists (callback) { - if (!repo.exists()) { - callback(new Error('Repo does not exist, you must init repo first')) - } else { repo.load() } - } } diff --git a/tests/jsipfs-test.js b/tests/jsipfs-test.js deleted file mode 100644 index 49ac1f0bd1..0000000000 --- a/tests/jsipfs-test.js +++ /dev/null @@ -1,57 +0,0 @@ -/* globals describe, before, after, it*/ - -var expect = require('chai').expect -var ncp = require('ncp').ncp -var rimraf = require('rimraf') - -// var IPFS = require('../src/ipfs-core') - -describe('IPFS Repo Tests', function () { - var testRepoPath = __dirname + '/test-repo' - var date = Date.now().toString() - var repoPath = testRepoPath + date - var node - - before(function (done) { - ncp(testRepoPath, repoPath, function (err) { - if (err) { - expect(err).to.equal(null) - } - done() - }) - }) - - after(function (done) { - rimraf(repoPath, function (err) { - if (err) { - expect(err).to.equal(null) - } - done() - }) - }) - - it('start a new node', function (done) { - process.env.IPFS_PATH = repoPath - var IPFS = require('../src/ipfs-core') - - node = new IPFS() - done() - }) - - it('check repo version', function (done) { - node.repo.version(function (err, version) { - expect(err).to.equal(null) - expect(version).to.be.a('string') - expect(Number(version)).to.be.a('number') - done() - }) - }) - - it('check id info', function (done) { - node.id(function (err, id) { - expect(err).to.equal(null) - expect(id).to.be.a('object') - done() - }) - }) -}) diff --git a/tests/test-repo/blocks/1220120f/1220120f6af601d46e10b2d2e11ed71c55d25f3042c22501e41d1246e7a1e9d3d8ec.data b/tests/repo-example/blocks/1220120f/1220120f6af601d46e10b2d2e11ed71c55d25f3042c22501e41d1246e7a1e9d3d8ec.data similarity index 100% rename from tests/test-repo/blocks/1220120f/1220120f6af601d46e10b2d2e11ed71c55d25f3042c22501e41d1246e7a1e9d3d8ec.data rename to tests/repo-example/blocks/1220120f/1220120f6af601d46e10b2d2e11ed71c55d25f3042c22501e41d1246e7a1e9d3d8ec.data diff --git a/tests/test-repo/blocks/122031d6/122031d6da265092f1b03fec969243fdcf095c1d219356cdf538ffce705a52d5738d.data b/tests/repo-example/blocks/122031d6/122031d6da265092f1b03fec969243fdcf095c1d219356cdf538ffce705a52d5738d.data similarity index 100% rename from tests/test-repo/blocks/122031d6/122031d6da265092f1b03fec969243fdcf095c1d219356cdf538ffce705a52d5738d.data rename to tests/repo-example/blocks/122031d6/122031d6da265092f1b03fec969243fdcf095c1d219356cdf538ffce705a52d5738d.data diff --git a/tests/test-repo/blocks/122031e7/122031e7a41c15d03feb8cd793c3348ea3b310512d7767a9abfbd7a928a85e977173.data b/tests/repo-example/blocks/122031e7/122031e7a41c15d03feb8cd793c3348ea3b310512d7767a9abfbd7a928a85e977173.data similarity index 100% rename from tests/test-repo/blocks/122031e7/122031e7a41c15d03feb8cd793c3348ea3b310512d7767a9abfbd7a928a85e977173.data rename to tests/repo-example/blocks/122031e7/122031e7a41c15d03feb8cd793c3348ea3b310512d7767a9abfbd7a928a85e977173.data diff --git a/tests/test-repo/blocks/12203628/12203628a4a19525dd84bbbffe132ec0b0d3be3528fbbcc814feb7f2fbf71ca06162.data b/tests/repo-example/blocks/12203628/12203628a4a19525dd84bbbffe132ec0b0d3be3528fbbcc814feb7f2fbf71ca06162.data similarity index 100% rename from tests/test-repo/blocks/12203628/12203628a4a19525dd84bbbffe132ec0b0d3be3528fbbcc814feb7f2fbf71ca06162.data rename to tests/repo-example/blocks/12203628/12203628a4a19525dd84bbbffe132ec0b0d3be3528fbbcc814feb7f2fbf71ca06162.data diff --git a/tests/test-repo/blocks/12204a5a/12204a5a95586f52e25811cf214677160e64383755a8c5163ba3c053c3b65777ed16.data b/tests/repo-example/blocks/12204a5a/12204a5a95586f52e25811cf214677160e64383755a8c5163ba3c053c3b65777ed16.data similarity index 100% rename from tests/test-repo/blocks/12204a5a/12204a5a95586f52e25811cf214677160e64383755a8c5163ba3c053c3b65777ed16.data rename to tests/repo-example/blocks/12204a5a/12204a5a95586f52e25811cf214677160e64383755a8c5163ba3c053c3b65777ed16.data diff --git a/tests/test-repo/blocks/12205200/12205200cc6b6f79e1588480d9f9016ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data b/tests/repo-example/blocks/12205200/12205200cc6b6f79e1588480d9f9016ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data similarity index 100% rename from tests/test-repo/blocks/12205200/12205200cc6b6f79e1588480d9f9016ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data rename to tests/repo-example/blocks/12205200/12205200cc6b6f79e1588480d9f9016ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data diff --git a/tests/test-repo/blocks/122052c6/122052c63c7775396b3f82c639977a7223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data b/tests/repo-example/blocks/122052c6/122052c63c7775396b3f82c639977a7223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data similarity index 100% rename from tests/test-repo/blocks/122052c6/122052c63c7775396b3f82c639977a7223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data rename to tests/repo-example/blocks/122052c6/122052c63c7775396b3f82c639977a7223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data diff --git a/tests/test-repo/blocks/12205994/122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef.data b/tests/repo-example/blocks/12205994/122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef.data similarity index 100% rename from tests/test-repo/blocks/12205994/122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef.data rename to tests/repo-example/blocks/12205994/122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef.data diff --git a/tests/test-repo/blocks/122062ce/122062ce1f2c91a13a97b596e873b5a3346a644605d7614dca53cd3a59f7385a8abb.data b/tests/repo-example/blocks/122062ce/122062ce1f2c91a13a97b596e873b5a3346a644605d7614dca53cd3a59f7385a8abb.data similarity index 100% rename from tests/test-repo/blocks/122062ce/122062ce1f2c91a13a97b596e873b5a3346a644605d7614dca53cd3a59f7385a8abb.data rename to tests/repo-example/blocks/122062ce/122062ce1f2c91a13a97b596e873b5a3346a644605d7614dca53cd3a59f7385a8abb.data diff --git a/tests/test-repo/blocks/12206781/122067817186b8ff365c758f387e3ae7f28fa9367ee167c312e6d65a2e02e81ab815.data b/tests/repo-example/blocks/12206781/122067817186b8ff365c758f387e3ae7f28fa9367ee167c312e6d65a2e02e81ab815.data similarity index 100% rename from tests/test-repo/blocks/12206781/122067817186b8ff365c758f387e3ae7f28fa9367ee167c312e6d65a2e02e81ab815.data rename to tests/repo-example/blocks/12206781/122067817186b8ff365c758f387e3ae7f28fa9367ee167c312e6d65a2e02e81ab815.data diff --git a/tests/test-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data b/tests/repo-example/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data similarity index 100% rename from tests/test-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data rename to tests/repo-example/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data diff --git a/tests/test-repo/blocks/1220709b/1220709b2dcc5f6a90ad64d6fe3a5d202a72b057d1c7f2e682d0776a5363e2cca974.data b/tests/repo-example/blocks/1220709b/1220709b2dcc5f6a90ad64d6fe3a5d202a72b057d1c7f2e682d0776a5363e2cca974.data similarity index 100% rename from tests/test-repo/blocks/1220709b/1220709b2dcc5f6a90ad64d6fe3a5d202a72b057d1c7f2e682d0776a5363e2cca974.data rename to tests/repo-example/blocks/1220709b/1220709b2dcc5f6a90ad64d6fe3a5d202a72b057d1c7f2e682d0776a5363e2cca974.data diff --git a/tests/test-repo/blocks/12207fb8/12207fb898b5d7be46d85feb75d894e16cfa9a7ae5533f8e997cdab2ebadd7506340.data b/tests/repo-example/blocks/12207fb8/12207fb898b5d7be46d85feb75d894e16cfa9a7ae5533f8e997cdab2ebadd7506340.data similarity index 100% rename from tests/test-repo/blocks/12207fb8/12207fb898b5d7be46d85feb75d894e16cfa9a7ae5533f8e997cdab2ebadd7506340.data rename to tests/repo-example/blocks/12207fb8/12207fb898b5d7be46d85feb75d894e16cfa9a7ae5533f8e997cdab2ebadd7506340.data diff --git a/tests/test-repo/blocks/12208b87/12208b872ca4ee517608331696dd6b3e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data b/tests/repo-example/blocks/12208b87/12208b872ca4ee517608331696dd6b3e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data similarity index 100% rename from tests/test-repo/blocks/12208b87/12208b872ca4ee517608331696dd6b3e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data rename to tests/repo-example/blocks/12208b87/12208b872ca4ee517608331696dd6b3e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data diff --git a/tests/test-repo/blocks/122090c0/122090c07a7795c1193510a696d1fdfc0f1e4947cff8e422610996e609dbcb976598.data b/tests/repo-example/blocks/122090c0/122090c07a7795c1193510a696d1fdfc0f1e4947cff8e422610996e609dbcb976598.data similarity index 100% rename from tests/test-repo/blocks/122090c0/122090c07a7795c1193510a696d1fdfc0f1e4947cff8e422610996e609dbcb976598.data rename to tests/repo-example/blocks/122090c0/122090c07a7795c1193510a696d1fdfc0f1e4947cff8e422610996e609dbcb976598.data diff --git a/tests/test-repo/blocks/1220929a/1220929a303c39da8a0b67c09697462f687a00c638bcb580feae06452e0c1f20b4.data b/tests/repo-example/blocks/1220929a/1220929a303c39da8a0b67c09697462f687a00c638bcb580feae06452e0c1f20b4.data similarity index 100% rename from tests/test-repo/blocks/1220929a/1220929a303c39da8a0b67c09697462f687a00c638bcb580feae06452e0c1f20b4.data rename to tests/repo-example/blocks/1220929a/1220929a303c39da8a0b67c09697462f687a00c638bcb580feae06452e0c1f20b4.data diff --git a/tests/test-repo/blocks/1220933b/1220933b41d37fd4508cdff45930dff56baef91c7dc345e73d049ab570abe10dfbb9.data b/tests/repo-example/blocks/1220933b/1220933b41d37fd4508cdff45930dff56baef91c7dc345e73d049ab570abe10dfbb9.data similarity index 100% rename from tests/test-repo/blocks/1220933b/1220933b41d37fd4508cdff45930dff56baef91c7dc345e73d049ab570abe10dfbb9.data rename to tests/repo-example/blocks/1220933b/1220933b41d37fd4508cdff45930dff56baef91c7dc345e73d049ab570abe10dfbb9.data diff --git a/tests/test-repo/blocks/1220a52c/1220a52c3602030cb912edfe4de97002fdadf9d45666c3be122a2efb5db93c1d5fa6.data b/tests/repo-example/blocks/1220a52c/1220a52c3602030cb912edfe4de97002fdadf9d45666c3be122a2efb5db93c1d5fa6.data similarity index 100% rename from tests/test-repo/blocks/1220a52c/1220a52c3602030cb912edfe4de97002fdadf9d45666c3be122a2efb5db93c1d5fa6.data rename to tests/repo-example/blocks/1220a52c/1220a52c3602030cb912edfe4de97002fdadf9d45666c3be122a2efb5db93c1d5fa6.data diff --git a/tests/test-repo/blocks/1220c0fc/1220c0fc6b49543d7bf04e83d2a5a7cbe72a83e80f9c7bca1abcaa42298a57a33ff5.data b/tests/repo-example/blocks/1220c0fc/1220c0fc6b49543d7bf04e83d2a5a7cbe72a83e80f9c7bca1abcaa42298a57a33ff5.data similarity index 100% rename from tests/test-repo/blocks/1220c0fc/1220c0fc6b49543d7bf04e83d2a5a7cbe72a83e80f9c7bca1abcaa42298a57a33ff5.data rename to tests/repo-example/blocks/1220c0fc/1220c0fc6b49543d7bf04e83d2a5a7cbe72a83e80f9c7bca1abcaa42298a57a33ff5.data diff --git a/tests/test-repo/blocks/1220e3b0/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.data b/tests/repo-example/blocks/1220e3b0/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.data similarity index 100% rename from tests/test-repo/blocks/1220e3b0/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.data rename to tests/repo-example/blocks/1220e3b0/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.data diff --git a/tests/test-repo/blocks/1220e605/1220e605408ac3f78113ac9a7fd486441317afc9f967abe2aa05e7c641f7bbe98a37.data b/tests/repo-example/blocks/1220e605/1220e605408ac3f78113ac9a7fd486441317afc9f967abe2aa05e7c641f7bbe98a37.data similarity index 100% rename from tests/test-repo/blocks/1220e605/1220e605408ac3f78113ac9a7fd486441317afc9f967abe2aa05e7c641f7bbe98a37.data rename to tests/repo-example/blocks/1220e605/1220e605408ac3f78113ac9a7fd486441317afc9f967abe2aa05e7c641f7bbe98a37.data diff --git a/tests/test-repo/blocks/1220e6a0/1220e6a045864ff8569e43e4866c0af807def07b0db2f018808620eb30b980e94011.data b/tests/repo-example/blocks/1220e6a0/1220e6a045864ff8569e43e4866c0af807def07b0db2f018808620eb30b980e94011.data similarity index 100% rename from tests/test-repo/blocks/1220e6a0/1220e6a045864ff8569e43e4866c0af807def07b0db2f018808620eb30b980e94011.data rename to tests/repo-example/blocks/1220e6a0/1220e6a045864ff8569e43e4866c0af807def07b0db2f018808620eb30b980e94011.data diff --git a/tests/test-repo/blocks/1220ec5b/1220ec5b533a3218991f4377b8b8c2538b95dd29d31eac6433af0fb6fcd83dd80778.data b/tests/repo-example/blocks/1220ec5b/1220ec5b533a3218991f4377b8b8c2538b95dd29d31eac6433af0fb6fcd83dd80778.data similarity index 100% rename from tests/test-repo/blocks/1220ec5b/1220ec5b533a3218991f4377b8b8c2538b95dd29d31eac6433af0fb6fcd83dd80778.data rename to tests/repo-example/blocks/1220ec5b/1220ec5b533a3218991f4377b8b8c2538b95dd29d31eac6433af0fb6fcd83dd80778.data diff --git a/tests/test-repo/config b/tests/repo-example/config similarity index 100% rename from tests/test-repo/config rename to tests/repo-example/config diff --git a/tests/test-repo/datastore/000002.ldb b/tests/repo-example/datastore/000002.ldb similarity index 100% rename from tests/test-repo/datastore/000002.ldb rename to tests/repo-example/datastore/000002.ldb diff --git a/tests/test-repo/datastore/000005.ldb b/tests/repo-example/datastore/000005.ldb similarity index 100% rename from tests/test-repo/datastore/000005.ldb rename to tests/repo-example/datastore/000005.ldb diff --git a/tests/test-repo/datastore/CURRENT b/tests/repo-example/datastore/CURRENT similarity index 100% rename from tests/test-repo/datastore/CURRENT rename to tests/repo-example/datastore/CURRENT diff --git a/tests/test-repo/datastore/LOCK b/tests/repo-example/datastore/LOCK similarity index 100% rename from tests/test-repo/datastore/LOCK rename to tests/repo-example/datastore/LOCK diff --git a/tests/test-repo/datastore/LOG b/tests/repo-example/datastore/LOG similarity index 100% rename from tests/test-repo/datastore/LOG rename to tests/repo-example/datastore/LOG diff --git a/tests/test-repo/datastore/LOG.old b/tests/repo-example/datastore/LOG.old similarity index 100% rename from tests/test-repo/datastore/LOG.old rename to tests/repo-example/datastore/LOG.old diff --git a/tests/test-repo/datastore/MANIFEST-000007 b/tests/repo-example/datastore/MANIFEST-000007 similarity index 100% rename from tests/test-repo/datastore/MANIFEST-000007 rename to tests/repo-example/datastore/MANIFEST-000007 diff --git a/tests/test-repo/version b/tests/repo-example/version similarity index 100% rename from tests/test-repo/version rename to tests/repo-example/version diff --git a/tests/test-api/test-version.js b/tests/test-api/test-version.js new file mode 100644 index 0000000000..15202c193c --- /dev/null +++ b/tests/test-api/test-version.js @@ -0,0 +1,22 @@ +/* globals describe, it */ +'use strict' + +const expect = require('chai').expect + +process.env.IPFS_PATH = process.cwd() + '/tests/repo-example' +const api = require('../../src/http-api') + +describe('api: version', function () { + it('get the version', done => { + api.start(err => { + expect(err).to.not.exist + api.server.inject({ + method: 'GET', + url: '/api/v0/version' + }, res => { + expect(res.result).to.equal('0.4.0-dev') + done() + }) + }) + }) +}) diff --git a/tests/test-cli-offline/test-version.js b/tests/test-cli-offline/test-version.js new file mode 100644 index 0000000000..3cc5636f7d --- /dev/null +++ b/tests/test-cli-offline/test-version.js @@ -0,0 +1,18 @@ +/* globals describe, it */ + +'use strict' + +const expect = require('chai').expect +const nexpect = require('nexpect') + +describe('cli-offline: version', () => { + it('get the version', done => { + nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'version']) + .expect('0.4.0-dev') + .run((err, stdout, exitcode) => { + expect(err).to.not.exist + expect(exitcode).to.equal(0) + done() + }) + }) +}) diff --git a/tests/test-cli/test-version.js b/tests/test-cli/test-version.js new file mode 100644 index 0000000000..baa493ee0a --- /dev/null +++ b/tests/test-cli/test-version.js @@ -0,0 +1,17 @@ +/* globals describe, it */ +'use strict' + +const expect = require('chai').expect +const nexpect = require('nexpect') + +describe('cli: version', () => { + it('get the version', done => { + nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'version']) + .expect('0.4.0-dev') + .run((err, stdout, exitcode) => { + expect(err).to.not.exist + expect(exitcode).to.equal(0) + done() + }) + }) +}) diff --git a/tests/test-core/test-version.js b/tests/test-core/test-version.js new file mode 100644 index 0000000000..fe0f925674 --- /dev/null +++ b/tests/test-core/test-version.js @@ -0,0 +1,19 @@ +/* globals describe, it */ + +'use strict' + +const expect = require('chai').expect + +process.env.IPFS_PATH = process.cwd() + '/tests/repo-example' +const IPFS = require('../../src/ipfs-core') + +describe('core: version', () => { + it('get version', done => { + let ipfs = new IPFS() + ipfs.version((err, version) => { + expect(err).to.not.exist + expect(version).to.equal('0.4.0-dev') + done() + }) + }) +})