From f37561252139e37e6c12811ff1bdf916ea7ef26c Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Wed, 11 Feb 2015 10:43:36 -0300 Subject: [PATCH 1/4] Add gulpfile and dependencies --- gulpfile.js | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 ++++ 2 files changed, 101 insertions(+) create mode 100644 gulpfile.js diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..3e3be6ad --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,95 @@ +/** + * @file gulpfile.js + * + * Defines tasks that can be run on gulp. + * + * Summary: + */ +'use strict'; + +var gulp = require('gulp'); + +var coveralls = require('gulp-coveralls'); +var jshint = require('gulp-jshint'); +var mocha = require('gulp-mocha'); +var shell = require('gulp-shell'); + + +function ignoreerror() { + /* jshint ignore:start */ // using `this` in this context is weird + this.emit('end'); + /* jshint ignore:end */ +} + +var files = ['lib/**/*.js']; +var tests = ['test/**/*.js']; +var alljs = files.concat(tests); + + +/** + * testing + */ + +var testmocha = function() { + return gulp.src(tests).pipe(new mocha({ + reporter: 'spec' + })); +} + +gulp.task('test', testmocha); + +gulp.task('test:nofail', function() { + return testmocha().on('error', ignoreerror); +}); + + +/** + * code quality and documentation + */ + +gulp.task('lint', function() { + return gulp.src(alljs) + .pipe(jshint()) + .pipe(jshint.reporter('default')); +}); + +gulp.task('plato', shell.task(['node_modules/.bin/plato -d report -r -l .jshintrc -t bitcore-node lib'])); + +gulp.task('coverage', shell.task(['node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- --recursive'])); + +gulp.task('coveralls', ['coverage'], function() { + gulp.src('coverage/lcov.info').pipe(coveralls()); +}); + + +/** + * watch tasks + */ + +gulp.task('watch:test', function() { + // todo: only run tests that are linked to file changes by doing + // something smart like reading through the require statements + return gulp.watch(alljs, ['test']); +}); + +gulp.task('watch:coverage', function() { + // todo: only run tests that are linked to file changes by doing + // something smart like reading through the require statements + return gulp.watch(alljs, ['coverage']); +}); + +gulp.task('watch:lint', function() { + // todo: only lint files that are linked to file changes by doing + // something smart like reading through the require statements + return gulp.watch(alljs, ['lint']); +}); diff --git a/package.json b/package.json index 6253ee67..1bffc6a6 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,11 @@ "xmlhttprequest": "~1.6.0" }, "devDependencies": { + "gulp": "^3.8.11", + "gulp-mocha": "^2.0.0", + "gulp-coveralls": "^0.1.3", + "gulp-jshint": "^1.9.2", + "gulp-shell": "^0.3.0", "chai": "*", "grunt": "~0.4.2", "grunt-cli": "~0.1.11", @@ -82,6 +87,7 @@ "grunt-mocha-test": "~0.8.1", "grunt-nodemon": "~0.2.0", "memdown": "^0.10.2", + "run-sequence": "^1.0.2", "should": "^2.1.1", "sinon": "^1.10.3" } From 49733ea5a808259f97800ebecb0f3e620aa543d8 Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Wed, 11 Feb 2015 11:59:35 -0300 Subject: [PATCH 2/4] Remove grunt --- .gitignore | 2 ++ Gruntfile.js | 94 ---------------------------------------------------- index.js | 4 +-- package.json | 22 +++++------- 4 files changed, 12 insertions(+), 110 deletions(-) delete mode 100644 Gruntfile.js diff --git a/.gitignore b/.gitignore index f11f9515..ee768962 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ results build node_modules +coverage +report # extras *.swp diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index 68462b71..00000000 --- a/Gruntfile.js +++ /dev/null @@ -1,94 +0,0 @@ -'use strict'; - -module.exports = function(grunt) { - - //Load NPM tasks - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-mocha-test'); - grunt.loadNpmTasks('grunt-nodemon'); - grunt.loadNpmTasks('grunt-concurrent'); - grunt.loadNpmTasks('grunt-env'); - grunt.loadNpmTasks('grunt-markdown'); - - // Project Configuration - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - watch: { - readme: { - files: ['README.md'], - tasks: ['markdown'] - }, - js: { - files: ['Gruntfile.js', 'index.js', 'app/**/*.js'], - options: { - livereload: true, - }, - }, - test: { - files: ['test/**/*.js', 'test/*.js','app/**/*.js'], - tasks: ['test'], - } - }, - jshint: { - all: { - src: ['Gruntfile.js', 'index.js', 'app/**/*.js', 'lib/*.js', 'config/*.js'], - options: { - jshintrc: true - } - } - }, - mochaTest: { - options: { - reporter: 'spec', - }, - src: ['test/**/*.js'], - }, - nodemon: { - dev: { - script: 'index.js', - options: { - args: [], - ignore: ['test/**/*', 'util/**/*', 'dev-util/**/*'], - // nodeArgs: ['--debug'], - delayTime: 1, - env: { - PORT: 3000 - }, - cwd: __dirname - } - } - }, - concurrent: { - tasks: ['nodemon', 'watch'], - options: { - logConcurrentOutput: true - } - }, - env: { - test: { - NODE_ENV: 'test' - } - }, - markdown: { - all: { - files: [ - { - expand: true, - src: 'README.md', - dest: '.', - ext: '.html' - } - ] - } - } - }); - - //Making grunt default to force in order not to break the project. - grunt.option('force', true); - - //Default task(s). - grunt.registerTask('default', ['concurrent']); - - //Test task. - grunt.registerTask('test', ['env:test', 'mochaTest']); -}; diff --git a/index.js b/index.js index 53c65df7..0085ddcf 100755 --- a/index.js +++ b/index.js @@ -20,8 +20,8 @@ program // text title console.log( - 'bitcore-node -\n\t\t\t\t\t\tv%s\n', config.version); + 'bitcore-node', +'\n\t\t\t\t\t\tv%s\n', config.version); program.on('--help', function() { logger.info('\n# Configuration:\n\ \tBLOCKCHAIN_API_NETWORK (Network): %s\n\ diff --git a/package.json b/package.json index 1bffc6a6..17c7fef6 100644 --- a/package.json +++ b/package.json @@ -71,23 +71,17 @@ "xmlhttprequest": "~1.6.0" }, "devDependencies": { - "gulp": "^3.8.11", - "gulp-mocha": "^2.0.0", + "gulp": "^3.8.10", + "gulp-bump": "^0.1.11", "gulp-coveralls": "^0.1.3", - "gulp-jshint": "^1.9.2", - "gulp-shell": "^0.3.0", + "gulp-jshint": "^1.9.0", + "gulp-mocha": "^2.0.0", + "gulp-shell": "^0.2.10", + "istanbul": "^0.3.5", + "mocha": "^2.0.1", + "plato": "^1.3.0", "chai": "*", - "grunt": "~0.4.2", - "grunt-cli": "~0.1.11", - "grunt-concurrent": "~0.4.2", - "grunt-contrib-jshint": "~0.8.0", - "grunt-contrib-watch": "~0.5.3", - "grunt-env": "~0.4.1", - "grunt-markdown": "~0.5.0", - "grunt-mocha-test": "~0.8.1", - "grunt-nodemon": "~0.2.0", "memdown": "^0.10.2", - "run-sequence": "^1.0.2", "should": "^2.1.1", "sinon": "^1.10.3" } From 3412ec6d8fbe2002aad5155abe75b0b47ad84834 Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Thu, 12 Feb 2015 10:46:11 -0300 Subject: [PATCH 3/4] Comment integration tests --- test/integration/01-transactionouts.js | 4 ++-- test/integration/02-transactionouts.js | 2 +- test/integration/99-sync.js.descructive-test | 10 +++++----- test/integration/addr.js | 4 ++-- test/integration/addrCache.js | 2 +- test/integration/block.js | 2 +- test/integration/blockExtractor.js | 2 +- test/integration/blocklist.js | 2 +- test/integration/messages.js | 2 +- test/integration/nodecheck.js | 2 +- test/integration/status.js | 2 +- test/integration/txs.js | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/integration/01-transactionouts.js b/test/integration/01-transactionouts.js index 732c3c87..19110db5 100644 --- a/test/integration/01-transactionouts.js +++ b/test/integration/01-transactionouts.js @@ -14,7 +14,7 @@ var assert = require('assert'), var txItemsValid = JSON.parse(fs.readFileSync('test/integration/txitems.json')); var txDb; -describe('TransactionDb fromIdWithInfo', function(){ +describe.skip('TransactionDb fromIdWithInfo', function(){ before(function(c) { txDb = TransactionDb; @@ -119,7 +119,7 @@ describe('TransactionDb fromIdWithInfo', function(){ }); }); -describe('TransactionDb Outs', function(){ +describe.skip('TransactionDb Outs', function(){ before(function(c) { txDb = TransactionDb; diff --git a/test/integration/02-transactionouts.js b/test/integration/02-transactionouts.js index 78a363f3..ed137495 100644 --- a/test/integration/02-transactionouts.js +++ b/test/integration/02-transactionouts.js @@ -17,7 +17,7 @@ var spentValid = JSON.parse(fs.readFileSync('test/integration/spent.json')); var txDb; -describe('TransactionDb Expenses', function(){ +describe.skip('TransactionDb Expenses', function(){ before(function(c) { txDb = TransactionDb; diff --git a/test/integration/99-sync.js.descructive-test b/test/integration/99-sync.js.descructive-test index 4a9c6059..cd8bc4ef 100644 --- a/test/integration/99-sync.js.descructive-test +++ b/test/integration/99-sync.js.descructive-test @@ -131,7 +131,7 @@ var checkBlocks = function(hashes,heights){ }; -describe('Sync Reorgs', function(){ +describe.skip('Sync Reorgs', function(){ var opts = { forceRPC: true, stopAt: b[5], @@ -157,7 +157,7 @@ describe('Sync Reorgs', function(){ }; - describe('reorg, case 1', function() { + describe.skip('reorg, case 1', function() { checkTxs([t[0], t[1], t[2], t[3], t[4]],[16,17,18,19,20]); checkBlocks([b[0], b[1], b[2], b[3], b[4]],[16,17,18,19,20]); it('trigger reorg case 1', function(done1){ @@ -250,7 +250,7 @@ describe('Sync Reorgs', function(){ // * \ // * C2c(TX=C2.TX)* - describe('reorg, case 2c', function() { + describe.skip('reorg, case 2c', function() { it('trigger reorg case 2c', function(done1){ s.sync.storeTipBlock(case2c, function(err) { assert(!err, 'shouldnt return error' + err); @@ -291,7 +291,7 @@ describe('Sync Reorgs', function(){ previousblockhash: '666', }; - describe('reorg, case 3)', function() { + describe.skip('reorg, case 3)', function() { it('case 3). Should return an error', function(done1){ s.sync.storeTipBlock(case3, function(err) { assert(err, 'should return error' + err); @@ -322,7 +322,7 @@ describe('Sync Reorgs', function(){ previousblockhash: '111', }; - describe('p2p sync. no reorgs', function() { + describe.skip('p2p sync. no reorgs', function() { it('Should return an error', function(done1){ s.sync.storeTipBlock(p2p, false, function(err) { assert(!err, 'shouldnt return error' + err); diff --git a/test/integration/addr.js b/test/integration/addr.js index 70d80fd5..824c09d3 100644 --- a/test/integration/addr.js +++ b/test/integration/addr.js @@ -14,7 +14,7 @@ var assert = require('assert'), var should = require('chai'); var txDb; -describe('Address balances', function() { +describe.skip('Address balances', function() { this.timeout(5000); before(function(c) { @@ -83,7 +83,7 @@ describe('Address balances', function() { }); //tested against https://api.biteasy.com/testnet/v1/addresses/2N1pLkosf6o8Ciqs573iwwgVpuFS6NbNKx5/unspent-outputs?per_page=40 -describe('Address unspent', function() { +describe.skip('Address unspent', function() { before(function(c) { txDb = TransactionDb; diff --git a/test/integration/addrCache.js b/test/integration/addrCache.js index 815e76e7..6e6b4f68 100644 --- a/test/integration/addrCache.js +++ b/test/integration/addrCache.js @@ -16,7 +16,7 @@ var should = require('chai'); var txDb; -describe('Address cache ', function() { +describe.skip('Address cache ', function() { this.timeout(5000); before(function(c) { diff --git a/test/integration/block.js b/test/integration/block.js index 0d6e5e4e..91192fc6 100644 --- a/test/integration/block.js +++ b/test/integration/block.js @@ -14,7 +14,7 @@ assert = require('assert'), var bDb; -describe('BlockDb fromHashWithInfo', function() { +describe.skip('BlockDb fromHashWithInfo', function() { before(function(c) { bDb = BlockDb; diff --git a/test/integration/blockExtractor.js b/test/integration/blockExtractor.js index 3f5f3609..c08c9384 100644 --- a/test/integration/blockExtractor.js +++ b/test/integration/blockExtractor.js @@ -14,7 +14,7 @@ var assert = require('assert'), var should = require('chai'); //var txItemsValid = JSON.parse(fs.readFileSync('test/model/txitems.json')); -describe('BlockExtractor', function(){ +describe.skip('BlockExtractor', function(){ var be = new BlockExtractor(config.bitcoind.dataDir, config.network); diff --git a/test/integration/blocklist.js b/test/integration/blocklist.js index 19b104af..4e1b3fc5 100644 --- a/test/integration/blocklist.js +++ b/test/integration/blocklist.js @@ -13,7 +13,7 @@ var assert = require('assert'), var bDb; -describe('BlockDb getBlocksByDate', function(){ +describe.skip('BlockDb getBlocksByDate', function(){ before(function(c) { diff --git a/test/integration/messages.js b/test/integration/messages.js index d51ccbaa..5cbd728c 100644 --- a/test/integration/messages.js +++ b/test/integration/messages.js @@ -31,7 +31,7 @@ function createMockReq(body) { }; } -describe('messages.verify', function() { +describe.skip('messages.verify', function() { it('should return true with correct message', function(done) { var mockReq = createMockReq({ diff --git a/test/integration/nodecheck.js b/test/integration/nodecheck.js index 2e2973cd..9da6d85f 100644 --- a/test/integration/nodecheck.js +++ b/test/integration/nodecheck.js @@ -6,7 +6,7 @@ var bDb = BlockDb; var expect = require('chai').expect; -describe('Node check', function() { +describe.skip('Node check', function() { it('should contain block ' + height_needed, function(done) { bDb.blockIndex(height_needed, function(err, b) { expect(err).to.equal(null); diff --git a/test/integration/status.js b/test/integration/status.js index d912fa02..46e8a03a 100644 --- a/test/integration/status.js +++ b/test/integration/status.js @@ -6,7 +6,7 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'development'; var assert = require('assert'), Status = require('../../app/models/Status'); -describe('Status', function(){ +describe.skip('Status', function(){ it('getInfo', function(done) { var d = new Status(); diff --git a/test/integration/txs.js b/test/integration/txs.js index 0fc18f9c..2f4ce234 100644 --- a/test/integration/txs.js +++ b/test/integration/txs.js @@ -16,7 +16,7 @@ var should = require('chai'); var sinon = require('sinon'); var txDb; -describe('Transactions for multiple addresses', function() { +describe.skip('Transactions for multiple addresses', function() { this.timeout(5000); var req, res; From ed6f67c43cf789a7a327086715cb477a61d85ee7 Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Thu, 12 Feb 2015 15:35:01 -0300 Subject: [PATCH 4/4] Use bitcore-build --- gulpfile.js | 93 ++--------------------------------------------------- 1 file changed, 3 insertions(+), 90 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 3e3be6ad..04f4f794 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,95 +1,8 @@ -/** - * @file gulpfile.js - * - * Defines tasks that can be run on gulp. - * - * Summary:
    - *
  • `test` - runs all the tests using mocha - *
      - *
    • `test:node` - *
    • `test:nofail` - internally used for watching (due to bug on gulp-mocha) - *
    ` - *
  • `watch:test` - watch for file changes and run tests - *
  • `lint` - run `jshint` - *
  • `coverage` - run `istanbul` with mocha to generate a report of test coverage - *
  • `coveralls` - updates coveralls info - *
- */ 'use strict'; var gulp = require('gulp'); +var bitcoreTasks = require('bitcore-build'); -var coveralls = require('gulp-coveralls'); -var jshint = require('gulp-jshint'); -var mocha = require('gulp-mocha'); -var shell = require('gulp-shell'); +bitcoreTasks('node', {skipBrowser: true}); - -function ignoreerror() { - /* jshint ignore:start */ // using `this` in this context is weird - this.emit('end'); - /* jshint ignore:end */ -} - -var files = ['lib/**/*.js']; -var tests = ['test/**/*.js']; -var alljs = files.concat(tests); - - -/** - * testing - */ - -var testmocha = function() { - return gulp.src(tests).pipe(new mocha({ - reporter: 'spec' - })); -} - -gulp.task('test', testmocha); - -gulp.task('test:nofail', function() { - return testmocha().on('error', ignoreerror); -}); - - -/** - * code quality and documentation - */ - -gulp.task('lint', function() { - return gulp.src(alljs) - .pipe(jshint()) - .pipe(jshint.reporter('default')); -}); - -gulp.task('plato', shell.task(['node_modules/.bin/plato -d report -r -l .jshintrc -t bitcore-node lib'])); - -gulp.task('coverage', shell.task(['node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- --recursive'])); - -gulp.task('coveralls', ['coverage'], function() { - gulp.src('coverage/lcov.info').pipe(coveralls()); -}); - - -/** - * watch tasks - */ - -gulp.task('watch:test', function() { - // todo: only run tests that are linked to file changes by doing - // something smart like reading through the require statements - return gulp.watch(alljs, ['test']); -}); - -gulp.task('watch:coverage', function() { - // todo: only run tests that are linked to file changes by doing - // something smart like reading through the require statements - return gulp.watch(alljs, ['coverage']); -}); - -gulp.task('watch:lint', function() { - // todo: only lint files that are linked to file changes by doing - // something smart like reading through the require statements - return gulp.watch(alljs, ['lint']); -}); +gulp.task('default', ['lint', 'coverage']);