diff --git a/Gruntfile.js b/Gruntfile.js index fd9887f4a1f..619a3591e1a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -68,6 +68,11 @@ module.exports = function (grunt) { }, coverageSingle: { + command: 'export NODE_ENV=TEST && node_modules/.bin/istanbul cover --dir test/.coverage-unit --include-pid ./node_modules/.bin/_mocha $TEST -- --grep @slow --invert', + maxBuffer: maxBufferSize + }, + + coverageSingleExtensive: { command: 'export NODE_ENV=TEST && node_modules/.bin/istanbul cover --dir test/.coverage-unit --include-pid ./node_modules/.bin/_mocha $TEST', maxBuffer: maxBufferSize }, @@ -77,8 +82,18 @@ module.exports = function (grunt) { maxBuffer: maxBufferSize }, - testFunctional: { - command: './node_modules/.bin/mocha test/api/index.js', + coverageUnitSlow: { + command: 'node_modules/.bin/istanbul cover --dir test/.coverage-unit ./node_modules/.bin/_mocha test/unit/index.slow.js', + maxBuffer: maxBufferSize + }, + + testFunctionalWs: { + command: './node_modules/.bin/_mocha test/functional/ws/index.js', + maxBuffer: maxBufferSize + }, + + testFunctionalHttp: { + command: './node_modules/.bin/_mocha test/functional/http/index.js', maxBuffer: maxBufferSize }, @@ -143,11 +158,14 @@ module.exports = function (grunt) { grunt.registerTask('default', ['release']); grunt.registerTask('release', ['exec:folder', 'obfuscator', 'exec:createBundles', 'exec:package', 'exec:build', 'compress']); grunt.registerTask('jenkins', ['exec:coverageSingle']); + grunt.registerTask('jenkins-extensive', ['exec:coverageSingleExtensive']); grunt.registerTask('coverageReport', ['exec:coverageReport']); grunt.registerTask('eslint-nofix', ['eslint']); grunt.registerTask('test', ['eslint', 'exec:coverage']); grunt.registerTask('test-unit', ['eslint', 'exec:coverageUnit']); - grunt.registerTask('test-functional', ['eslint', 'exec:testFunctional']); + grunt.registerTask('test-unit-slow', ['eslint', 'exec:coverageUnitSlow']); + grunt.registerTask('test-functional-ws', ['eslint', 'exec:testFunctionalWs']); + grunt.registerTask('test-functional-http', ['eslint', 'exec:testFunctionalHttp']); grunt.registerTask('test-integration', ['eslint', 'exec:testIntegration']); grunt.registerTask('eslint-fix', 'Run eslint and fix formatting', function () { diff --git a/Jenkinsfile b/Jenkinsfile index fa3681d24a3..5ed30dc1056 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,8 +11,8 @@ def initBuild() { def buildDependency() { try { - sh '''#!/bin/bash - # Install Deps + sh ''' + rsync -axl -e "ssh -oUser=jenkins" master-01:/var/lib/jenkins/lisk/node_modules/ "$WORKSPACE/node_modules/" npm install ''' } catch (err) { @@ -53,8 +53,26 @@ def report(){ } lock(resource: "Lisk-Core-Nodes", inversePrecedence: true) { + + properties([ + parameters([ + string(name: 'JENKINS_PROFILE', defaultValue: 'jenkins', description: 'To build cache dependencies and run slow test, change this value to jenkins-extensive.', ) + ]) + ]) + stage ('Prepare Workspace') { parallel( + "Build cached dependencies" : { + node('master-01'){ + sh '''#!/bin/bash -xe + if [ $JENKINS_PROFILE == "jenkins-extensive" ]; then + rm -Rf "$WORKSPACE/node_modules/" + npm install + rsync -axl --delete "$WORKSPACE/node_modules/" /var/lib/jenkins/lisk/node_modules/ + fi + ''' + } + }, "Build Node-01" : { node('node-01'){ initBuild() @@ -155,129 +173,129 @@ lock(resource: "Lisk-Core-Nodes", inversePrecedence: true) { "Functional Accounts" : { node('node-01'){ sh ''' - export TEST=test/api/accounts.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/http/get/accounts.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, "Functional Blocks" : { node('node-01'){ sh ''' - export TEST=test/api/blocks.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/http/get/blocks.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, - "Functional Delegates" : { + "Functional Dapps" : { node('node-01'){ sh ''' - export TEST=test/api/delegates.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/http/get/dapps.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, - "Functional Dapps" : { + "Functional Delegates" : { node('node-01'){ sh ''' - export TEST=test/api/dapps.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/http/get/delegates.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, "Functional Loader" : { node('node-01'){ sh ''' - export TEST=test/api/loader.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/http/get/loader.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, - "Functional Transport - Handshake" : { - node('node-02'){ + "Functional Multisignatures" : { + node('node-01'){ sh ''' - export TEST=test/api/transport/transport.handshake.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/http/get/multisignatures.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, - "Functional Multisignatures" : { + "Functional Multisignatures post" : { node('node-01'){ sh ''' - export TEST=test/api/multisignatures.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/http/get/multisignatures.post.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, - "Functional Multisignatures POST" : { + "Functional Transactions" : { node('node-01'){ sh ''' - export TEST=test/api/multisignatures.post.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/http/get/transactions.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, - "Functional Transactions" : { - node('node-01'){ + "Functional Peers" : { + node('node-02'){ sh ''' - export TEST=test/api/transactions.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/http/get/peers.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } - }, //End node-01 functional tests + }, // End node-01 functional tests "Functional Transport - Main" : { node('node-02'){ sh ''' - export TEST=test/api/transport/transport.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/ws/transport.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, "Functional Transport - Blocks" : { node('node-02'){ sh ''' - export TEST=test/api/transport/transport.blocks.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/ws/transport.blocks.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, "Functional Transport - Client" : { node('node-02'){ sh ''' - export TEST=test/api/transport/transport.client.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/ws/transport.client.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, - "Functional Transport - Transactions Main" : { + "Functional Transport - Handshake" : { node('node-02'){ sh ''' - export TEST=test/api/transport/transport.transactions.main.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/ws/transport.handshake.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } }, - "Functional Transport - Peers" : { + "Functional Transport - Transactions" : { node('node-02'){ sh ''' - export TEST=test/api/peers.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/ws/transport.transactions.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } - }, // End Node-02 functional tests + }, // End Node-02 Tests "Unit Tests" : { node('node-03'){ sh ''' @@ -286,16 +304,34 @@ lock(resource: "Lisk-Core-Nodes", inversePrecedence: true) { npm run test-unit ''' } - }, // End Node-03 unit tests + }, + "Unit Tests - sql blockRewards" : { + node('node-03'){ + sh ''' + export TEST=test/unit/sql/blockRewards.js TEST_TYPE='FUNC' NODE_ENV='TEST' + cd "$(echo $WORKSPACE | cut -f 1 -d '@')" + npm run $JENKINS_PROFILE + ''' + } + }, + "Unit Tests - logic blockReward" : { + node('node-03'){ + sh ''' + export TEST=test/unit/logic/blockReward.js TEST_TYPE='FUNC' NODE_ENV='TEST' + cd "$(echo $WORKSPACE | cut -f 1 -d '@')" + npm run $JENKINS_PROFILE + ''' + } + },// End Node-03 unit tests "Functional Stress - Transactions" : { node('node-04'){ sh ''' - export TEST=test/api/transport/transport.transactions.stress.js TEST_TYPE='FUNC' NODE_ENV='TEST' + export TEST=test/functional/ws/transport.transactions.stress.js TEST_TYPE='FUNC' NODE_ENV='TEST' cd "$(echo $WORKSPACE | cut -f 1 -d '@')" - npm run jenkins + npm run $JENKINS_PROFILE ''' } - } + } // End Node-04 ) // End Parallel } diff --git a/Jenkinsfile.extensive b/Jenkinsfile.extensive new file mode 100644 index 00000000000..fdde5f35e17 --- /dev/null +++ b/Jenkinsfile.extensive @@ -0,0 +1,5 @@ +node { + stage('Build extensive testsuite') { + build job: "lisk-core/${env.BRANCH_NAME}", parameters: [string(name: 'JENKINS_PROFILE', value: 'jenkins-extensive')] + } +} diff --git a/package.json b/package.json index d34911dfe8d..42d2996118b 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,16 @@ "scripts": { "start": "node app.js", "jenkins": "./node_modules/.bin/grunt jenkins --verbose", + "jenkins-extensive": "./node_modules/.bin/grunt jenkins-extensive --verbose", "eslint": "./node_modules/.bin/grunt eslint-nofix --verbose", "fetchCoverage": "./node_modules/.bin/grunt exec:fetchCoverage --verbose", "coverageReport": "./node_modules/.bin/grunt coverageReport --verbose", "test": "./node_modules/.bin/grunt test --verbose", "test-unit": "./node_modules/.bin/grunt test-unit --verbose", + "test-unit-slow": "./node_modules/.bin/grunt test-unit-slow --verbose", "test-integration": "grunt test-integration", - "test-functional": "grunt test-functional", + "test-functional-ws": "grunt test-functional-ws", + "test-functional-http": "grunt test-functional-http", "jsdoc": "jsdoc -c docs/conf.json --verbose --pedantic", "create-bundles": "webpack", "server-docs": "npm run jsdoc && http-server docs/jsdoc/", diff --git a/test/api/index.js b/test/api/index.js deleted file mode 100644 index 9cf7c9de56a..00000000000 --- a/test/api/index.js +++ /dev/null @@ -1,14 +0,0 @@ -require('./accounts'); -require('./blocks'); -require('./dapps'); -require('./delegates'); -require('./loader'); -require('./multisignatures'); -require('./multisignatures.post'); -require('./peers'); -require('./transactions'); -require('./transport/transport'); -require('./transport/transport.blocks'); -require('./transport/transport.client'); -require('./transport/transport.handshake'); -require('./transport/transport.transactions.stress'); diff --git a/test/common/complexTransactions.js b/test/common/complexTransactions.js index 776d7d999ac..3281ef552dc 100644 --- a/test/common/complexTransactions.js +++ b/test/common/complexTransactions.js @@ -1,32 +1,66 @@ 'use strict'; var lisk = require('lisk-js'); + +var node = require('../node'); var http = require('./httpCommunication'); +function httpCallbackHelper (cb, err, res) { + if (err) { + return cb(err); + } + cb(null, res.body); +} + +function getTransaction (transaction, cb) { + http.get('/api/transactions/get?id=' + transaction, httpCallbackHelper.bind(null, cb)); +} + +function getUnconfirmedTransaction (transaction, cb) { + http.get('/api/transactions/unconfirmed/get?id=' + transaction, httpCallbackHelper.bind(null, cb)); +} + +function getPendingMultisignature (transaction, cb) { + http.get('/api/multisignatures/pending?publicKey=' + transaction.senderPublicKey, httpCallbackHelper.bind(null, cb)); +} + function sendTransaction (transaction, cb) { - http.post('/api/transactions', { transaction: transaction }, function (err, res) { - if (res.body.success) { - return cb(null, res.body); - } - return cb(res.body); - }); + http.post('/api/transactions', {transaction: transaction}, httpCallbackHelper.bind(null, cb)); } function sendSignature (signature, transaction, cb) { - http.post('/api/signatures', { signature: signature, transaction: transaction.id }, function (err, res) { - if (res.body.success) { - return cb(null, res.body); - } - return cb(res.body); - }); + http.post('/api/signatures', {signature: {signature: signature, transaction: transaction.id}}, httpCallbackHelper.bind(null, cb)); } function sendLISK (params, cb) { - sendTransaction(lisk.transaction.createTransaction(params.address, params.amount, params.secret, params.secondSecret), cb); + var transaction = lisk.transaction.createTransaction(params.address, params.amount, params.secret, params.secondSecret); + sendTransaction(transaction, cb); } +function creditAccount (address, amount, cb) { + var transaction = lisk.transaction.createTransaction(address, amount, node.gAccount.password); + sendTransaction(transaction, cb); +} + +var getTransactionPromise = node.Promise.promisify(getTransaction); +var sendTransactionPromise = node.Promise.promisify(sendTransaction); +var getUnconfirmedTransactionPromise = node.Promise.promisify(getUnconfirmedTransaction); +var getPendingMultisignaturePromise = node.Promise.promisify(getPendingMultisignature); +var creditAccountPromise = node.Promise.promisify(creditAccount); +var sendSignaturePromise = node.Promise.promisify(sendSignature); + module.exports = { + getTransaction: getTransaction, + getTransactionPromise: getTransactionPromise, + getUnconfirmedTransaction: getUnconfirmedTransaction, + getUnconfirmedTransactionPromise: getUnconfirmedTransactionPromise, + getPendingMultisignature: getPendingMultisignature, + getPendingMultisignaturePromise: getPendingMultisignaturePromise, sendSignature: sendSignature, + sendSignaturePromise: sendSignaturePromise, sendTransaction: sendTransaction, - sendLISK: sendLISK + sendTransactionPromise: sendTransactionPromise, + sendLISK: sendLISK, + creditAccount: creditAccount, + creditAccountPromise: creditAccountPromise }; diff --git a/test/api/accounts.js b/test/functional/http/get/accounts.js similarity index 99% rename from test/api/accounts.js rename to test/functional/http/get/accounts.js index d7adf76b7d5..15c2b335382 100644 --- a/test/api/accounts.js +++ b/test/functional/http/get/accounts.js @@ -1,7 +1,7 @@ 'use strict'; -var node = require('../node.js'); -var http = require('../common/httpCommunication.js'); +var node = require('../../../node.js'); +var http = require('../../../common/httpCommunication.js'); var account = node.randomAccount(); diff --git a/test/api/blocks.js b/test/functional/http/get/blocks.js similarity index 98% rename from test/api/blocks.js rename to test/functional/http/get/blocks.js index b4ac007b56b..dddfc8b91d9 100644 --- a/test/api/blocks.js +++ b/test/functional/http/get/blocks.js @@ -1,8 +1,8 @@ 'use strict'; -var node = require('../node.js'); -var http = require('../common/httpCommunication.js'); -var modulesLoader = require('../common/initModule').modulesLoader; +var node = require('../../../node.js'); +var http = require('../../../common/httpCommunication.js'); +var modulesLoader = require('../../../common/initModule').modulesLoader; var block = { blockHeight: 0, diff --git a/test/api/dapps.js b/test/functional/http/get/dapps.js similarity index 97% rename from test/api/dapps.js rename to test/functional/http/get/dapps.js index f0aafc23da0..32a58a49363 100644 --- a/test/api/dapps.js +++ b/test/functional/http/get/dapps.js @@ -1,10 +1,10 @@ 'use strict'; -var node = require('./../node.js'); -var http = require('../common/httpCommunication.js'); -var ws = require('../common/wsCommunication.js'); -var clearDatabaseTable = require('../common/globalBefore').clearDatabaseTable; -var modulesLoader = require('../common/initModule').modulesLoader; +var node = require('../../../node.js'); +var http = require('../../../common/httpCommunication.js'); +var ws = require('../../../common/wsCommunication.js'); +var clearDatabaseTable = require('../../../common/globalBefore').clearDatabaseTable; +var modulesLoader = require('../../../common/initModule').modulesLoader; function postTransaction (transaction, done) { ws.call('postTransactions', { transaction: transaction }, done, true); diff --git a/test/api/delegates.js b/test/functional/http/get/delegates.js similarity index 98% rename from test/api/delegates.js rename to test/functional/http/get/delegates.js index c27491792c9..f9ee8ca6eb4 100644 --- a/test/api/delegates.js +++ b/test/functional/http/get/delegates.js @@ -1,12 +1,11 @@ 'use strict'; -var node = require('../node.js'); -var http = require('../common/httpCommunication.js'); -var sendLISK = require('../common/complexTransactions.js').sendLISK; -var sendTransaction = require('../common/complexTransactions.js').sendTransaction; -var modulesLoader = require('./../common/initModule.js').modulesLoader; -var genesisDelegates = require('../genesisDelegates.json'); - +var node = require('../../../node.js'); +var http = require('../../../common/httpCommunication.js'); +var sendLISK = require('../../../common/complexTransactions.js').sendLISK; +var sendTransaction = require('../../../common/complexTransactions.js').sendTransaction; +var modulesLoader = require('../../../common/initModule.js').modulesLoader; +var genesisDelegates = require('../../../genesisDelegates.json'); var testDelegate = genesisDelegates.delegates[0]; function getForgingStatus (publicKey, cb) { @@ -23,7 +22,8 @@ before(function (done) { amount: node.randomLISK(), address: delegate.address }, function (err, res) { - node.expect(err).to.be.null; + node.expect(res).to.have.property('success').to.be.ok; + node.expect(res).to.have.property('transactionId').that.is.not.empty; node.onNewBlock(function () { var insertDelegateTrs = node.lisk.delegate.createDelegate(delegate.password, delegate.username); sendTransaction(insertDelegateTrs, function (err, res) { @@ -34,16 +34,11 @@ before(function (done) { }); }); - describe('GET /api/delegates (cache)', function () { var cache; before(function (done) { node.config.cacheEnabled = true; - done(); - }); - - before(function (done) { modulesLoader.initCache(function (err, __cache) { cache = __cache; node.expect(err).to.not.exist; @@ -52,10 +47,6 @@ describe('GET /api/delegates (cache)', function () { }); }); - after(function (done) { - cache.quit(done); - }); - afterEach(function (done) { cache.flushDb(function (err, status) { node.expect(err).to.not.exist; @@ -64,6 +55,10 @@ describe('GET /api/delegates (cache)', function () { }); }); + after(function (done) { + cache.quit(done); + }); + it('cache delegates when response is a success', function (done) { var url; url = '/api/delegates'; @@ -97,7 +92,7 @@ describe('GET /api/delegates (cache)', function () { }); }); - it('should flush cache on the next round', function (done) { + it('should flush cache on the next round @slow', function (done) { var url; url = '/api/delegates'; diff --git a/test/api/loader.js b/test/functional/http/get/loader.js similarity index 90% rename from test/api/loader.js rename to test/functional/http/get/loader.js index d4718e1fbd0..e5400bc1d91 100644 --- a/test/api/loader.js +++ b/test/functional/http/get/loader.js @@ -1,7 +1,7 @@ 'use strict'; -var node = require('../node.js'); -var http = require('../common/httpCommunication.js'); +var node = require('../../../node.js'); +var http = require('../../../common/httpCommunication.js'); describe('GET /api/loader/status/ping', function () { diff --git a/test/api/multisignatures.js b/test/functional/http/get/multisignatures.js similarity index 89% rename from test/api/multisignatures.js rename to test/functional/http/get/multisignatures.js index 0b2ae949bcd..3cbd319c186 100644 --- a/test/api/multisignatures.js +++ b/test/functional/http/get/multisignatures.js @@ -1,11 +1,11 @@ 'use strict'; var async = require('async'); -var node = require('../node.js'); -var http = require('../common/httpCommunication.js'); -var sendLISK = require('../common/complexTransactions.js').sendLISK; -var sendTransaction = require('../common/complexTransactions.js').sendTransaction; -var sendSignature = require('../common/complexTransactions.js').sendSignature; +var node = require('../../../node.js'); +var http = require('../../../common/httpCommunication.js'); +var sendLISK = require('../../../common/complexTransactions.js').sendLISK; +var sendTransaction = require('../../../common/complexTransactions.js').sendTransaction; +var sendSignature = require('../../../common/complexTransactions.js').sendSignature; var multisigAccount = node.randomAccount(); var multisigTransaction; @@ -24,7 +24,8 @@ before(function (done) { amount: node.randomLISK(), address: multisigAccount.address }, function (err, res) { - node.expect(err).to.be.null; + node.expect(res).to.have.property('success').to.be.ok; + node.expect(res).to.have.property('transactionId').that.is.not.empty; node.onNewBlock(function () { keysGroup = accounts.map(function (account) {
 return '+' + account.publicKey;
 @@ -118,7 +119,8 @@ describe('POST signatures/sign (regular account)', function () { node.expect(res.body.transaction).to.have.property('id').to.equal(transaction.id); var signature = node.lisk.multisignature.signTransaction(transaction, multisigAccount.password); sendSignature(signature, transaction, function (err, res) { - node.expect(err).not.to.be.empty; + node.expect(res).to.have.property('success').to.not.be.ok; + node.expect(res).to.have.property('message').to.equal('Error processing signature: Transaction not found'); done(); }); }); diff --git a/test/api/multisignatures.post.js b/test/functional/http/get/multisignatures.post.js similarity index 88% rename from test/api/multisignatures.post.js rename to test/functional/http/get/multisignatures.post.js index b56edcc9cba..06d51b4f528 100644 --- a/test/api/multisignatures.post.js +++ b/test/functional/http/get/multisignatures.post.js @@ -2,10 +2,10 @@ var async = require('async'); -var constants = require('../../helpers/constants'); -var node = require('./../node.js'); -var sendLISK = require('../common/complexTransactions.js').sendLISK; -var sendTransaction = require('../common/complexTransactions.js').sendTransaction; +var constants = require('../../../../helpers/constants'); +var node = require('../../../node.js'); +var sendLISK = require('../../../common/complexTransactions.js').sendLISK; +var sendTransaction = require('../../../common/complexTransactions.js').sendTransaction; var multisigAccount = node.randomAccount(); var memberAccount1 = node.randomAccount(); @@ -28,7 +28,7 @@ describe('POST /api/multisignatures', function () { it('using null member in keysgroup should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + node.eAccount.publicKey, null], 1, 2); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.equal('Invalid member in keysgroup'); done(); @@ -38,7 +38,7 @@ describe('POST /api/multisignatures', function () { it('using invalid member in keysgroup should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + node.eAccount.publicKey + 'A', '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], 1, 2); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.equal('Invalid public key in multisignature keysgroup'); done(); @@ -48,7 +48,7 @@ describe('POST /api/multisignatures', function () { it('using empty keysgroup should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, [], 1, 2); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Array is too short \(0\), minimum 1$/); done(); @@ -60,7 +60,7 @@ describe('POST /api/multisignatures', function () { delete multiSigTx.asset.multisignature.keysgroup; - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Missing required property: keysgroup$/); done(); @@ -70,7 +70,7 @@ describe('POST /api/multisignatures', function () { it('using sender in the keysgroup should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + multisigAccount.publicKey, '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], 1, 2); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.equal('Invalid multisignature keysgroup. Can not contain sender'); done(); @@ -80,7 +80,7 @@ describe('POST /api/multisignatures', function () { it('using no math operator in keysgroup should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, [node.eAccount.publicKey], 1, 1); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.equal('Invalid math operator in multisignature keysgroup'); done(); @@ -90,7 +90,7 @@ describe('POST /api/multisignatures', function () { it('using invalid math operator in keysgroup should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['-' + node.eAccount.publicKey], 1, 1); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.equal('Invalid math operator in multisignature keysgroup'); done(); @@ -100,7 +100,7 @@ describe('POST /api/multisignatures', function () { it('using same member twice should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + memberAccount1.publicKey, '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], 1, 2); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.equal('Encountered duplicate public key in multisignature keysgroup'); done(); @@ -114,7 +114,7 @@ describe('POST /api/multisignatures', function () { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, keysgroup, 1, 2); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Array is too long \(16\), maximum 15$/); done(); @@ -126,7 +126,7 @@ describe('POST /api/multisignatures', function () { multiSigTx.asset.multisignature.keysgroup = 'invalid'; - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Expected type array but found type string$/); done(); @@ -138,7 +138,7 @@ describe('POST /api/multisignatures', function () { delete multiSigTx.asset.multisignature.lifetime; - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Missing required property: lifetime$/); done(); @@ -150,7 +150,7 @@ describe('POST /api/multisignatures', function () { multiSigTx.asset.multisignature.lifetime = 'inv4lid'; - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Expected type integer but found type string$/); done(); @@ -160,7 +160,7 @@ describe('POST /api/multisignatures', function () { it('using lifetime greater than maximum allowed should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + node.eAccount.publicKey, '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], constants.multisigConstraints.lifetime.maximum + 1, 2); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Value 73 is greater than maximum 72$/); done(); @@ -170,7 +170,7 @@ describe('POST /api/multisignatures', function () { it('using lifetime == 0 should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + node.eAccount.publicKey, '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], 0, 2); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Value 0 is less than minimum 1$/); done(); @@ -180,7 +180,7 @@ describe('POST /api/multisignatures', function () { it('using negative lifetime should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + node.eAccount.publicKey, '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], -1, 2); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Value -1 is less than minimum 1$/); done(); @@ -192,7 +192,7 @@ describe('POST /api/multisignatures', function () { delete multiSigTx.asset.multisignature.min; - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Missing required property: min$/); done(); @@ -204,7 +204,7 @@ describe('POST /api/multisignatures', function () { multiSigTx.asset.multisignature.min = 'inv4lid'; - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Expected type integer but found type string$/); done(); @@ -214,7 +214,7 @@ describe('POST /api/multisignatures', function () { it('using min greater than keysgroup size plus 1 should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + node.eAccount.publicKey, '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], 1, 5); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.equal('Invalid multisignature min. Must be less than or equal to keysgroup size'); done(); @@ -224,7 +224,7 @@ describe('POST /api/multisignatures', function () { it('using min greater than maximum acceptable should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + node.eAccount.publicKey, '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], 1, 16); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Value 16 is greater than maximum 15$/); done(); @@ -234,7 +234,7 @@ describe('POST /api/multisignatures', function () { it('using min less than minimum acceptable should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + node.eAccount.publicKey, '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], 1, 0); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Value 0 is less than minimum 1$/); done(); @@ -244,7 +244,7 @@ describe('POST /api/multisignatures', function () { it('using negative min should fail', function (done) { var multiSigTx = node.lisk.multisignature.createMultisignature(multisigAccount.password, null, ['+' + node.eAccount.publicKey, '+' + memberAccount1.publicKey, '+' + memberAccount2.publicKey], 1, -1); - sendTransaction(multiSigTx, function (res) { + sendTransaction(multiSigTx, function (err, res) { node.expect(res).to.have.property('success').to.be.not.ok; node.expect(res).to.have.property('message').to.match(/Value -1 is less than minimum 1$/); done(); diff --git a/test/api/peers.js b/test/functional/http/get/peers.js similarity index 98% rename from test/api/peers.js rename to test/functional/http/get/peers.js index 40bf4f167d6..590e4ed7523 100644 --- a/test/api/peers.js +++ b/test/functional/http/get/peers.js @@ -3,12 +3,12 @@ var _ = require('lodash'); var scClient = require('socketcluster-client'); -var node = require('../node.js'); -var http = require('../common/httpCommunication.js'); -var Peer = require('../../logic/peer.js'); -var peersSortFields = require('../../sql/peers').sortFields; -var wsServer = require('../common/wsServer'); -var testConfig = require('../config.json'); +var node = require('../../../node.js'); +var http = require('../../../common/httpCommunication.js'); +var Peer = require('../../../../logic/peer.js'); +var peersSortFields = require('../../../../sql/peers').sortFields; +var wsServer = require('../../../common/wsServer'); +var testConfig = require('../../../config.json'); var validHeaders; var wsServerPort = 9998; diff --git a/test/api/transactions.js b/test/functional/http/get/transactions.js similarity index 97% rename from test/api/transactions.js rename to test/functional/http/get/transactions.js index a227967132a..c66abf41e25 100644 --- a/test/api/transactions.js +++ b/test/functional/http/get/transactions.js @@ -1,13 +1,13 @@ 'use strict'; -var node = require('../node.js'); -var http = require('../common/httpCommunication.js'); -var ws = require('../common/wsCommunication'); -var sendLiskTrs = require('../common/complexTransactions.js').sendLISK; -var transactionSortFields = require('../../sql/transactions').sortFields; -var modulesLoader = require('../common/initModule').modulesLoader; -var transactionTypes = require('../../helpers/transactionTypes.js'); -var genesisblock = require('../genesisBlock.json'); +var node = require('../../../node.js'); +var http = require('../../../common/httpCommunication.js'); +var ws = require('../../../common/wsCommunication'); +var sendLiskTrs = require('../../../common/complexTransactions.js').sendLISK; +var transactionSortFields = require('../../../../sql/transactions').sortFields; +var modulesLoader = require('../../../common/initModule').modulesLoader; +var transactionTypes = require('../../../../helpers/transactionTypes.js'); +var genesisblock = require('../../../genesisBlock.json'); var account = node.randomTxAccount(); var account2 = node.randomTxAccount(); diff --git a/test/functional/http/index.js b/test/functional/http/index.js new file mode 100644 index 00000000000..1d07948534e --- /dev/null +++ b/test/functional/http/index.js @@ -0,0 +1,14 @@ +require('./get/accounts'); +require('./get/blocks'); +require('./get/dapps'); +require('./get/delegates'); +require('./get/loader'); +require('./get/multisignatures'); +require('./get/peers'); +require('./get/transactions'); +require('./post/0.transfer'); +require('./post/1.second.secret'); +require('./post/2.delegate'); +require('./post/3.votes'); +require('./post/4.multisignatures'); +require('./post/5.dapps'); diff --git a/test/functional/ws/index.js b/test/functional/ws/index.js new file mode 100644 index 00000000000..de4428b938f --- /dev/null +++ b/test/functional/ws/index.js @@ -0,0 +1,5 @@ +require('./transport'); +require('./transport.blocks'); +require('./transport.client'); +require('./transport.handshake'); +require('./transport.transactions'); diff --git a/test/api/transport/transport.blocks.js b/test/functional/ws/transport.blocks.js similarity index 100% rename from test/api/transport/transport.blocks.js rename to test/functional/ws/transport.blocks.js diff --git a/test/api/transport/transport.client.js b/test/functional/ws/transport.client.js similarity index 100% rename from test/api/transport/transport.client.js rename to test/functional/ws/transport.client.js diff --git a/test/api/transport/transport.handshake.js b/test/functional/ws/transport.handshake.js similarity index 100% rename from test/api/transport/transport.handshake.js rename to test/functional/ws/transport.handshake.js diff --git a/test/api/transport/transport.js b/test/functional/ws/transport.js similarity index 100% rename from test/api/transport/transport.js rename to test/functional/ws/transport.js diff --git a/test/api/transport/transport.transactions.main.js b/test/functional/ws/transport.transactions.js similarity index 100% rename from test/api/transport/transport.transactions.main.js rename to test/functional/ws/transport.transactions.js diff --git a/test/api/transport/transport.transactions.stress.js b/test/functional/ws/transport.transactions.stress.js similarity index 98% rename from test/api/transport/transport.transactions.stress.js rename to test/functional/ws/transport.transactions.stress.js index 60dd6408ef3..ac79515185b 100644 --- a/test/api/transport/transport.transactions.stress.js +++ b/test/functional/ws/transport.transactions.stress.js @@ -16,7 +16,7 @@ function postTransactions (transactions, done) { }, done, true); } -describe('postTransactions', function () { +describe('postTransactions @slow', function () { describe('sending 1000 bundled transfers to random addresses', function () { diff --git a/test/index.js b/test/index.js index f461880c39e..923167db278 100644 --- a/test/index.js +++ b/test/index.js @@ -1,2 +1,3 @@ -require('./api'); +require('./functional'); require('./unit'); +require('./integration'); diff --git a/test/integration/index.js b/test/integration/index.js new file mode 100644 index 00000000000..c759a7ffb8e --- /dev/null +++ b/test/integration/index.js @@ -0,0 +1 @@ +require('./peers.integration'); diff --git a/test/integration/peers.integration.js b/test/integration/peers.integration.js index 58ca855ed5f..c5f01b1429e 100644 --- a/test/integration/peers.integration.js +++ b/test/integration/peers.integration.js @@ -31,9 +31,10 @@ var SYNC_MODE_DEFAULT_ARGS = { } }; -var WAIT_BEFORE_CONNECT_MS = 25000; +var WAIT_BEFORE_CONNECT_MS = 40000; -var testNodeConfigs = generateNodesConfig(10, SYNC_MODE.ALL_TO_FIRST, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); +SYNC_MODE_DEFAULT_ARGS.ALL_TO_GROUP.INDICES = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +var testNodeConfigs = generateNodesConfig(10, SYNC_MODE.ALL_TO_GROUP, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); var monitorWSClient = { protocol: 'http', @@ -81,7 +82,17 @@ function generateNodePeers (numOfPeers, syncMode, syncModeArgs) { break; case SYNC_MODE.ALL_TO_GROUP: - throw new Error('To implement'); + if (!Array.isArray(syncModeArgs.ALL_TO_GROUP.INDICES)) { + throw new Error('Provide peers indices to sync with as an array'); + } + Array.apply(null, new Array(numOfPeers)).forEach(function (val, index) { + if (syncModeArgs.ALL_TO_GROUP.INDICES.indexOf(index) !== -1) { + peersList.push({ + ip: '127.0.0.1', + port: 5000 + index + }); + } + }); } return peersList; } @@ -175,7 +186,7 @@ function killTestNodes (cb) { } function runFunctionalTests (cb) { - var child = child_process.spawn('node_modules/.bin/_mocha', ['--timeout', (8 * 60 * 1000).toString(), 'test/api/blocks.js', 'test/api/transactions.js'], { + var child = child_process.spawn('node_modules/.bin/_mocha', ['--timeout', (8 * 60 * 1000).toString(), 'test/functional/http/get/blocks.js', 'test/functional/http/get/transactions.js'], { cwd: __dirname + '/../..' }); diff --git a/test/node.js b/test/node.js index a7c2159ef1e..478b0b4f175 100644 --- a/test/node.js +++ b/test/node.js @@ -27,6 +27,7 @@ node.chai.config.includeStack = true; node.chai.use(require('chai-bignumber')(node.bignum)); node.lisk = require('lisk-js'); node.supertest = require('supertest'); +node.Promise = require('bluebird'); var randomString = require('randomstring'); var jobsQueue = require('../helpers/jobsQueue.js'); @@ -105,19 +106,6 @@ if (process.env.SILENT === 'true') { // Random LSK amount node.LISK = Math.floor(Math.random() * (100000 * 100000000)) + 1; -// Returns a random delegate name -node.randomDelegateName = function () { - var size = node.randomNumber(1, 20); // Min. delegate name size is 1, Max. delegate name is 20 - var delegateName = ''; - var possible = 'abcdefghijklmnopqrstuvwxyz0123456789!@$&_.'; - - for (var i = 0; i < size; i++) { - delegateName += possible.charAt(Math.floor(Math.random() * possible.length)); - } - - return delegateName; -}; - // Returns a random property from the given object node.randomProperty = function (obj, needKey) { var keys = Object.keys(obj); @@ -276,43 +264,77 @@ node.expectedFeeForTrsWithData = function (amount) { return parseInt(node.fees.transactionFee) + parseInt(node.fees.dataFee); }; -// Returns a random username +// Returns a random username of 16 characters node.randomUsername = function () { - var size = node.randomNumber(1, 16); // Min. username size is 1, Max. username size is 16 - var username = ''; - var possible = 'abcdefghijklmnopqrstuvwxyz0123456789!@$&_.'; + var randomLetter = randomString.generate({ + length: 1, + charset: 'alphabetic', + capitalization: 'lowercase' + }); + var custom = 'abcdefghijklmnopqrstuvwxyz0123456789!@$&_.'; + var username = randomString.generate({ + length: node.randomNumber(1, 15), + charset: custom + }); - for (var i = 0; i < size; i++) { - username += possible.charAt(Math.floor(Math.random() * possible.length)); - } + return randomLetter.concat(username); +}; + +// Returns a random delegate name of 20 characters +node.randomDelegateName = function () { + var randomLetter = randomString.generate({ + length: 1, + charset: 'alphabetic', + capitalization: 'lowercase' + }); + var custom = 'abcdefghijklmnopqrstuvwxyz0123456789!@$&_.'; + var username = randomString.generate({ + length: node.randomNumber(1, 19), + charset: custom + }); - return username; + return randomLetter.concat(username); }; -// Returns a random capitialized username +// Returns a random capitialized username of 16 characters node.randomCapitalUsername = function () { - var size = node.randomNumber(1, 16); // Min. username size is 1, Max. username size is 16 - var username = 'A'; - var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@$&_.'; - - for (var i = 0; i < size - 1; i++) { - username += possible.charAt(Math.floor(Math.random() * possible.length)); - } + var randomLetter = randomString.generate({ + length: 1, + charset: 'alphabetic', + capitalization: 'uppercase' + }); + var custom = 'abcdefghijklmnopqrstuvwxyz0123456789!@$&_.'; + var username = randomString.generate({ + length: node.randomNumber(1, 15), + charset: custom + }); - return username; + return randomLetter.concat(username); }; -// Returns a random application name +// Returns a random application name of 32 characteres node.randomApplicationName = function () { - var size = node.randomNumber(1, 32); // Min. username size is 1, Max. username size is 32 - var name = 'A'; - var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + var custom = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - for (var i = 0; i < size - 1; i++) { - name += possible.charAt(Math.floor(Math.random() * possible.length)); - } + return randomString.generate({ + length: node.randomNumber(1, 32), + charset: custom + }); +}; + +// Test random application +node.randomApplication = function () { + var application = { + category: node.randomNumber(0, 9), + name: node.randomApplicationName(), + description: 'Blockchain based home monitoring tool', + tags: 'monitoring temperature power sidechain', + type: node.randomNumber(0, 2), + link: 'https://' + node.randomApplicationName() + '.zip', + icon: 'https://raw.githubusercontent.com/MaxKK/blockDataDapp/master/icon.png' + }; - return name; + return application; }; // Returns a basic random account @@ -341,6 +363,13 @@ node.randomTxAccount = function () { }); }; +// Returns an random basic transaction to send 1 LSK from genesis account to a random account +node.randomTx = function (offset) { + var randomAccount = node.randomAccount(); + + return node.lisk.transaction.createTransaction(randomAccount.address, 1, node.gAccount.password, offset); +}; + // Returns a random password node.randomPassword = function () { return Math.random().toString(36).substring(7); @@ -354,7 +383,7 @@ node.initApplication = function (cb, initScope) { var modules = [], rewiredModules = {}; // Init dummy connection with database - valid, used for tests here var options = { - promiseLib: Promise + promiseLib: Promise }; var db = initScope.db; if (!db) { diff --git a/test/unit/index.js b/test/unit/index.js index f3735151537..e31733ff48c 100644 --- a/test/unit/index.js +++ b/test/unit/index.js @@ -6,6 +6,7 @@ require('./api/ws/workers/slaveToMasterSender'); require('./helpers/ed'); require('./helpers/jobs-queue'); require('./helpers/peersManager'); +require('./helpers/pg-notify'); require('./helpers/request-limiter'); require('./helpers/RPC'); require('./helpers/slots'); @@ -37,8 +38,3 @@ require('./sql/delegatesList'); require('./sql/rounds'); require('./schema/delegates'); - -// with long timeouts -require('./helpers/pg-notify'); -require('./logic/blockReward'); -require('./sql/blockRewards'); diff --git a/test/unit/index.slow.js b/test/unit/index.slow.js new file mode 100644 index 00000000000..59e6f211590 --- /dev/null +++ b/test/unit/index.slow.js @@ -0,0 +1,3 @@ +require('./logic/blockReward'); + +require('./sql/blockRewards'); diff --git a/test/unit/modules/cache.js b/test/unit/modules/cache.js index b22ae49c1bd..ebce2faaf49 100644 --- a/test/unit/modules/cache.js +++ b/test/unit/modules/cache.js @@ -1,6 +1,6 @@ 'use strict'; -var node = require('./../../node.js'); +var node = require('./../../node.js'); var chai = require('chai'); var expect = require('chai').expect; var async = require('async'); @@ -14,10 +14,6 @@ describe('cache', function () { before(function (done) { node.config.cacheEnabled = true; - done(); - }); - - before(function (done) { modulesLoader.initCache(function (err, __cache) { cache = __cache; expect(err).to.not.exist; @@ -27,10 +23,6 @@ describe('cache', function () { }); }); - after(function (done) { - cache.quit(done); - }); - afterEach(function (done) { cache.flushDb(function (err, status) { expect(err).to.not.exist; @@ -39,6 +31,10 @@ describe('cache', function () { }); }); + after(function (done) { + cache.quit(done); + }); + describe('setJsonForKey', function () { it('should set the key value correctly', function (done) { @@ -173,7 +169,7 @@ describe('cache', function () { }); }); - + describe('onNewBlock', function () { it('should remove all keys matching pattern /api/transactions', function (done) { @@ -312,7 +308,6 @@ describe('cache', function () { }); }); }); - }); describe('onTransactionsSaved', function (done) {