From 7fd1b02fb41da35bc404bd6c347661295ddfa17b Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Tue, 27 Sep 2016 11:02:34 +0200 Subject: [PATCH 01/14] refactor: update to new block api --- package.json | 14 +++++++------- src/api/block.js | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 047be97eb..78b398d36 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,14 @@ "main": "lib/index.js", "jsnext:main": "src/index.js", "scripts": { - "test": "PHANTOM=off node --max_old_space_size=8192 node_modules/.bin/gulp test:node", - "test:node": "PHANTOM=off gulp test:node", - "test:browser": "PHANTOM=off node --max_old_space_size=8192 node_modules/.bin/gulp test:browser", + "test": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp test:node", + "test:node": "gulp test:node", + "test:browser": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp test:browser", "lint": "aegir-lint", "build": "gulp build", - "release": "PHANTOM=off node --max_old_space_size=8192 node_modules/.bin/gulp release", - "release-minor": "PHANTOM=off node --max_old_space_size=8192 node_modules/.bin/gulp release --type minor", - "release-major": "PHANTOM=off node --max_old_space_size=8192 node_modules/.bin/gulp release --type major", + "release": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp release", + "release-minor": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp release --type minor", + "release-major": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp release --type major", "coverage": "gulp coverage", "coverage-publish": "aegir-coverage publish" }, @@ -103,4 +103,4 @@ "url": "https://github.com/ipfs/js-ipfs-api/issues" }, "homepage": "https://github.com/ipfs/js-ipfs-api" -} \ No newline at end of file +} diff --git a/src/api/block.js b/src/api/block.js index 41c880408..3e2bd2b81 100644 --- a/src/api/block.js +++ b/src/api/block.js @@ -27,13 +27,13 @@ module.exports = (send) => { return callback(err) } if (Buffer.isBuffer(res)) { - callback(null, new Block(res)) + Block.create(res, callback) } else { res.pipe(bl((err, data) => { if (err) { return callback(err) } - callback(null, new Block(data)) + Block.create(data, callback) })) } }) @@ -85,7 +85,8 @@ module.exports = (send) => { if (err) { return callback(err) } - callback(null, new Block(block)) + + Block.create(block, callback) }) }) } From 02623f0aa703703d9f9fb64bacff0bafd7944c20 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Tue, 27 Sep 2016 11:05:10 +0200 Subject: [PATCH 02/14] chore: remove unused .aegir config --- .aegir.js | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .aegir.js diff --git a/.aegir.js b/.aegir.js deleted file mode 100644 index 0ca4c8882..000000000 --- a/.aegir.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict' - -const path = require('path') - -module.exports = { - webpack: { - resolve: { - alias: { - 'node-forge': path.resolve( - path.dirname(require.resolve('libp2p-crypto')), - '../vendor/forge.bundle.js' - ) - } - }, - externals: { - fs: '{}', - mkdirp: '{}' - } - } -} From e17b055e6a64487d32021f0746ce5864661bd3be Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Thu, 29 Sep 2016 11:00:02 +0200 Subject: [PATCH 03/14] more async fixes --- package.json | 3 +++ src/add-to-dagnode-transform.js | 28 ++++++++++++---------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 78b398d36..2853ea902 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,9 @@ "description": "A client library for the IPFS HTTP API. Follows interface-ipfs-core spec", "main": "lib/index.js", "jsnext:main": "src/index.js", + "browser": { + "glob": false + }, "scripts": { "test": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp test:node", "test:node": "gulp test:node", diff --git a/src/add-to-dagnode-transform.js b/src/add-to-dagnode-transform.js index 5f2e65785..5566de542 100644 --- a/src/add-to-dagnode-transform.js +++ b/src/add-to-dagnode-transform.js @@ -1,6 +1,8 @@ 'use strict' const map = require('async/map') +const waterfall = require('async/waterfall') + const getDagNode = require('./get-dagnode') // transform { Hash: '...' } objects into { path: 'string', node: DAGNode } @@ -9,24 +11,18 @@ module.exports = (err, res, send, done) => { return done(err) } - map(res, (entry, next) => { - getDagNode(send, entry.Hash, (err, node) => { + map(res, (entry, next) => waterfall([ + (cb) => getDagNode(send, entry.Hash, cb), + (node, cb) => node.size((err, size) => { if (err) { - return next(err) + return cb(err) } - node.size((err, size) => { - if (err) { - return next(err) - } - const obj = { - path: entry.Name, - hash: entry.Hash, - size: size - } - next(null, obj) + + cb(null, { + path: entry.Name, + hash: entry.Hash, + size: size }) }) - }, (err, res) => { - done(err, res) - }) + ], next), done) } From edf17b5a7f594fbe2b6c76b60176a701a2a421e3 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Mon, 31 Oct 2016 09:58:43 +0100 Subject: [PATCH 04/14] updates for new aegir --- .gitignore | 1 - .travis.yml | 26 ++++++++++++++------ package.json | 34 ++++++++++++++------------ test/factory/daemon-spawner.js | 3 ++- test/interface-ipfs-core/files.spec.js | 9 ++++++- test/interface-ipfs-core/get.spec.js | 8 +++++- test/interface-ipfs-core/name.spec.js | 9 ++++++- 7 files changed, 62 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 0234febe2..7cdb316de 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ node_modules *.log test/setup/tmp-disposable-nodes-addrs.json dist -lib coverage diff --git a/.travis.yml b/.travis.yml index c2e95ab4f..f8ac65973 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,16 @@ sudo: false language: node_js -node_js: - - 4 - - 5 - - "stable" + +matrix: + include: + - node_js: 4 + env: CXX=g++-4.8 + - node_js: 6 + env: CXX=g++-4.8 + - node_js: stable + env: + - SAUCE=true + - CXX=g++-4.8 # Make sure we have new NPM. before_install: @@ -14,12 +21,17 @@ script: - npm run test:node - npm run coverage -addons: - firefox: 'latest' - before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start after_success: - npm run coverage-publish + +addons: + firefox: 'latest' + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 diff --git a/package.json b/package.json index 2853ea902..0cfb1f67e 100644 --- a/package.json +++ b/package.json @@ -2,55 +2,58 @@ "name": "ipfs-api", "version": "11.0.1", "description": "A client library for the IPFS HTTP API. Follows interface-ipfs-core spec", - "main": "lib/index.js", - "jsnext:main": "src/index.js", + "main": "src/index.js", "browser": { - "glob": false + "glob": false, + "fs": false, + "http": "stream-http", + "https": "https-browserify" }, "scripts": { - "test": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp test:node", + "test": "gulp test", "test:node": "gulp test:node", - "test:browser": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp test:browser", + "test:browser": "gulp test:browser", "lint": "aegir-lint", "build": "gulp build", - "release": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp release", - "release-minor": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp release --type minor", - "release-major": "PHANTOM=off node --max_old_space_size=4096 node_modules/.bin/gulp release --type major", + "release": "gulp release", + "release-minor": "gulp release --type minor", + "release-major": "gulp release --type major", "coverage": "gulp coverage", "coverage-publish": "aegir-coverage publish" }, "dependencies": { "async": "^2.1.2", - "babel-runtime": "^6.18.0", "bl": "^1.1.2", "bs58": "^3.0.0", "detect-node": "^2.0.3", "flatmap": "0.0.3", "glob": "^7.1.1", + "https-browserify": "0.0.1", "ipfs-block": "^0.4.0", "ipld-dag-pb": "^0.1.3", - "is-ipfs": "^0.2.0", + "is-ipfs": "^0.2.1", "isstream": "^0.1.2", - "multiaddr": "^2.0.2", + "multiaddr": "^2.0.3", "multipart-stream": "^2.0.1", "ndjson": "^1.4.3", "peer-id": "^0.7.0", "peer-info": "^0.7.1", - "promisify-es6": "^1.0.1", + "promisify-es6": "^1.0.2", "qs": "^6.3.0", + "stream-http": "^2.4.0", "streamifier": "^0.1.1", "tar-stream": "^1.5.2", "wreck": "^10.0.0" }, "engines": { - "node": ">=4.2.2" + "node": ">=4.0.0" }, "repository": { "type": "git", "url": "https://github.com/ipfs/js-ipfs-api" }, "devDependencies": { - "aegir": "^8.1.2", + "aegir": "^9.0.0", "chai": "^3.5.0", "gulp": "^3.9.1", "hapi": "^15.2.0", @@ -59,8 +62,7 @@ "pre-commit": "^1.1.3", "socket.io": "^1.5.1", "socket.io-client": "^1.5.1", - "stream-equal": "^0.1.8", - "stream-http": "^2.4.0" + "stream-equal": "^0.1.9" }, "pre-commit": [ "lint", diff --git a/test/factory/daemon-spawner.js b/test/factory/daemon-spawner.js index f4f9f9498..9499f51f0 100644 --- a/test/factory/daemon-spawner.js +++ b/test/factory/daemon-spawner.js @@ -70,7 +70,8 @@ function spawnEphemeralNode (callback) { (cb) => { const headers = { HTTPHeaders: { - 'Access-Control-Allow-Origin': ['*'] + 'Access-Control-Allow-Origin': ['*'], + 'Access-Control-Allow-Credentials': 'true' } } node.setConfig('API', JSON.stringify(headers), cb) diff --git a/test/interface-ipfs-core/files.spec.js b/test/interface-ipfs-core/files.spec.js index bed5c1506..80586c4fa 100644 --- a/test/interface-ipfs-core/files.spec.js +++ b/test/interface-ipfs-core/files.spec.js @@ -8,7 +8,14 @@ const path = require('path') const test = require('interface-ipfs-core') const fs = require('fs') const FactoryClient = require('../factory/factory-client') -const testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt')) + +let testfile + +if (isNode) { + testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt')) +} else { + testfile = require('file!../data/testfile.txt') +} // add, cat, get and ls tests from interface-ipfs-core let fc diff --git a/test/interface-ipfs-core/get.spec.js b/test/interface-ipfs-core/get.spec.js index b989811c7..32aa13cd0 100644 --- a/test/interface-ipfs-core/get.spec.js +++ b/test/interface-ipfs-core/get.spec.js @@ -12,7 +12,13 @@ const streamEqual = require('stream-equal') const path = require('path') const FactoryClient = require('../factory/factory-client') -const testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt')) +let testfile + +if (isNode) { + testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt')) +} else { + testfile = require('file!../data/testfile.txt') +} let testfileBig let tfbPath diff --git a/test/interface-ipfs-core/name.spec.js b/test/interface-ipfs-core/name.spec.js index 4e3e9194f..8d0f0f208 100644 --- a/test/interface-ipfs-core/name.spec.js +++ b/test/interface-ipfs-core/name.spec.js @@ -5,8 +5,15 @@ const expect = require('chai').expect const fs = require('fs') const path = require('path') +const isNode = require('detect-node') -const testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt')) +let testfile + +if (isNode) { + testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt')) +} else { + testfile = require('file!../data/testfile.txt') +} describe('.name', () => { let name From 585a48bd82b0950a723fe2ec64aaaa469823418c Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Mon, 31 Oct 2016 10:04:34 +0100 Subject: [PATCH 05/14] chore: deps update --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0cfb1f67e..de411691d 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "peer-info": "^0.7.1", "promisify-es6": "^1.0.2", "qs": "^6.3.0", - "stream-http": "^2.4.0", + "stream-http": "^2.4.1", "streamifier": "^0.1.1", "tar-stream": "^1.5.2", "wreck": "^10.0.0" @@ -53,11 +53,11 @@ "url": "https://github.com/ipfs/js-ipfs-api" }, "devDependencies": { - "aegir": "^9.0.0", + "aegir": "^9.0.1", "chai": "^3.5.0", "gulp": "^3.9.1", "hapi": "^15.2.0", - "interface-ipfs-core": "^0.16.1", + "interface-ipfs-core": "^0.16.6", "ipfsd-ctl": "^0.17.0", "pre-commit": "^1.1.3", "socket.io": "^1.5.1", From 5917214e5ec3f98a4a225d3f5993670f1c3af136 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Thu, 3 Nov 2016 13:37:46 +0100 Subject: [PATCH 06/14] wip --- .travis.yml | 8 ++++---- test/{data => fixtures}/15mb.random | Bin test/{data => fixtures}/r-config.json | 0 test/{data => fixtures}/test-folder/add.js | 0 test/{data => fixtures}/test-folder/cat.js | 0 test/{data => fixtures}/test-folder/files/hello.txt | 0 test/{data => fixtures}/test-folder/files/ipfs.txt | 0 test/{data => fixtures}/test-folder/hello-link | 0 test/{data => fixtures}/test-folder/ipfs-add.js | 0 test/{data => fixtures}/test-folder/ls.js | 0 test/{data => fixtures}/test-folder/version.js | 0 test/{data => fixtures}/testconfig.json | 0 test/{data => fixtures}/testfile.txt | 0 test/interface-ipfs-core/files.spec.js | 12 +++--------- test/interface-ipfs-core/get.spec.js | 11 +++-------- test/interface-ipfs-core/ls.spec.js | 2 +- test/interface-ipfs-core/name.spec.js | 12 ++---------- test/interface-ipfs-core/refs.spec.js | 2 +- test/ipfs-api/request-api.spec.js | 2 +- test/ipfs-api/util.spec.js | 6 +++--- test/tmp-disposable-nodes-addrs.json | 1 - 21 files changed, 18 insertions(+), 38 deletions(-) rename test/{data => fixtures}/15mb.random (100%) rename test/{data => fixtures}/r-config.json (100%) rename test/{data => fixtures}/test-folder/add.js (100%) rename test/{data => fixtures}/test-folder/cat.js (100%) rename test/{data => fixtures}/test-folder/files/hello.txt (100%) rename test/{data => fixtures}/test-folder/files/ipfs.txt (100%) rename test/{data => fixtures}/test-folder/hello-link (100%) rename test/{data => fixtures}/test-folder/ipfs-add.js (100%) rename test/{data => fixtures}/test-folder/ls.js (100%) rename test/{data => fixtures}/test-folder/version.js (100%) rename test/{data => fixtures}/testconfig.json (100%) rename test/{data => fixtures}/testfile.txt (100%) delete mode 100644 test/tmp-disposable-nodes-addrs.json diff --git a/.travis.yml b/.travis.yml index f8ac65973..bddac4362 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,11 @@ matrix: - node_js: 4 env: CXX=g++-4.8 - node_js: 6 - env: CXX=g++-4.8 - - node_js: stable env: - - SAUCE=true - - CXX=g++-4.8 + - SAUCE=true + - CXX=g++-4.8 + - node_js: stable + env: CXX=g++-4.8 # Make sure we have new NPM. before_install: diff --git a/test/data/15mb.random b/test/fixtures/15mb.random similarity index 100% rename from test/data/15mb.random rename to test/fixtures/15mb.random diff --git a/test/data/r-config.json b/test/fixtures/r-config.json similarity index 100% rename from test/data/r-config.json rename to test/fixtures/r-config.json diff --git a/test/data/test-folder/add.js b/test/fixtures/test-folder/add.js similarity index 100% rename from test/data/test-folder/add.js rename to test/fixtures/test-folder/add.js diff --git a/test/data/test-folder/cat.js b/test/fixtures/test-folder/cat.js similarity index 100% rename from test/data/test-folder/cat.js rename to test/fixtures/test-folder/cat.js diff --git a/test/data/test-folder/files/hello.txt b/test/fixtures/test-folder/files/hello.txt similarity index 100% rename from test/data/test-folder/files/hello.txt rename to test/fixtures/test-folder/files/hello.txt diff --git a/test/data/test-folder/files/ipfs.txt b/test/fixtures/test-folder/files/ipfs.txt similarity index 100% rename from test/data/test-folder/files/ipfs.txt rename to test/fixtures/test-folder/files/ipfs.txt diff --git a/test/data/test-folder/hello-link b/test/fixtures/test-folder/hello-link similarity index 100% rename from test/data/test-folder/hello-link rename to test/fixtures/test-folder/hello-link diff --git a/test/data/test-folder/ipfs-add.js b/test/fixtures/test-folder/ipfs-add.js similarity index 100% rename from test/data/test-folder/ipfs-add.js rename to test/fixtures/test-folder/ipfs-add.js diff --git a/test/data/test-folder/ls.js b/test/fixtures/test-folder/ls.js similarity index 100% rename from test/data/test-folder/ls.js rename to test/fixtures/test-folder/ls.js diff --git a/test/data/test-folder/version.js b/test/fixtures/test-folder/version.js similarity index 100% rename from test/data/test-folder/version.js rename to test/fixtures/test-folder/version.js diff --git a/test/data/testconfig.json b/test/fixtures/testconfig.json similarity index 100% rename from test/data/testconfig.json rename to test/fixtures/testconfig.json diff --git a/test/data/testfile.txt b/test/fixtures/testfile.txt similarity index 100% rename from test/data/testfile.txt rename to test/fixtures/testfile.txt diff --git a/test/interface-ipfs-core/files.spec.js b/test/interface-ipfs-core/files.spec.js index 80586c4fa..84308c262 100644 --- a/test/interface-ipfs-core/files.spec.js +++ b/test/interface-ipfs-core/files.spec.js @@ -4,18 +4,12 @@ const expect = require('chai').expect const isNode = require('detect-node') -const path = require('path') const test = require('interface-ipfs-core') -const fs = require('fs') -const FactoryClient = require('../factory/factory-client') +const loadFixture = require('aegir/fixtures') -let testfile +const FactoryClient = require('../factory/factory-client') -if (isNode) { - testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt')) -} else { - testfile = require('file!../data/testfile.txt') -} +const testfile = loadFixture(__dirname, '../fixtures/testfile.txt') // add, cat, get and ls tests from interface-ipfs-core let fc diff --git a/test/interface-ipfs-core/get.spec.js b/test/interface-ipfs-core/get.spec.js index 32aa13cd0..a8eeab3ae 100644 --- a/test/interface-ipfs-core/get.spec.js +++ b/test/interface-ipfs-core/get.spec.js @@ -10,20 +10,15 @@ const concat = require('concat-stream') const through = require('through2') const streamEqual = require('stream-equal') const path = require('path') +const loadFixture = require('aegir/fixtures') const FactoryClient = require('../factory/factory-client') -let testfile - -if (isNode) { - testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt')) -} else { - testfile = require('file!../data/testfile.txt') -} +const testfile = loadFixture(__dirname, '../fixtures/testfile.txt') let testfileBig let tfbPath if (isNode) { - tfbPath = path.join(__dirname, '/../data/15mb.random') + tfbPath = path.join(__dirname, '/../fixtures/15mb.random') testfileBig = fs.createReadStream(tfbPath, { bufferSize: 128 }) } diff --git a/test/interface-ipfs-core/ls.spec.js b/test/interface-ipfs-core/ls.spec.js index 44d60fc5b..d62aa58d0 100644 --- a/test/interface-ipfs-core/ls.spec.js +++ b/test/interface-ipfs-core/ls.spec.js @@ -24,7 +24,7 @@ describe('ls', function () { (cb) => fc.spawnNode(cb), (node, cb) => { ipfs = node - const filesPath = path.join(__dirname, '../data/test-folder') + const filesPath = path.join(__dirname, '../fixtures/test-folder') ipfs.util.addFromFs(filesPath, { recursive: true }, cb) }, (hashes, cb) => { diff --git a/test/interface-ipfs-core/name.spec.js b/test/interface-ipfs-core/name.spec.js index 8d0f0f208..da47c97fa 100644 --- a/test/interface-ipfs-core/name.spec.js +++ b/test/interface-ipfs-core/name.spec.js @@ -3,17 +3,9 @@ 'use strict' const expect = require('chai').expect -const fs = require('fs') -const path = require('path') -const isNode = require('detect-node') +const loadFixture = require('aegir/fixtures') -let testfile - -if (isNode) { - testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt')) -} else { - testfile = require('file!../data/testfile.txt') -} +const testfile = loadFixture(__dirname, '../fixtures/testfile.txt') describe('.name', () => { let name diff --git a/test/interface-ipfs-core/refs.spec.js b/test/interface-ipfs-core/refs.spec.js index ea658e736..8db93ff4f 100644 --- a/test/interface-ipfs-core/refs.spec.js +++ b/test/interface-ipfs-core/refs.spec.js @@ -23,7 +23,7 @@ describe('.refs', () => { (cb) => fc.spawnNode(cb), (node, cb) => { ipfs = node - const filesPath = path.join(__dirname, '../data/test-folder') + const filesPath = path.join(__dirname, '../fixtures/test-folder') ipfs.util.addFromFs(filesPath, { recursive: true }, cb) }, (hashes, cb) => { diff --git a/test/ipfs-api/request-api.spec.js b/test/ipfs-api/request-api.spec.js index 79219b7d7..e362a255f 100644 --- a/test/ipfs-api/request-api.spec.js +++ b/test/ipfs-api/request-api.spec.js @@ -57,7 +57,7 @@ describe('ipfsAPI request tests', () => { res.end() }).listen(6001, () => { ipfsAPI('/ip4/127.0.0.1/tcp/6001') - .config.replace('test/data/r-config.json', (err) => { + .config.replace('test/fixtures/r-config.json', (err) => { expect(err).to.not.exist server.close(done) }) diff --git a/test/ipfs-api/util.spec.js b/test/ipfs-api/util.spec.js index b4453a5c8..e0990a9d1 100644 --- a/test/ipfs-api/util.spec.js +++ b/test/ipfs-api/util.spec.js @@ -31,7 +31,7 @@ describe('.util', () => { }) it('.streamAdd', (done) => { - const tfpath = path.join(__dirname, '/../data/testfile.txt') + const tfpath = path.join(__dirname, '/../fixtures/testfile.txt') const rs = fs.createReadStream(tfpath) rs.path = '' // clean the path for testing purposes @@ -43,7 +43,7 @@ describe('.util', () => { }) it('.fsAdd a directory', (done) => { - const filesPath = path.join(__dirname, '../data/test-folder') + const filesPath = path.join(__dirname, '../fixtures/test-folder') ipfs.util.addFromFs(filesPath, { recursive: true }, (err, result) => { expect(err).to.not.exist expect(result.length).to.be.above(8) @@ -52,7 +52,7 @@ describe('.util', () => { }) it('.fsAdd a file', (done) => { - const filePath = path.join(__dirname, '../data/testfile.txt') + const filePath = path.join(__dirname, '../fixtures/testfile.txt') ipfs.util.addFromFs(filePath, (err, result) => { expect(err).to.not.exist expect(result.length).to.be.above(5) diff --git a/test/tmp-disposable-nodes-addrs.json b/test/tmp-disposable-nodes-addrs.json deleted file mode 100644 index 851a00021..000000000 --- a/test/tmp-disposable-nodes-addrs.json +++ /dev/null @@ -1 +0,0 @@ -{"c":"/ip4/127.0.0.1/tcp/56459","a":"/ip4/127.0.0.1/tcp/56466","b":"/ip4/127.0.0.1/tcp/56479"} \ No newline at end of file From b6012167101451c9e8145a7efb5f553cfb1b2baf Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Thu, 3 Nov 2016 14:07:55 +0100 Subject: [PATCH 07/14] node tests passing --- package.json | 4 ++-- src/api/block.js | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index de411691d..91cb7541f 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "multiaddr": "^2.0.3", "multipart-stream": "^2.0.1", "ndjson": "^1.4.3", - "peer-id": "^0.7.0", - "peer-info": "^0.7.1", + "peer-id": "^0.8.0", + "peer-info": "^0.8.0", "promisify-es6": "^1.0.2", "qs": "^6.3.0", "stream-http": "^2.4.1", diff --git a/src/api/block.js b/src/api/block.js index 3e2bd2b81..41c880408 100644 --- a/src/api/block.js +++ b/src/api/block.js @@ -27,13 +27,13 @@ module.exports = (send) => { return callback(err) } if (Buffer.isBuffer(res)) { - Block.create(res, callback) + callback(null, new Block(res)) } else { res.pipe(bl((err, data) => { if (err) { return callback(err) } - Block.create(data, callback) + callback(null, new Block(data)) })) } }) @@ -85,8 +85,7 @@ module.exports = (send) => { if (err) { return callback(err) } - - Block.create(block, callback) + callback(null, new Block(block)) }) }) } From 7eb8dbc83d98aeae65f174f95e22be5ecbfc33ee Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 3 Nov 2016 15:47:36 +0000 Subject: [PATCH 08/14] chore: update deps --- package.json | 8 ++++---- test/fixtures/test-folder/{add.js => add} | 0 test/fixtures/test-folder/{cat.js => cat} | 0 .../test-folder/{ipfs-add.js => ipfs-add} | 0 test/fixtures/test-folder/{ls.js => ls} | 0 .../fixtures/test-folder/{version.js => version} | 0 test/interface-ipfs-core/ls.spec.js | 6 +++--- test/interface-ipfs-core/refs.spec.js | 16 ++++++++-------- 8 files changed, 15 insertions(+), 15 deletions(-) rename test/fixtures/test-folder/{add.js => add} (100%) rename test/fixtures/test-folder/{cat.js => cat} (100%) rename test/fixtures/test-folder/{ipfs-add.js => ipfs-add} (100%) rename test/fixtures/test-folder/{ls.js => ls} (100%) rename test/fixtures/test-folder/{version.js => version} (100%) diff --git a/package.json b/package.json index 91cb7541f..da0e19d46 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "flatmap": "0.0.3", "glob": "^7.1.1", "https-browserify": "0.0.1", - "ipfs-block": "^0.4.0", - "ipld-dag-pb": "^0.1.3", + "ipfs-block": "^0.5.0", + "ipld-dag-pb": "^0.8.0", "is-ipfs": "^0.2.1", "isstream": "^0.1.2", "multiaddr": "^2.0.3", @@ -53,11 +53,11 @@ "url": "https://github.com/ipfs/js-ipfs-api" }, "devDependencies": { - "aegir": "^9.0.1", + "aegir": "^9.1.0", "chai": "^3.5.0", "gulp": "^3.9.1", "hapi": "^15.2.0", - "interface-ipfs-core": "^0.16.6", + "interface-ipfs-core": "^0.18.0", "ipfsd-ctl": "^0.17.0", "pre-commit": "^1.1.3", "socket.io": "^1.5.1", diff --git a/test/fixtures/test-folder/add.js b/test/fixtures/test-folder/add similarity index 100% rename from test/fixtures/test-folder/add.js rename to test/fixtures/test-folder/add diff --git a/test/fixtures/test-folder/cat.js b/test/fixtures/test-folder/cat similarity index 100% rename from test/fixtures/test-folder/cat.js rename to test/fixtures/test-folder/cat diff --git a/test/fixtures/test-folder/ipfs-add.js b/test/fixtures/test-folder/ipfs-add similarity index 100% rename from test/fixtures/test-folder/ipfs-add.js rename to test/fixtures/test-folder/ipfs-add diff --git a/test/fixtures/test-folder/ls.js b/test/fixtures/test-folder/ls similarity index 100% rename from test/fixtures/test-folder/ls.js rename to test/fixtures/test-folder/ls diff --git a/test/fixtures/test-folder/version.js b/test/fixtures/test-folder/version similarity index 100% rename from test/fixtures/test-folder/version.js rename to test/fixtures/test-folder/version diff --git a/test/interface-ipfs-core/ls.spec.js b/test/interface-ipfs-core/ls.spec.js index d62aa58d0..fdb5be93e 100644 --- a/test/interface-ipfs-core/ls.spec.js +++ b/test/interface-ipfs-core/ls.spec.js @@ -29,7 +29,7 @@ describe('ls', function () { }, (hashes, cb) => { folder = hashes[hashes.length - 1].hash - expect(folder).to.be.eql('QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6') + expect(folder).to.be.eql('QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh') cb() } ], done) @@ -45,7 +45,7 @@ describe('ls', function () { expect(res).to.have.a.property('Objects') expect(res.Objects[0]).to.have.a.property('Links') - expect(res.Objects[0]).to.have.property('Hash', 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6') + expect(res.Objects[0]).to.have.property('Hash', 'QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh') done() }) }) @@ -72,7 +72,7 @@ describe('ls', function () { .then((res) => { expect(res).to.have.a.property('Objects') expect(res.Objects[0]).to.have.a.property('Links') - expect(res.Objects[0]).to.have.property('Hash', 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6') + expect(res.Objects[0]).to.have.property('Hash', 'QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh') }) }) diff --git a/test/interface-ipfs-core/refs.spec.js b/test/interface-ipfs-core/refs.spec.js index 8db93ff4f..5b33662b0 100644 --- a/test/interface-ipfs-core/refs.spec.js +++ b/test/interface-ipfs-core/refs.spec.js @@ -28,7 +28,7 @@ describe('.refs', () => { }, (hashes, cb) => { folder = hashes[hashes.length - 1].hash - expect(folder).to.be.eql('QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6') + expect(folder).to.be.eql('QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh') cb() } ], done) @@ -39,25 +39,25 @@ describe('.refs', () => { }) const result = [{ - Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmcUYKmQxmTcFom4R4UZP7FWeQzgJkwcFn51XrvsMy7PE9 add.js', + Ref: 'QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh QmcUYKmQxmTcFom4R4UZP7FWeQzgJkwcFn51XrvsMy7PE9 add', Err: '' }, { - Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmNeHxDfQfjVFyYj2iruvysLH9zpp78v3cu1s3BZq1j5hY cat.js', + Ref: 'QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh QmNeHxDfQfjVFyYj2iruvysLH9zpp78v3cu1s3BZq1j5hY cat', Err: '' }, { - Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmTYFLz5vsdMpq4XXw1a1pSxujJc9Z5V3Aw1Qg64d849Zy files', + Ref: 'QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh QmTYFLz5vsdMpq4XXw1a1pSxujJc9Z5V3Aw1Qg64d849Zy files', Err: '' }, { - Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmY9cxiHqTFoWamkQVkpmmqzBrY3hCBEL2XNu3NtX74Fuu hello-link', + Ref: 'QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh QmY9cxiHqTFoWamkQVkpmmqzBrY3hCBEL2XNu3NtX74Fuu hello-link', Err: '' }, { - Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmU7wetVaAqc3Meurif9hcYBHGvQmL5QdpPJYBoZizyTNL ipfs-add.js', + Ref: 'QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh QmU7wetVaAqc3Meurif9hcYBHGvQmL5QdpPJYBoZizyTNL ipfs-add', Err: '' }, { - Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmctZfSuegbi2TMFY2y3VQjxsH5JbRBu7XmiLfHNvshhio ls.js', + Ref: 'QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh QmctZfSuegbi2TMFY2y3VQjxsH5JbRBu7XmiLfHNvshhio ls', Err: '' }, { - Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmbkMNB6rwfYAxRvnG9CWJ6cKKHEdq2ZKTozyF5FQ7H8Rs version.js', + Ref: 'QmQao3KNcpCsdXaLGpjieFGMfXzsSXgsf6Rnc5dJJA3QMh QmbkMNB6rwfYAxRvnG9CWJ6cKKHEdq2ZKTozyF5FQ7H8Rs version', Err: '' }] From cbe65823cc34b389ce93211b738083d4d8e92cf2 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Thu, 3 Nov 2016 18:34:49 +0100 Subject: [PATCH 09/14] use new aegir fixtures --- .aegir.js | 12 ++++++++++++ test/interface-ipfs-core/files.spec.js | 7 ++++++- test/interface-ipfs-core/get.spec.js | 8 +++++--- test/interface-ipfs-core/name.spec.js | 8 +++++++- 4 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 .aegir.js diff --git a/.aegir.js b/.aegir.js new file mode 100644 index 000000000..efeced9a7 --- /dev/null +++ b/.aegir.js @@ -0,0 +1,12 @@ +'use strict' + +module.exports = { + karma: { + files: [{ + pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*', + watched: false, + served: true, + included: false + }] + } +} \ No newline at end of file diff --git a/test/interface-ipfs-core/files.spec.js b/test/interface-ipfs-core/files.spec.js index 84308c262..43e181ce7 100644 --- a/test/interface-ipfs-core/files.spec.js +++ b/test/interface-ipfs-core/files.spec.js @@ -9,7 +9,12 @@ const loadFixture = require('aegir/fixtures') const FactoryClient = require('../factory/factory-client') -const testfile = loadFixture(__dirname, '../fixtures/testfile.txt') +let testfile +if (isNode) { + testfile = loadFixture(__dirname, '../fixtures/testfile.txt') +} else { + testfile = loadFixture(__dirname, 'fixtures/testfile.txt') +} // add, cat, get and ls tests from interface-ipfs-core let fc diff --git a/test/interface-ipfs-core/get.spec.js b/test/interface-ipfs-core/get.spec.js index a8eeab3ae..fe6d22505 100644 --- a/test/interface-ipfs-core/get.spec.js +++ b/test/interface-ipfs-core/get.spec.js @@ -13,13 +13,15 @@ const path = require('path') const loadFixture = require('aegir/fixtures') const FactoryClient = require('../factory/factory-client') -const testfile = loadFixture(__dirname, '../fixtures/testfile.txt') - +let testfile let testfileBig let tfbPath if (isNode) { - tfbPath = path.join(__dirname, '/../fixtures/15mb.random') + tfbPath = path.join(__dirname, '../fixtures/15mb.random') testfileBig = fs.createReadStream(tfbPath, { bufferSize: 128 }) + testfile = loadFixture(__dirname, '../fixtures/testfile.txt') +} else { + testfile = loadFixture(__dirname, 'fixtures/testfile.txt') } describe('.get', () => { diff --git a/test/interface-ipfs-core/name.spec.js b/test/interface-ipfs-core/name.spec.js index da47c97fa..20de8f012 100644 --- a/test/interface-ipfs-core/name.spec.js +++ b/test/interface-ipfs-core/name.spec.js @@ -3,9 +3,15 @@ 'use strict' const expect = require('chai').expect +const isNode = require('detect-node') const loadFixture = require('aegir/fixtures') -const testfile = loadFixture(__dirname, '../fixtures/testfile.txt') +let testfile +if (isNode) { + testfile = loadFixture(__dirname, '../fixtures/testfile.txt') +} else { + testfile = loadFixture(__dirname, 'fixtures/testfile.txt') +} describe('.name', () => { let name From 32f11acffc40d31af18da43d66039978fcc6ae27 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Sat, 5 Nov 2016 17:12:47 +0100 Subject: [PATCH 10/14] tests passing --- .travis.yml | 2 +- README.md | 2 + package.json | 6 +- test/factory/daemon-spawner.js | 49 ++++++++------- test/setup/spawn-daemons.js | 110 +++++++++++++++------------------ 5 files changed, 81 insertions(+), 88 deletions(-) diff --git a/.travis.yml b/.travis.yml index bddac4362..ec2e62243 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ before_install: script: - npm run lint - - npm run test:node + - npm run test - npm run coverage before_script: diff --git a/README.md b/README.md index 2d8d70f70..793a55c0e 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,8 @@ If are using this module in a browser with something like browserify, then you w ```bash $ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://example.com\"]" +$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "\"true\"" +$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"POST\", \"GET\"]" ``` ## Usage diff --git a/package.json b/package.json index da0e19d46..013d77f6d 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,7 @@ "browser": { "glob": false, "fs": false, - "http": "stream-http", - "https": "https-browserify" + "stream": "readable-stream" }, "scripts": { "test": "gulp test", @@ -28,7 +27,6 @@ "detect-node": "^2.0.3", "flatmap": "0.0.3", "glob": "^7.1.1", - "https-browserify": "0.0.1", "ipfs-block": "^0.5.0", "ipld-dag-pb": "^0.8.0", "is-ipfs": "^0.2.1", @@ -36,11 +34,11 @@ "multiaddr": "^2.0.3", "multipart-stream": "^2.0.1", "ndjson": "^1.4.3", + "once": "^1.4.0", "peer-id": "^0.8.0", "peer-info": "^0.8.0", "promisify-es6": "^1.0.2", "qs": "^6.3.0", - "stream-http": "^2.4.1", "streamifier": "^0.1.1", "tar-stream": "^1.5.2", "wreck": "^10.0.0" diff --git a/test/factory/daemon-spawner.js b/test/factory/daemon-spawner.js index 9499f51f0..7d9c88cf0 100644 --- a/test/factory/daemon-spawner.js +++ b/test/factory/daemon-spawner.js @@ -2,7 +2,9 @@ // const defaultConfig = require('./default-config.json') const ipfsd = require('ipfsd-ctl') -const series = require('run-series') +const series = require('async/series') +const eachSeries = require('async/eachSeries') +const once = require('once') module.exports = Factory @@ -11,7 +13,7 @@ function Factory () { return new Factory() } - const nodes = [] + let nodes = [] this.spawnNode = (repoPath, config, callback) => { if (typeof repoPath === 'function') { @@ -44,11 +46,18 @@ function Factory () { }) } - this.dismantle = function (callback) { - series( - nodes.map((node) => { - return node.stopDaemon - }), callback) + this.dismantle = (callback) => { + eachSeries(nodes, (node, cb) => { + cb = once(cb) + node.stopDaemon(cb) + }, (err) => { + if (err) { + return callback(err) + } + nodes = [] + + callback() + }) } } @@ -62,23 +71,19 @@ function spawnEphemeralNode (callback) { // doesn't work as expected series([ (cb) => { - node.setConfig('Bootstrap', null, cb) - }, - (cb) => { - node.setConfig('Discovery', '{}', cb) - }, - (cb) => { - const headers = { - HTTPHeaders: { - 'Access-Control-Allow-Origin': ['*'], - 'Access-Control-Allow-Credentials': 'true' - } + const configValues = { + // Bootstrap: [], + Discovery: {}, + 'HTTPHeaders.Access-Control-Allow-Origin': ['*'], + 'HTTPHeaders.Access-Control-Allow-Credentials': 'true', + 'HTTPHeaders.Access-Control-Allow-Methods': ['PUT', 'POST', 'GET'] } - node.setConfig('API', JSON.stringify(headers), cb) + + eachSeries(Object.keys(configValues), (configKey, cb) => { + node.setConfig(`API.${configKey}`, JSON.stringify(configValues[configKey]), cb) + }, cb) }, - (cb) => { - node.startDaemon(cb) - } + (cb) => node.startDaemon(cb) ], (err) => { if (err) { return callback(err) diff --git a/test/setup/spawn-daemons.js b/test/setup/spawn-daemons.js index 986073732..6b831d50b 100644 --- a/test/setup/spawn-daemons.js +++ b/test/setup/spawn-daemons.js @@ -6,6 +6,8 @@ const gulp = require('gulp') const fs = require('fs') const path = require('path') const ipfsd = require('ipfsd-ctl') +const eachSeries = require('async/eachSeries') +const parallel = require('async/parallel') let daemons @@ -13,82 +15,60 @@ function startDisposableDaemons (callback) { // a, b, c const ipfsNodes = {} - // a, b, c - const apiAddrs = {} - - let counter = 0 - - function finish () { - counter++ - if (counter === 3) { - const targetPath = path.join(__dirname, '/tmp-disposable-nodes-addrs.json') - fs.writeFileSync(targetPath, JSON.stringify(apiAddrs)) - callback(ipfsNodes) - } - } - - function startIndependentNode (nodes, addrs, key, cb) { + function startIndependentNode (nodes, key, cb) { ipfsd.disposable((err, node) => { if (err) { - throw err + return cb(err) } nodes[key] = node console.log(' ipfs init done - (bootstrap and mdns off) - ' + key) - nodes[key].setConfig('Bootstrap', null, (err) => { + const configValues = { + // Bootstrap: [], + Discovery: {}, + 'HTTPHeaders.Access-Control-Allow-Origin': ['*'], + 'HTTPHeaders.Access-Control-Allow-Credentials': 'true', + 'HTTPHeaders.Access-Control-Allow-Methods': ['PUT', 'POST', 'GET'] + } + + eachSeries(Object.keys(configValues), (configKey, cb) => { + nodes[key].setConfig(`API.${configKey}`, JSON.stringify(configValues[configKey]), cb) + }, (err) => { if (err) { - throw err + return cb(err) } - nodes[key].setConfig('Discovery', '{}', (err) => { - if (err) { - throw err - } - - const headers = { - HTTPHeaders: { - 'Access-Control-Allow-Origin': ['*'] - } - } - nodes[key].setConfig('API', JSON.stringify(headers), (err) => { - if (err) { - throw err - } - nodes[key].startDaemon((err, ignore) => { - if (err) { - throw err - } - - addrs[key] = nodes[key].apiAddr - cb() - }) - }) - }) + nodes[key].startDaemon(cb) }) }) } - startIndependentNode(ipfsNodes, apiAddrs, 'a', finish) - startIndependentNode(ipfsNodes, apiAddrs, 'b', finish) - startIndependentNode(ipfsNodes, apiAddrs, 'c', finish) + parallel([ + (cb) => startIndependentNode(ipfsNodes, 'a', cb), + (cb) => startIndependentNode(ipfsNodes, 'b', cb), + (cb) => startIndependentNode(ipfsNodes, 'c', cb) + ], (err) => { + if (err) { + return callback(err) + } + const targetPath = path.join(__dirname, '/tmp-disposable-nodes-addrs.json') + fs.writeFileSync(targetPath, JSON.stringify({ + a: ipfsNodes.a.apiAddr, + b: ipfsNodes.b.apiAddr, + c: ipfsNodes.c.apiAddr + })) + callback(null, ipfsNodes) + }) } function stopDisposableDaemons (ds, callback) { - let counter = 0 - function finish () { - counter++ - if (counter === 3) { - callback() - } - } - - function stopIPFSNode (list, key, cb) { + function stopIPFSNode (node, cb) { let nodeStopped - list[key].stopDaemon((err) => { + node.stopDaemon((err) => { if (err) { - throw err + return cb(err) } if (!nodeStopped) { nodeStopped = true @@ -97,20 +77,28 @@ function stopDisposableDaemons (ds, callback) { }) } - stopIPFSNode(ds, 'a', finish) - stopIPFSNode(ds, 'b', finish) - stopIPFSNode(ds, 'c', finish) + parallel([ + (cb) => stopIPFSNode(ds.a, cb), + (cb) => stopIPFSNode(ds.b, cb), + (cb) => stopIPFSNode(ds.c, cb) + ], callback) } gulp.task('daemons:start', (done) => { - startDisposableDaemons((d) => { + startDisposableDaemons((err, d) => { + if (err) { + return done(err) + } daemons = d done() }) }) gulp.task('daemons:stop', (done) => { - stopDisposableDaemons(daemons, () => { + stopDisposableDaemons(daemons, (err) => { + if (err) { + return done(err) + } daemons = null done() }) From e0f7ca2f0670b40ace450ea37e12d072d781f677 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 7 Nov 2016 11:07:59 +0100 Subject: [PATCH 11/14] cleanup --- README.md | 2 +- test/factory/daemon-spawner.js | 2 +- test/setup/spawn-daemons.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 793a55c0e..6744ed17e 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ If are using this module in a browser with something like browserify, then you w ```bash $ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://example.com\"]" -$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "\"true\"" +$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]" $ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"POST\", \"GET\"]" ``` diff --git a/test/factory/daemon-spawner.js b/test/factory/daemon-spawner.js index 7d9c88cf0..86a2d808b 100644 --- a/test/factory/daemon-spawner.js +++ b/test/factory/daemon-spawner.js @@ -72,7 +72,7 @@ function spawnEphemeralNode (callback) { series([ (cb) => { const configValues = { - // Bootstrap: [], + Bootstrap: [], Discovery: {}, 'HTTPHeaders.Access-Control-Allow-Origin': ['*'], 'HTTPHeaders.Access-Control-Allow-Credentials': 'true', diff --git a/test/setup/spawn-daemons.js b/test/setup/spawn-daemons.js index 6b831d50b..5a2d3b659 100644 --- a/test/setup/spawn-daemons.js +++ b/test/setup/spawn-daemons.js @@ -26,7 +26,7 @@ function startDisposableDaemons (callback) { console.log(' ipfs init done - (bootstrap and mdns off) - ' + key) const configValues = { - // Bootstrap: [], + Bootstrap: [], Discovery: {}, 'HTTPHeaders.Access-Control-Allow-Origin': ['*'], 'HTTPHeaders.Access-Control-Allow-Credentials': 'true', From ab10fa7c8507e415179151521734f25dc9fb6077 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 7 Nov 2016 16:31:08 +0000 Subject: [PATCH 12/14] fix: add readable-stream dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 013d77f6d..5bb974025 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "peer-info": "^0.8.0", "promisify-es6": "^1.0.2", "qs": "^6.3.0", + "readable-stream": "^1.1.14", "streamifier": "^0.1.1", "tar-stream": "^1.5.2", "wreck": "^10.0.0" From 2fe563d7d5871a05a019b33a2a277eeeddbd1f95 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 7 Nov 2016 17:00:00 +0000 Subject: [PATCH 13/14] docs: add note about red CI --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6744ed17e..489cc5da3 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ ipfs-api [![Travis CI](https://travis-ci.org/ipfs/js-ipfs-api.svg?branch=master)](https://travis-ci.org/ipfs/js-ipfs-api) [![Circle CI](https://circleci.com/gh/ipfs/js-ipfs-api.svg?style=svg)](https://circleci.com/gh/ipfs/js-ipfs-api) +> **Note: If you see CI red, that is due a failing test when adding nested directories in the browser, all the other features work as expect, if this is something you also need, please consider helping us identifying the solution for it, join the discussion at: https://github.com/ipfs/js-ipfs-api/issues/339** + > A client library for the IPFS HTTP API, implemented in JavaScript. This client library implements the [interface-ipfs-core](https://github.com/ipfs/interface-ipfs-core) enabling applications to change between a embebed js-ipfs node and any remote IPFS node without having to change the code. In addition, this client library implements a set of utility functions. ![](https://github.com/ipfs/interface-ipfs-core/raw/master/img/badge.png) From a6eb4be68839d92c231522f31baa11d38e8de500 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Mon, 7 Nov 2016 18:46:09 +0100 Subject: [PATCH 14/14] docs(readme): add badgesW --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 489cc5da3..9cc2eee22 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ ipfs-api [![Dependency Status](https://david-dm.org/ipfs/js-ipfs-api.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-api) [![Travis CI](https://travis-ci.org/ipfs/js-ipfs-api.svg?branch=master)](https://travis-ci.org/ipfs/js-ipfs-api) [![Circle CI](https://circleci.com/gh/ipfs/js-ipfs-api.svg?style=svg)](https://circleci.com/gh/ipfs/js-ipfs-api) +![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square) +![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square) + +[![Sauce Test Status](https://saucelabs.com/browser-matrix/js-ipfs-api.svg)](https://saucelabs.com/u/ipfs-js-api) > **Note: If you see CI red, that is due a failing test when adding nested directories in the browser, all the other features work as expect, if this is something you also need, please consider helping us identifying the solution for it, join the discussion at: https://github.com/ipfs/js-ipfs-api/issues/339**