From 205b548445e291d143095472b0eec1f6b4070e1e Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Tue, 22 Mar 2016 15:27:35 +0100 Subject: [PATCH 1/4] Setup dignified.js --- .travis.yml | 19 +++++++++++++++ package.json | 14 +++++++---- src/block-service.js | 8 +++--- src/block.js | 10 +++++--- src/index.js | 2 ++ src/util.js | 9 ++++--- {tests => test}/block-service-test.js | 5 ++-- {tests => test}/block-test.js | 7 +++--- test/browser.js | 6 +++++ ...c55d25f3042c22501e41d1246e7a1e9d3d8ec.data | 0 ...dcf095c1d219356cdf538ffce705a52d5738d.data | Bin ...ea3b310512d7767a9abfbd7a928a85e977173.data | 0 ...0b0d3be3528fbbcc814feb7f2fbf71ca06162.data | Bin ...60e64383755a8c5163ba3c053c3b65777ed16.data | 0 ...0aa787e820fe98dbf68131bf70e796693d373.data | Bin ...ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data | Bin ...223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data | 0 ...932be52c56d99c5966b65e0111239f098bbef.data | 0 ...6f9fccbf5fa0106df39556b3b411ea4121a6f.data | Bin ...481e88d2c710099738ccbd6964075730194ba.data | Bin ...3346a644605d7614dca53cd3a59f7385a8abb.data | 0 ...7f28fa9367ee167c312e6d65a2e02e81ab815.data | Bin ...68af3d10e1a497971629c07606bfdb812303d.data | Bin ...02a72b057d1c7f2e682d0776a5363e2cca974.data | 0 ...dced761633aca6704ba01a9be55934d95e5f1.data | Bin ...16cfa9a7ae5533f8e997cdab2ebadd7506340.data | 0 ...e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data | 0 ...c0f1e4947cff8e422610996e609dbcb976598.data | 0 ...62f687a00c638bcb580feae06452e0c1f20b4.data | 0 ...56baef91c7dc345e73d049ab570abe10dfbb9.data | Bin ...3edca90b68053c00b3004b7f0accbe1e8eedf.data | Bin ...2fdadf9d45666c3be122a2efb5db93c1d5fa6.data | 0 ...be72a83e80f9c7bca1abcaa42298a57a33ff5.data | Bin ...0e8710bd97eafcce5380a127dcc5ea32a887f.data | Bin ...fb92427ae41e4649b934ca495991b7852b855.data | 0 ...9e72dc99d23a391d3db5e1e42d00527241671.data | 0 ...eb49e3772f8949dacec55d099e3e17ac851c3.data | 0 ...41317afc9f967abe2aa05e7c641f7bbe98a37.data | Bin ...807def07b0db2f018808620eb30b980e94011.data | 0 ...38b95dd29d31eac6433af0fb6fcd83dd80778.data | 0 {tests => test}/example-repo/config | 0 .../example-repo/datastore/000002.ldb | Bin .../example-repo/datastore/000005.ldb | Bin .../example-repo/datastore/CURRENT | 0 {tests => test}/example-repo/datastore/LOCK | 0 {tests => test}/example-repo/datastore/LOG | 0 .../example-repo/datastore/LOG.old | 0 .../example-repo/datastore/MANIFEST-000007 | Bin {tests => test}/example-repo/version | 0 tests/index.js => test/node.js | 23 +++++++++--------- 50 files changed, 68 insertions(+), 35 deletions(-) create mode 100644 .travis.yml rename {tests => test}/block-service-test.js (98%) rename {tests => test}/block-test.js (93%) create mode 100644 test/browser.js rename {tests => test}/example-repo/blocks/1220120f/1220120f6af601d46e10b2d2e11ed71c55d25f3042c22501e41d1246e7a1e9d3d8ec.data (100%) rename {tests => test}/example-repo/blocks/122031d6/122031d6da265092f1b03fec969243fdcf095c1d219356cdf538ffce705a52d5738d.data (100%) rename {tests => test}/example-repo/blocks/122031e7/122031e7a41c15d03feb8cd793c3348ea3b310512d7767a9abfbd7a928a85e977173.data (100%) rename {tests => test}/example-repo/blocks/12203628/12203628a4a19525dd84bbbffe132ec0b0d3be3528fbbcc814feb7f2fbf71ca06162.data (100%) rename {tests => test}/example-repo/blocks/12204a5a/12204a5a95586f52e25811cf214677160e64383755a8c5163ba3c053c3b65777ed16.data (100%) rename {tests => test}/example-repo/blocks/1220503a/1220503aec3bbd533b39fd56f5148750aa787e820fe98dbf68131bf70e796693d373.data (100%) rename {tests => test}/example-repo/blocks/12205200/12205200cc6b6f79e1588480d9f9016ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data (100%) rename {tests => test}/example-repo/blocks/122052c6/122052c63c7775396b3f82c639977a7223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data (100%) rename {tests => test}/example-repo/blocks/12205994/122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef.data (100%) rename {tests => test}/example-repo/blocks/12205dff/12205dffb3c88f3de7036dc1840f0086f9fccbf5fa0106df39556b3b411ea4121a6f.data (100%) rename {tests => test}/example-repo/blocks/12206006/1220600627d80642365010791de1d62481e88d2c710099738ccbd6964075730194ba.data (100%) rename {tests => test}/example-repo/blocks/122062ce/122062ce1f2c91a13a97b596e873b5a3346a644605d7614dca53cd3a59f7385a8abb.data (100%) rename {tests => test}/example-repo/blocks/12206781/122067817186b8ff365c758f387e3ae7f28fa9367ee167c312e6d65a2e02e81ab815.data (100%) rename {tests => test}/example-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data (100%) rename {tests => test}/example-repo/blocks/1220709b/1220709b2dcc5f6a90ad64d6fe3a5d202a72b057d1c7f2e682d0776a5363e2cca974.data (100%) rename {tests => test}/example-repo/blocks/12207d5c/12207d5cd815f41ac0566dd956c8541dced761633aca6704ba01a9be55934d95e5f1.data (100%) rename {tests => test}/example-repo/blocks/12207fb8/12207fb898b5d7be46d85feb75d894e16cfa9a7ae5533f8e997cdab2ebadd7506340.data (100%) rename {tests => test}/example-repo/blocks/12208b87/12208b872ca4ee517608331696dd6b3e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data (100%) rename {tests => test}/example-repo/blocks/122090c0/122090c07a7795c1193510a696d1fdfc0f1e4947cff8e422610996e609dbcb976598.data (100%) rename {tests => test}/example-repo/blocks/1220929a/1220929a303c39da8a0b67c09697462f687a00c638bcb580feae06452e0c1f20b4.data (100%) rename {tests => test}/example-repo/blocks/1220933b/1220933b41d37fd4508cdff45930dff56baef91c7dc345e73d049ab570abe10dfbb9.data (100%) rename {tests => test}/example-repo/blocks/12209d6c/12209d6c2be50f706953479ab9df2ce3edca90b68053c00b3004b7f0accbe1e8eedf.data (100%) rename {tests => test}/example-repo/blocks/1220a52c/1220a52c3602030cb912edfe4de97002fdadf9d45666c3be122a2efb5db93c1d5fa6.data (100%) rename {tests => test}/example-repo/blocks/1220c0fc/1220c0fc6b49543d7bf04e83d2a5a7cbe72a83e80f9c7bca1abcaa42298a57a33ff5.data (100%) rename {tests => test}/example-repo/blocks/1220d15b/1220d15b2cf7ecc6eccbf7e68c2e4290e8710bd97eafcce5380a127dcc5ea32a887f.data (100%) rename {tests => test}/example-repo/blocks/1220e3b0/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.data (100%) rename {tests => test}/example-repo/blocks/1220e586/1220e586199640e1a4c63fa38c5434b9e72dc99d23a391d3db5e1e42d00527241671.data (100%) rename {tests => test}/example-repo/blocks/1220e5f8/1220e5f87b2b69cb032267bbc72a598eb49e3772f8949dacec55d099e3e17ac851c3.data (100%) rename {tests => test}/example-repo/blocks/1220e605/1220e605408ac3f78113ac9a7fd486441317afc9f967abe2aa05e7c641f7bbe98a37.data (100%) rename {tests => test}/example-repo/blocks/1220e6a0/1220e6a045864ff8569e43e4866c0af807def07b0db2f018808620eb30b980e94011.data (100%) rename {tests => test}/example-repo/blocks/1220ec5b/1220ec5b533a3218991f4377b8b8c2538b95dd29d31eac6433af0fb6fcd83dd80778.data (100%) rename {tests => test}/example-repo/config (100%) rename {tests => test}/example-repo/datastore/000002.ldb (100%) rename {tests => test}/example-repo/datastore/000005.ldb (100%) rename {tests => test}/example-repo/datastore/CURRENT (100%) rename {tests => test}/example-repo/datastore/LOCK (100%) rename {tests => test}/example-repo/datastore/LOG (100%) rename {tests => test}/example-repo/datastore/LOG.old (100%) rename {tests => test}/example-repo/datastore/MANIFEST-000007 (100%) rename {tests => test}/example-repo/version (100%) rename tests/index.js => test/node.js (61%) diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6c4753d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: node_js +node_js: + - '4' + - '5' + +before_install: + - npm i -g npm + # Workaround for a permissions issue with Travis virtual machine images + +addons: + firefox: 'latest' + +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + +script: + - npm run lint + - npm test diff --git a/package.json b/package.json index efdcae7..6d53f01 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,12 @@ "description": "JavaScript Implementation of Block and BlockService", "main": "src/index.js", "scripts": { - "test": "mocha tests/index.js", - "lint": "standard" + "lint": "dignified-lint", + "build": "dignified-build", + "test": "dignified-test", + "test:node": "dignified-test node", + "test:browser": "dignified-test browser", + "release": "dignified-release" }, "pre-commit": [ "lint", @@ -30,17 +34,17 @@ "devDependencies": { "bs58": "^3.0.0", "chai": "^3.5.0", + "dignified.js": "github:dignifiedquire/dignified.js", "fs-blob-store": "^5.2.1", "ipfs-repo": "^0.3.0", - "mocha": "^2.4.5", "ncp": "^2.0.0", "pre-commit": "^1.1.2", - "rimraf": "^2.5.1", - "standard": "^5.4.1" + "rimraf": "^2.5.1" }, "dependencies": { "async": "^1.5.2", "bl": "^1.0.1", + "detect-node": "^2.0.3", "multihashing": "^0.2.0" } } diff --git a/src/block-service.js b/src/block-service.js index 58bd292..def78f2 100644 --- a/src/block-service.js +++ b/src/block-service.js @@ -1,15 +1,14 @@ +'use strict' const Block = require('./block') const bl = require('bl') const async = require('async') -module.exports = BlockService - // BlockService is a hybrid block datastore. It stores data in a local // datastore and may retrieve data from a remote Exchange. // It uses an internal `datastore.Datastore` instance to store values. function BlockService (ipfsRepo, exchange) { this.addBlock = (block, callback) => { - var ws = ipfsRepo.datastore.createWriteStream(block.key) + const ws = ipfsRepo.datastore.createWriteStream(block.key) ws.write(block.data) ws.on('finish', callback) ws.end() @@ -44,7 +43,7 @@ function BlockService (ipfsRepo, exchange) { return callback(new Error('Invalid batch of multihashes')) } - var blocks = [] + const blocks = [] async.each(multihashes, (multihash, next) => { this.getBlock(multihash, (err, block) => { @@ -77,3 +76,4 @@ function BlockService (ipfsRepo, exchange) { } } +module.exports = BlockService diff --git a/src/block.js b/src/block.js index c4e783a..6e90ec6 100644 --- a/src/block.js +++ b/src/block.js @@ -1,14 +1,16 @@ +'use strict' const util = require('./util') // Immutable block of data - -module.exports = Block - function Block (data) { if (!data) { throw new Error('Block must be constructed with data') } - if (!(this instanceof Block)) { return new Block(data) } + if (!(this instanceof Block)) { + return new Block(data) + } this.data = new Buffer(data) this.key = util.hash(this.data) } + +module.exports = Block diff --git a/src/index.js b/src/index.js index e518dda..4644a76 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,5 @@ +'use strict' + exports.BlockService = require('./block-service.js') exports.Block = require('./block.js') exports.util = require('./util.js') diff --git a/src/util.js b/src/util.js index 86b3488..4d8add7 100644 --- a/src/util.js +++ b/src/util.js @@ -1,7 +1,10 @@ -var multihashing = require('multihashing') +'use strict' + +const multihashing = require('multihashing') +const isNode = require('detect-node') exports = module.exports // Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits -exports.hash = (data) => { return multihashing(data, 'sha2-256') } -exports.isBrowser = () => { return !!global.window } +exports.hash = (data) => multihashing(data, 'sha2-256') +exports.isBrowser = () => !isNode diff --git a/tests/block-service-test.js b/test/block-service-test.js similarity index 98% rename from tests/block-service-test.js rename to test/block-service-test.js index c4b7afa..bc593f6 100644 --- a/tests/block-service-test.js +++ b/test/block-service-test.js @@ -1,5 +1,4 @@ -/* globals describe, it */ - +/* eslint-env mocha */ 'use strict' const expect = require('chai').expect @@ -9,7 +8,7 @@ const BlockService = require('../src').BlockService const IPFSRepo = require('ipfs-repo') describe('block-service', () => { - var bs + let bs it('create a block-service', (done) => { const repo = new IPFSRepo(process.env.IPFS_PATH) diff --git a/tests/block-test.js b/test/block-test.js similarity index 93% rename from tests/block-test.js rename to test/block-test.js index 5bf1033..af32b02 100644 --- a/tests/block-test.js +++ b/test/block-test.js @@ -1,5 +1,4 @@ -/* globals describe, it */ - +/* eslint-env mocha */ 'use strict' const expect = require('chai').expect @@ -14,7 +13,7 @@ describe('block', () => { }) it('fail to create an empty block', (done) => { - var b + let b try { b = new Block() } catch (err) { @@ -34,7 +33,7 @@ describe('block', () => { // it from the original implementation // It doesn't stricly verify the immutability of the Block object const block = new Block("Can't change this!") - var key = block.key + let key = block.key key = new Buffer('new key') expect(key.equals(block.key)).to.equal(false) diff --git a/test/browser.js b/test/browser.js new file mode 100644 index 0000000..58a75b4 --- /dev/null +++ b/test/browser.js @@ -0,0 +1,6 @@ +/* eslint-env mocha */ +'use strict' + +describe.skip('blocks', () => { + it('works in the browser') +}) diff --git a/tests/example-repo/blocks/1220120f/1220120f6af601d46e10b2d2e11ed71c55d25f3042c22501e41d1246e7a1e9d3d8ec.data b/test/example-repo/blocks/1220120f/1220120f6af601d46e10b2d2e11ed71c55d25f3042c22501e41d1246e7a1e9d3d8ec.data similarity index 100% rename from tests/example-repo/blocks/1220120f/1220120f6af601d46e10b2d2e11ed71c55d25f3042c22501e41d1246e7a1e9d3d8ec.data rename to test/example-repo/blocks/1220120f/1220120f6af601d46e10b2d2e11ed71c55d25f3042c22501e41d1246e7a1e9d3d8ec.data diff --git a/tests/example-repo/blocks/122031d6/122031d6da265092f1b03fec969243fdcf095c1d219356cdf538ffce705a52d5738d.data b/test/example-repo/blocks/122031d6/122031d6da265092f1b03fec969243fdcf095c1d219356cdf538ffce705a52d5738d.data similarity index 100% rename from tests/example-repo/blocks/122031d6/122031d6da265092f1b03fec969243fdcf095c1d219356cdf538ffce705a52d5738d.data rename to test/example-repo/blocks/122031d6/122031d6da265092f1b03fec969243fdcf095c1d219356cdf538ffce705a52d5738d.data diff --git a/tests/example-repo/blocks/122031e7/122031e7a41c15d03feb8cd793c3348ea3b310512d7767a9abfbd7a928a85e977173.data b/test/example-repo/blocks/122031e7/122031e7a41c15d03feb8cd793c3348ea3b310512d7767a9abfbd7a928a85e977173.data similarity index 100% rename from tests/example-repo/blocks/122031e7/122031e7a41c15d03feb8cd793c3348ea3b310512d7767a9abfbd7a928a85e977173.data rename to test/example-repo/blocks/122031e7/122031e7a41c15d03feb8cd793c3348ea3b310512d7767a9abfbd7a928a85e977173.data diff --git a/tests/example-repo/blocks/12203628/12203628a4a19525dd84bbbffe132ec0b0d3be3528fbbcc814feb7f2fbf71ca06162.data b/test/example-repo/blocks/12203628/12203628a4a19525dd84bbbffe132ec0b0d3be3528fbbcc814feb7f2fbf71ca06162.data similarity index 100% rename from tests/example-repo/blocks/12203628/12203628a4a19525dd84bbbffe132ec0b0d3be3528fbbcc814feb7f2fbf71ca06162.data rename to test/example-repo/blocks/12203628/12203628a4a19525dd84bbbffe132ec0b0d3be3528fbbcc814feb7f2fbf71ca06162.data diff --git a/tests/example-repo/blocks/12204a5a/12204a5a95586f52e25811cf214677160e64383755a8c5163ba3c053c3b65777ed16.data b/test/example-repo/blocks/12204a5a/12204a5a95586f52e25811cf214677160e64383755a8c5163ba3c053c3b65777ed16.data similarity index 100% rename from tests/example-repo/blocks/12204a5a/12204a5a95586f52e25811cf214677160e64383755a8c5163ba3c053c3b65777ed16.data rename to test/example-repo/blocks/12204a5a/12204a5a95586f52e25811cf214677160e64383755a8c5163ba3c053c3b65777ed16.data diff --git a/tests/example-repo/blocks/1220503a/1220503aec3bbd533b39fd56f5148750aa787e820fe98dbf68131bf70e796693d373.data b/test/example-repo/blocks/1220503a/1220503aec3bbd533b39fd56f5148750aa787e820fe98dbf68131bf70e796693d373.data similarity index 100% rename from tests/example-repo/blocks/1220503a/1220503aec3bbd533b39fd56f5148750aa787e820fe98dbf68131bf70e796693d373.data rename to test/example-repo/blocks/1220503a/1220503aec3bbd533b39fd56f5148750aa787e820fe98dbf68131bf70e796693d373.data diff --git a/tests/example-repo/blocks/12205200/12205200cc6b6f79e1588480d9f9016ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data b/test/example-repo/blocks/12205200/12205200cc6b6f79e1588480d9f9016ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data similarity index 100% rename from tests/example-repo/blocks/12205200/12205200cc6b6f79e1588480d9f9016ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data rename to test/example-repo/blocks/12205200/12205200cc6b6f79e1588480d9f9016ccadfda3d8bc7d2f8cdf302aa51dae8dae9da.data diff --git a/tests/example-repo/blocks/122052c6/122052c63c7775396b3f82c639977a7223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data b/test/example-repo/blocks/122052c6/122052c63c7775396b3f82c639977a7223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data similarity index 100% rename from tests/example-repo/blocks/122052c6/122052c63c7775396b3f82c639977a7223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data rename to test/example-repo/blocks/122052c6/122052c63c7775396b3f82c639977a7223c2d96a9f70b5fd8b1d513f8c5b69dcaed4.data diff --git a/tests/example-repo/blocks/12205994/122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef.data b/test/example-repo/blocks/12205994/122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef.data similarity index 100% rename from tests/example-repo/blocks/12205994/122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef.data rename to test/example-repo/blocks/12205994/122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef.data diff --git a/tests/example-repo/blocks/12205dff/12205dffb3c88f3de7036dc1840f0086f9fccbf5fa0106df39556b3b411ea4121a6f.data b/test/example-repo/blocks/12205dff/12205dffb3c88f3de7036dc1840f0086f9fccbf5fa0106df39556b3b411ea4121a6f.data similarity index 100% rename from tests/example-repo/blocks/12205dff/12205dffb3c88f3de7036dc1840f0086f9fccbf5fa0106df39556b3b411ea4121a6f.data rename to test/example-repo/blocks/12205dff/12205dffb3c88f3de7036dc1840f0086f9fccbf5fa0106df39556b3b411ea4121a6f.data diff --git a/tests/example-repo/blocks/12206006/1220600627d80642365010791de1d62481e88d2c710099738ccbd6964075730194ba.data b/test/example-repo/blocks/12206006/1220600627d80642365010791de1d62481e88d2c710099738ccbd6964075730194ba.data similarity index 100% rename from tests/example-repo/blocks/12206006/1220600627d80642365010791de1d62481e88d2c710099738ccbd6964075730194ba.data rename to test/example-repo/blocks/12206006/1220600627d80642365010791de1d62481e88d2c710099738ccbd6964075730194ba.data diff --git a/tests/example-repo/blocks/122062ce/122062ce1f2c91a13a97b596e873b5a3346a644605d7614dca53cd3a59f7385a8abb.data b/test/example-repo/blocks/122062ce/122062ce1f2c91a13a97b596e873b5a3346a644605d7614dca53cd3a59f7385a8abb.data similarity index 100% rename from tests/example-repo/blocks/122062ce/122062ce1f2c91a13a97b596e873b5a3346a644605d7614dca53cd3a59f7385a8abb.data rename to test/example-repo/blocks/122062ce/122062ce1f2c91a13a97b596e873b5a3346a644605d7614dca53cd3a59f7385a8abb.data diff --git a/tests/example-repo/blocks/12206781/122067817186b8ff365c758f387e3ae7f28fa9367ee167c312e6d65a2e02e81ab815.data b/test/example-repo/blocks/12206781/122067817186b8ff365c758f387e3ae7f28fa9367ee167c312e6d65a2e02e81ab815.data similarity index 100% rename from tests/example-repo/blocks/12206781/122067817186b8ff365c758f387e3ae7f28fa9367ee167c312e6d65a2e02e81ab815.data rename to test/example-repo/blocks/12206781/122067817186b8ff365c758f387e3ae7f28fa9367ee167c312e6d65a2e02e81ab815.data diff --git a/tests/example-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data b/test/example-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data similarity index 100% rename from tests/example-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data rename to test/example-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data diff --git a/tests/example-repo/blocks/1220709b/1220709b2dcc5f6a90ad64d6fe3a5d202a72b057d1c7f2e682d0776a5363e2cca974.data b/test/example-repo/blocks/1220709b/1220709b2dcc5f6a90ad64d6fe3a5d202a72b057d1c7f2e682d0776a5363e2cca974.data similarity index 100% rename from tests/example-repo/blocks/1220709b/1220709b2dcc5f6a90ad64d6fe3a5d202a72b057d1c7f2e682d0776a5363e2cca974.data rename to test/example-repo/blocks/1220709b/1220709b2dcc5f6a90ad64d6fe3a5d202a72b057d1c7f2e682d0776a5363e2cca974.data diff --git a/tests/example-repo/blocks/12207d5c/12207d5cd815f41ac0566dd956c8541dced761633aca6704ba01a9be55934d95e5f1.data b/test/example-repo/blocks/12207d5c/12207d5cd815f41ac0566dd956c8541dced761633aca6704ba01a9be55934d95e5f1.data similarity index 100% rename from tests/example-repo/blocks/12207d5c/12207d5cd815f41ac0566dd956c8541dced761633aca6704ba01a9be55934d95e5f1.data rename to test/example-repo/blocks/12207d5c/12207d5cd815f41ac0566dd956c8541dced761633aca6704ba01a9be55934d95e5f1.data diff --git a/tests/example-repo/blocks/12207fb8/12207fb898b5d7be46d85feb75d894e16cfa9a7ae5533f8e997cdab2ebadd7506340.data b/test/example-repo/blocks/12207fb8/12207fb898b5d7be46d85feb75d894e16cfa9a7ae5533f8e997cdab2ebadd7506340.data similarity index 100% rename from tests/example-repo/blocks/12207fb8/12207fb898b5d7be46d85feb75d894e16cfa9a7ae5533f8e997cdab2ebadd7506340.data rename to test/example-repo/blocks/12207fb8/12207fb898b5d7be46d85feb75d894e16cfa9a7ae5533f8e997cdab2ebadd7506340.data diff --git a/tests/example-repo/blocks/12208b87/12208b872ca4ee517608331696dd6b3e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data b/test/example-repo/blocks/12208b87/12208b872ca4ee517608331696dd6b3e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data similarity index 100% rename from tests/example-repo/blocks/12208b87/12208b872ca4ee517608331696dd6b3e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data rename to test/example-repo/blocks/12208b87/12208b872ca4ee517608331696dd6b3e5cf3497a7845ee8f94456ccf4d1d2f6602b5.data diff --git a/tests/example-repo/blocks/122090c0/122090c07a7795c1193510a696d1fdfc0f1e4947cff8e422610996e609dbcb976598.data b/test/example-repo/blocks/122090c0/122090c07a7795c1193510a696d1fdfc0f1e4947cff8e422610996e609dbcb976598.data similarity index 100% rename from tests/example-repo/blocks/122090c0/122090c07a7795c1193510a696d1fdfc0f1e4947cff8e422610996e609dbcb976598.data rename to test/example-repo/blocks/122090c0/122090c07a7795c1193510a696d1fdfc0f1e4947cff8e422610996e609dbcb976598.data diff --git a/tests/example-repo/blocks/1220929a/1220929a303c39da8a0b67c09697462f687a00c638bcb580feae06452e0c1f20b4.data b/test/example-repo/blocks/1220929a/1220929a303c39da8a0b67c09697462f687a00c638bcb580feae06452e0c1f20b4.data similarity index 100% rename from tests/example-repo/blocks/1220929a/1220929a303c39da8a0b67c09697462f687a00c638bcb580feae06452e0c1f20b4.data rename to test/example-repo/blocks/1220929a/1220929a303c39da8a0b67c09697462f687a00c638bcb580feae06452e0c1f20b4.data diff --git a/tests/example-repo/blocks/1220933b/1220933b41d37fd4508cdff45930dff56baef91c7dc345e73d049ab570abe10dfbb9.data b/test/example-repo/blocks/1220933b/1220933b41d37fd4508cdff45930dff56baef91c7dc345e73d049ab570abe10dfbb9.data similarity index 100% rename from tests/example-repo/blocks/1220933b/1220933b41d37fd4508cdff45930dff56baef91c7dc345e73d049ab570abe10dfbb9.data rename to test/example-repo/blocks/1220933b/1220933b41d37fd4508cdff45930dff56baef91c7dc345e73d049ab570abe10dfbb9.data diff --git a/tests/example-repo/blocks/12209d6c/12209d6c2be50f706953479ab9df2ce3edca90b68053c00b3004b7f0accbe1e8eedf.data b/test/example-repo/blocks/12209d6c/12209d6c2be50f706953479ab9df2ce3edca90b68053c00b3004b7f0accbe1e8eedf.data similarity index 100% rename from tests/example-repo/blocks/12209d6c/12209d6c2be50f706953479ab9df2ce3edca90b68053c00b3004b7f0accbe1e8eedf.data rename to test/example-repo/blocks/12209d6c/12209d6c2be50f706953479ab9df2ce3edca90b68053c00b3004b7f0accbe1e8eedf.data diff --git a/tests/example-repo/blocks/1220a52c/1220a52c3602030cb912edfe4de97002fdadf9d45666c3be122a2efb5db93c1d5fa6.data b/test/example-repo/blocks/1220a52c/1220a52c3602030cb912edfe4de97002fdadf9d45666c3be122a2efb5db93c1d5fa6.data similarity index 100% rename from tests/example-repo/blocks/1220a52c/1220a52c3602030cb912edfe4de97002fdadf9d45666c3be122a2efb5db93c1d5fa6.data rename to test/example-repo/blocks/1220a52c/1220a52c3602030cb912edfe4de97002fdadf9d45666c3be122a2efb5db93c1d5fa6.data diff --git a/tests/example-repo/blocks/1220c0fc/1220c0fc6b49543d7bf04e83d2a5a7cbe72a83e80f9c7bca1abcaa42298a57a33ff5.data b/test/example-repo/blocks/1220c0fc/1220c0fc6b49543d7bf04e83d2a5a7cbe72a83e80f9c7bca1abcaa42298a57a33ff5.data similarity index 100% rename from tests/example-repo/blocks/1220c0fc/1220c0fc6b49543d7bf04e83d2a5a7cbe72a83e80f9c7bca1abcaa42298a57a33ff5.data rename to test/example-repo/blocks/1220c0fc/1220c0fc6b49543d7bf04e83d2a5a7cbe72a83e80f9c7bca1abcaa42298a57a33ff5.data diff --git a/tests/example-repo/blocks/1220d15b/1220d15b2cf7ecc6eccbf7e68c2e4290e8710bd97eafcce5380a127dcc5ea32a887f.data b/test/example-repo/blocks/1220d15b/1220d15b2cf7ecc6eccbf7e68c2e4290e8710bd97eafcce5380a127dcc5ea32a887f.data similarity index 100% rename from tests/example-repo/blocks/1220d15b/1220d15b2cf7ecc6eccbf7e68c2e4290e8710bd97eafcce5380a127dcc5ea32a887f.data rename to test/example-repo/blocks/1220d15b/1220d15b2cf7ecc6eccbf7e68c2e4290e8710bd97eafcce5380a127dcc5ea32a887f.data diff --git a/tests/example-repo/blocks/1220e3b0/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.data b/test/example-repo/blocks/1220e3b0/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.data similarity index 100% rename from tests/example-repo/blocks/1220e3b0/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.data rename to test/example-repo/blocks/1220e3b0/1220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.data diff --git a/tests/example-repo/blocks/1220e586/1220e586199640e1a4c63fa38c5434b9e72dc99d23a391d3db5e1e42d00527241671.data b/test/example-repo/blocks/1220e586/1220e586199640e1a4c63fa38c5434b9e72dc99d23a391d3db5e1e42d00527241671.data similarity index 100% rename from tests/example-repo/blocks/1220e586/1220e586199640e1a4c63fa38c5434b9e72dc99d23a391d3db5e1e42d00527241671.data rename to test/example-repo/blocks/1220e586/1220e586199640e1a4c63fa38c5434b9e72dc99d23a391d3db5e1e42d00527241671.data diff --git a/tests/example-repo/blocks/1220e5f8/1220e5f87b2b69cb032267bbc72a598eb49e3772f8949dacec55d099e3e17ac851c3.data b/test/example-repo/blocks/1220e5f8/1220e5f87b2b69cb032267bbc72a598eb49e3772f8949dacec55d099e3e17ac851c3.data similarity index 100% rename from tests/example-repo/blocks/1220e5f8/1220e5f87b2b69cb032267bbc72a598eb49e3772f8949dacec55d099e3e17ac851c3.data rename to test/example-repo/blocks/1220e5f8/1220e5f87b2b69cb032267bbc72a598eb49e3772f8949dacec55d099e3e17ac851c3.data diff --git a/tests/example-repo/blocks/1220e605/1220e605408ac3f78113ac9a7fd486441317afc9f967abe2aa05e7c641f7bbe98a37.data b/test/example-repo/blocks/1220e605/1220e605408ac3f78113ac9a7fd486441317afc9f967abe2aa05e7c641f7bbe98a37.data similarity index 100% rename from tests/example-repo/blocks/1220e605/1220e605408ac3f78113ac9a7fd486441317afc9f967abe2aa05e7c641f7bbe98a37.data rename to test/example-repo/blocks/1220e605/1220e605408ac3f78113ac9a7fd486441317afc9f967abe2aa05e7c641f7bbe98a37.data diff --git a/tests/example-repo/blocks/1220e6a0/1220e6a045864ff8569e43e4866c0af807def07b0db2f018808620eb30b980e94011.data b/test/example-repo/blocks/1220e6a0/1220e6a045864ff8569e43e4866c0af807def07b0db2f018808620eb30b980e94011.data similarity index 100% rename from tests/example-repo/blocks/1220e6a0/1220e6a045864ff8569e43e4866c0af807def07b0db2f018808620eb30b980e94011.data rename to test/example-repo/blocks/1220e6a0/1220e6a045864ff8569e43e4866c0af807def07b0db2f018808620eb30b980e94011.data diff --git a/tests/example-repo/blocks/1220ec5b/1220ec5b533a3218991f4377b8b8c2538b95dd29d31eac6433af0fb6fcd83dd80778.data b/test/example-repo/blocks/1220ec5b/1220ec5b533a3218991f4377b8b8c2538b95dd29d31eac6433af0fb6fcd83dd80778.data similarity index 100% rename from tests/example-repo/blocks/1220ec5b/1220ec5b533a3218991f4377b8b8c2538b95dd29d31eac6433af0fb6fcd83dd80778.data rename to test/example-repo/blocks/1220ec5b/1220ec5b533a3218991f4377b8b8c2538b95dd29d31eac6433af0fb6fcd83dd80778.data diff --git a/tests/example-repo/config b/test/example-repo/config similarity index 100% rename from tests/example-repo/config rename to test/example-repo/config diff --git a/tests/example-repo/datastore/000002.ldb b/test/example-repo/datastore/000002.ldb similarity index 100% rename from tests/example-repo/datastore/000002.ldb rename to test/example-repo/datastore/000002.ldb diff --git a/tests/example-repo/datastore/000005.ldb b/test/example-repo/datastore/000005.ldb similarity index 100% rename from tests/example-repo/datastore/000005.ldb rename to test/example-repo/datastore/000005.ldb diff --git a/tests/example-repo/datastore/CURRENT b/test/example-repo/datastore/CURRENT similarity index 100% rename from tests/example-repo/datastore/CURRENT rename to test/example-repo/datastore/CURRENT diff --git a/tests/example-repo/datastore/LOCK b/test/example-repo/datastore/LOCK similarity index 100% rename from tests/example-repo/datastore/LOCK rename to test/example-repo/datastore/LOCK diff --git a/tests/example-repo/datastore/LOG b/test/example-repo/datastore/LOG similarity index 100% rename from tests/example-repo/datastore/LOG rename to test/example-repo/datastore/LOG diff --git a/tests/example-repo/datastore/LOG.old b/test/example-repo/datastore/LOG.old similarity index 100% rename from tests/example-repo/datastore/LOG.old rename to test/example-repo/datastore/LOG.old diff --git a/tests/example-repo/datastore/MANIFEST-000007 b/test/example-repo/datastore/MANIFEST-000007 similarity index 100% rename from tests/example-repo/datastore/MANIFEST-000007 rename to test/example-repo/datastore/MANIFEST-000007 diff --git a/tests/example-repo/version b/test/example-repo/version similarity index 100% rename from tests/example-repo/version rename to test/example-repo/version diff --git a/tests/index.js b/test/node.js similarity index 61% rename from tests/index.js rename to test/node.js index 237361b..8da5ae8 100644 --- a/tests/index.js +++ b/test/node.js @@ -1,5 +1,4 @@ -/* globals describe, before, after */ - +/* eslint-env mocha */ 'use strict' const fs = require('fs') @@ -8,35 +7,35 @@ const rimraf = require('rimraf') const expect = require('chai').expect describe('blocks', () => { - const repoExample = process.cwd() + '/tests/example-repo' - const repoTests = process.cwd() + '/tests/repo-just-for-test' + Date.now() + const repoExample = process.cwd() + '/test/example-repo' + const repoTests = process.cwd() + '/test/repo-just-for-test' + Date.now() - before(done => { - ncp(repoExample, repoTests, err => { + before((done) => { + ncp(repoExample, repoTests, (err) => { process.env.IPFS_PATH = repoTests expect(err).to.equal(null) done() }) }) - after(done => { - rimraf(repoTests, err => { + after((done) => { + rimraf(repoTests, (err) => { expect(err).to.equal(null) done() }) }) const tests = fs.readdirSync(__dirname) - tests.filter(file => { + tests.filter((file) => { if (file === 'index.js' || file === 'example-repo' || file.indexOf('repo-just-for-test') > -1 || file === 'browser.js') { return false - } else { - return true } - }).forEach(file => { + + return true + }).forEach((file) => { require('./' + file) }) }) From 1a0dfc08037614cc85167a8886f21399f40e962f Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Tue, 22 Mar 2016 16:20:03 +0100 Subject: [PATCH 2/4] Ingore lib and dist --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 029979f..513e8cb 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ node_modules # Optional REPL history .node_repl_history + +lib +dist \ No newline at end of file From 91f0e3d15df4404102d551961ae095617ac67129 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 7 Apr 2016 21:19:06 +0200 Subject: [PATCH 3/4] Use dignified.js 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d53f01..34bf0b1 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "devDependencies": { "bs58": "^3.0.0", "chai": "^3.5.0", - "dignified.js": "github:dignifiedquire/dignified.js", + "dignified.js": "^1.0.0", "fs-blob-store": "^5.2.1", "ipfs-repo": "^0.3.0", "ncp": "^2.0.0", From 268062be2593d9f14aa542d4983eeeb8ff6e3613 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Fri, 8 Apr 2016 10:50:31 +0200 Subject: [PATCH 4/4] Cleanup and npmignore --- .npmignore | 35 +++++++++++++++++++++++++++++++++++ package.json | 3 ++- src/block-service.js | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..029979f --- /dev/null +++ b/.npmignore @@ -0,0 +1,35 @@ +tests/repo-just-for-test* + +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +node_modules + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history diff --git a/package.json b/package.json index 34bf0b1..1632643 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "test": "dignified-test", "test:node": "dignified-test node", "test:browser": "dignified-test browser", - "release": "dignified-release" + "release": "dignified-release", + "coverage": "dignified-coverage" }, "pre-commit": [ "lint", diff --git a/src/block-service.js b/src/block-service.js index def78f2..18e203e 100644 --- a/src/block-service.js +++ b/src/block-service.js @@ -1,4 +1,5 @@ 'use strict' + const Block = require('./block') const bl = require('bl') const async = require('async')