From 62d48edc32e5068d6e32df77759844426a350efa Mon Sep 17 00:00:00 2001 From: Andrea Baccega Date: Wed, 9 Aug 2017 10:08:30 +0200 Subject: [PATCH 01/11] Fix transaction pool bug in "transactionInPool" plus tests. --- logic/transactionPool.js | 4 +- test/unit/index.js | 1 + test/unit/logic/transactionPool.js | 138 +++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 test/unit/logic/transactionPool.js diff --git a/logic/transactionPool.js b/logic/transactionPool.js index 58931bece23..05f27abd85f 100644 --- a/logic/transactionPool.js +++ b/logic/transactionPool.js @@ -101,7 +101,9 @@ TransactionPool.prototype.transactionInPool = function (id) { self.bundled.index[id], self.queued.index[id], self.multisignature.index[id] - ].filter(Boolean).length > 0; + ].filter(function (index) { + return typeof(index) === 'number'; + }).length > 0; }; /** diff --git a/test/unit/index.js b/test/unit/index.js index 30bcf961d05..0bfb485d058 100644 --- a/test/unit/index.js +++ b/test/unit/index.js @@ -7,6 +7,7 @@ require('./logic/blockReward.js'); require('./logic/peer'); require('./logic/peers'); require('./logic/transaction'); +require('./logic/transactionPool'); require('./logic/transfer'); require('./logic/vote'); diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js new file mode 100644 index 00000000000..26e7a04926d --- /dev/null +++ b/test/unit/logic/transactionPool.js @@ -0,0 +1,138 @@ +var TransactionPool = require('../../../logic/transactionPool.js'); +var TransactionLogic = require('../../../logic/transaction.js'); +var DelegateModule = require('../../../modules/delegates.js'); + +var TransferLogic = require('../../../logic/transfer.js'); + +var transactionTypes = require('../../../helpers/transactionTypes'); +var AccountModule = require('../../../modules/accounts.js'); +var BlocksModule = require('../../../modules/blocks.js'); +var AccountLogic = require('../../../logic/account.js'); +var Rounds = require('../../../modules/rounds.js'); +var modulesLoader = require('../../common/initModule').modulesLoader; +var async = require('async'); +var expect = require('chai').expect; +var node = require('../../node'); +var ws = require('../../common/wsCommunication'); + +function postTransaction(transaction, done) { + ws.call('postTransactions', { + transaction: transaction + }, done, true); +} + +describe('transactionPool', function () { + let txPool; + + before(function (done) { + // Init transaction logic + async.auto({ + rounds : function (cb) { + modulesLoader.initModule(Rounds, modulesLoader.scope, cb); + }, + accountLogic : function (cb) { + modulesLoader.initLogicWithDb(AccountLogic, cb); + }, + blockModule : ['accountLogic', function (result, cb) { + modulesLoader.initModuleWithDb(BlocksModule, cb, { + logic: { /* dependencies not included */ }, + }); + }], + transactionLogic: ['accountLogic', function (result, cb) { + modulesLoader.initLogicWithDb(TransactionLogic, cb, { + account: result.accountLogic + }); + }], + delegateModule : ['transactionLogic', function (result, cb) { + modulesLoader.initModuleWithDb(DelegateModule, cb, { + logic: { + transaction: result.transactionLogic + } + }); + }], + // transactionModule: ['transactionLogic', function (result, cb) { + // modulesLoader.initModuleWithDb(TransactionModule, cb, { + // transaction: result.transactionLogic + // }); + // }] + }, function (err, result) { + modulesLoader.initModuleWithDb(AccountModule, function (err, __accountModule) { + expect(err).to.not.exist; + + var account = __accountModule; + accountLogic = result.accountLogic; + + // for correctly initializing setting blocks module + result.blockModule.lastBlock.set({ height: 10 }); + + result.delegateModule.onBind({ + accounts: __accountModule, + // transactions: result.transactionModule, + blocks : result.blockModule + }); + var sendLogic = result.transactionLogic.attachAssetType(transactionTypes.SEND, new TransferLogic()); + sendLogic.bind(account, /* rounds */ null); + // + // result.transactionModule.onBind({ + // accounts: __accountModule, + // // transactions: result.transactionModule, + // //loader: + // }); + + account.onBind({ + delegates: result.delegateModule, + accounts : account, + // transactions: result.transactionModule + }); + + accountModuleDependencies = result; + txPool = new TransactionPool( + modulesLoader.scope.config.broadcasts.broadcastInterval, + modulesLoader.scope.config.broadcasts.releaseLimit, + result.transactionLogic, + modulesLoader.scope.bus, // bus + modulesLoader.logger// logger + ); + txPool.bind(account, null, modulesLoader.scope.loader); + done(); + }, { + logic: { + account : result.accountLogic, + transaction: result.transactionLogic + } + }); + }); + + }); + + describe('receiveTransactions', function () { + it('should do nothing for empty array', function (done) { + txPool.receiveTransactions([], false, function (err, data) { + expect(err).to.not.exist; + expect(data).to.be.empty; + done(); + }); + }); + it('should return error for invalid tx', function (done) { + txPool.receiveTransactions([{ id: '123' }], false, function (err, data) { + expect(err).to.exist; + done(); + }); + }); + it('should process tx if valid and insert tx into queue', function (done) { + var account = node.randomAccount(); + const tx = node.lisk.transaction.createTransaction(account.address, 100000000000, node.gAccount.password) + txPool.receiveTransactions([tx], false, function (err, data) { + expect(err).to.not.exist; + expect(txPool.transactionInPool(tx.id)).to.be.true; + done(); + }); + }); + }); + + describe('transactionInPool', function () { + it('should return false for an unknown id', function () { + expect(txPool.transactionInPool('11111')).to.be.false; + }); + }); +}); \ No newline at end of file From d29dee6ecf4f5828f3af1d0be188f66897431026 Mon Sep 17 00:00:00 2001 From: Andrea Baccega Date: Wed, 9 Aug 2017 15:32:53 +0200 Subject: [PATCH 02/11] fixed eslint + removed let --- logic/transactionPool.js | 2 +- test/unit/logic/transactionPool.js | 215 ++++++++++++++--------------- 2 files changed, 106 insertions(+), 111 deletions(-) diff --git a/logic/transactionPool.js b/logic/transactionPool.js index 05f27abd85f..63bf5276c47 100644 --- a/logic/transactionPool.js +++ b/logic/transactionPool.js @@ -103,7 +103,7 @@ TransactionPool.prototype.transactionInPool = function (id) { self.multisignature.index[id] ].filter(function (index) { return typeof(index) === 'number'; - }).length > 0; + }).length > 0; }; /** diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index 26e7a04926d..1b7b9a1bcd7 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -13,126 +13,121 @@ var modulesLoader = require('../../common/initModule').modulesLoader; var async = require('async'); var expect = require('chai').expect; var node = require('../../node'); -var ws = require('../../common/wsCommunication'); -function postTransaction(transaction, done) { - ws.call('postTransactions', { - transaction: transaction - }, done, true); -} + describe('transactionPool', function () { - let txPool; + var txPool; - before(function (done) { - // Init transaction logic - async.auto({ - rounds : function (cb) { - modulesLoader.initModule(Rounds, modulesLoader.scope, cb); - }, - accountLogic : function (cb) { - modulesLoader.initLogicWithDb(AccountLogic, cb); - }, - blockModule : ['accountLogic', function (result, cb) { - modulesLoader.initModuleWithDb(BlocksModule, cb, { - logic: { /* dependencies not included */ }, - }); - }], - transactionLogic: ['accountLogic', function (result, cb) { - modulesLoader.initLogicWithDb(TransactionLogic, cb, { - account: result.accountLogic - }); - }], - delegateModule : ['transactionLogic', function (result, cb) { - modulesLoader.initModuleWithDb(DelegateModule, cb, { - logic: { - transaction: result.transactionLogic - } - }); - }], - // transactionModule: ['transactionLogic', function (result, cb) { - // modulesLoader.initModuleWithDb(TransactionModule, cb, { - // transaction: result.transactionLogic - // }); - // }] - }, function (err, result) { - modulesLoader.initModuleWithDb(AccountModule, function (err, __accountModule) { - expect(err).to.not.exist; + before(function (done) { + // Init transaction logic + async.auto({ + rounds : function (cb) { + modulesLoader.initModule(Rounds, modulesLoader.scope, cb); + }, + accountLogic : function (cb) { + modulesLoader.initLogicWithDb(AccountLogic, cb); + }, + blockModule : ['accountLogic', function (result, cb) { + modulesLoader.initModuleWithDb(BlocksModule, cb, { + logic: { /* dependencies not included */ }, + }); + }], + transactionLogic: ['accountLogic', function (result, cb) { + modulesLoader.initLogicWithDb(TransactionLogic, cb, { + account: result.accountLogic + }); + }], + delegateModule : ['transactionLogic', function (result, cb) { + modulesLoader.initModuleWithDb(DelegateModule, cb, { + logic: { + transaction: result.transactionLogic + } + }); + }], + // transactionModule: ['transactionLogic', function (result, cb) { + // modulesLoader.initModuleWithDb(TransactionModule, cb, { + // transaction: result.transactionLogic + // }); + // }] + }, function (err, result) { + modulesLoader.initModuleWithDb(AccountModule, function (err, __accountModule) { + expect(err).to.not.exist; - var account = __accountModule; - accountLogic = result.accountLogic; + var account = __accountModule; + var accountLogic = result.accountLogic; - // for correctly initializing setting blocks module - result.blockModule.lastBlock.set({ height: 10 }); + // for correctly initializing setting blocks module + result.blockModule.lastBlock.set({ height: 10 }); - result.delegateModule.onBind({ - accounts: __accountModule, - // transactions: result.transactionModule, - blocks : result.blockModule - }); - var sendLogic = result.transactionLogic.attachAssetType(transactionTypes.SEND, new TransferLogic()); - sendLogic.bind(account, /* rounds */ null); - // - // result.transactionModule.onBind({ - // accounts: __accountModule, - // // transactions: result.transactionModule, - // //loader: - // }); + result.delegateModule.onBind({ + accounts: __accountModule, + // transactions: result.transactionModule, + blocks : result.blockModule + }); + var sendLogic = result.transactionLogic.attachAssetType(transactionTypes.SEND, new TransferLogic()); + sendLogic.bind(account, /* rounds */ null); + // + // result.transactionModule.onBind({ + // accounts: __accountModule, + // // transactions: result.transactionModule, + // //loader: + // }); - account.onBind({ - delegates: result.delegateModule, - accounts : account, - // transactions: result.transactionModule - }); + account.onBind({ + delegates: result.delegateModule, + accounts : account, + // transactions: result.transactionModule + }); - accountModuleDependencies = result; - txPool = new TransactionPool( - modulesLoader.scope.config.broadcasts.broadcastInterval, - modulesLoader.scope.config.broadcasts.releaseLimit, - result.transactionLogic, - modulesLoader.scope.bus, // bus - modulesLoader.logger// logger - ); - txPool.bind(account, null, modulesLoader.scope.loader); - done(); - }, { - logic: { - account : result.accountLogic, - transaction: result.transactionLogic - } - }); - }); + var accountModuleDependencies = result; + txPool = new TransactionPool( + modulesLoader.scope.config.broadcasts.broadcastInterval, + modulesLoader.scope.config.broadcasts.releaseLimit, + result.transactionLogic, + modulesLoader.scope.bus, // bus + modulesLoader.logger// logger + ); + txPool.bind(account, null, modulesLoader.scope.loader); + done(); + }, { + logic: { + account : result.accountLogic, + transaction: result.transactionLogic + } + }); + }); - }); + }); - describe('receiveTransactions', function () { - it('should do nothing for empty array', function (done) { - txPool.receiveTransactions([], false, function (err, data) { - expect(err).to.not.exist; - expect(data).to.be.empty; - done(); - }); - }); - it('should return error for invalid tx', function (done) { - txPool.receiveTransactions([{ id: '123' }], false, function (err, data) { - expect(err).to.exist; - done(); - }); - }); - it('should process tx if valid and insert tx into queue', function (done) { - var account = node.randomAccount(); - const tx = node.lisk.transaction.createTransaction(account.address, 100000000000, node.gAccount.password) - txPool.receiveTransactions([tx], false, function (err, data) { - expect(err).to.not.exist; - expect(txPool.transactionInPool(tx.id)).to.be.true; - done(); - }); - }); - }); + describe('receiveTransactions', function () { + it('should do nothing for empty array', function (done) { + txPool.receiveTransactions([], false, function (err, data) { + expect(err).to.not.exist; + expect(data).to.be.empty; + done(); + }); + }); + it('should return error for invalid tx', function (done) { + txPool.receiveTransactions([{ id: '123' }], false, function (err, data) { + expect(err).to.exist; + done(); + }); + }); + it('should process tx if valid and insert tx into queue', function (done) { + var account = node.randomAccount(); + const tx = node.lisk.transaction.createTransaction(account.address, 100000000000, node.gAccount.password); + txPool.receiveTransactions([tx], false, function (err, data) { + expect(err).to.not.exist; + expect(txPool.transactionInPool(tx.id)).to.be.true; + done(); + }); + }); + }); - describe('transactionInPool', function () { - it('should return false for an unknown id', function () { - expect(txPool.transactionInPool('11111')).to.be.false; - }); - }); + describe('transactionInPool', function () { + it('should return false for an unknown id', function () { + expect(txPool.transactionInPool('11111')).to.be.false; + }); + }); }); \ No newline at end of file From 8f842321dd2a4e405935d15a008f079f26f34711 Mon Sep 17 00:00:00 2001 From: Andrea Baccega Date: Fri, 11 Aug 2017 14:41:28 +0200 Subject: [PATCH 03/11] removed comments and used some instead of filter. --- logic/transactionPool.js | 2 +- test/unit/logic/transactionPool.js | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/logic/transactionPool.js b/logic/transactionPool.js index 63bf5276c47..f1c959b7d69 100644 --- a/logic/transactionPool.js +++ b/logic/transactionPool.js @@ -101,7 +101,7 @@ TransactionPool.prototype.transactionInPool = function (id) { self.bundled.index[id], self.queued.index[id], self.multisignature.index[id] - ].filter(function (index) { + ].some(function (index) { return typeof(index) === 'number'; }).length > 0; }; diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index 1b7b9a1bcd7..26e80eb3e89 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -45,11 +45,6 @@ describe('transactionPool', function () { } }); }], - // transactionModule: ['transactionLogic', function (result, cb) { - // modulesLoader.initModuleWithDb(TransactionModule, cb, { - // transaction: result.transactionLogic - // }); - // }] }, function (err, result) { modulesLoader.initModuleWithDb(AccountModule, function (err, __accountModule) { expect(err).to.not.exist; @@ -67,12 +62,6 @@ describe('transactionPool', function () { }); var sendLogic = result.transactionLogic.attachAssetType(transactionTypes.SEND, new TransferLogic()); sendLogic.bind(account, /* rounds */ null); - // - // result.transactionModule.onBind({ - // accounts: __accountModule, - // // transactions: result.transactionModule, - // //loader: - // }); account.onBind({ delegates: result.delegateModule, From 70dfa202dd63878eb5bd9fc4a170cea46cd6c4b6 Mon Sep 17 00:00:00 2001 From: Andrea Baccega Date: Mon, 14 Aug 2017 12:19:55 +0200 Subject: [PATCH 04/11] fixed wrong implementation of `some` check and removed rounds from transactionPool tests. --- logic/transactionPool.js | 2 +- test/unit/logic/transactionPool.js | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/logic/transactionPool.js b/logic/transactionPool.js index f1c959b7d69..2a881aabb1e 100644 --- a/logic/transactionPool.js +++ b/logic/transactionPool.js @@ -103,7 +103,7 @@ TransactionPool.prototype.transactionInPool = function (id) { self.multisignature.index[id] ].some(function (index) { return typeof(index) === 'number'; - }).length > 0; + }); }; /** diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index 26e80eb3e89..449bf472e2e 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -8,7 +8,6 @@ var transactionTypes = require('../../../helpers/transactionTypes'); var AccountModule = require('../../../modules/accounts.js'); var BlocksModule = require('../../../modules/blocks.js'); var AccountLogic = require('../../../logic/account.js'); -var Rounds = require('../../../modules/rounds.js'); var modulesLoader = require('../../common/initModule').modulesLoader; var async = require('async'); var expect = require('chai').expect; @@ -22,9 +21,7 @@ describe('transactionPool', function () { before(function (done) { // Init transaction logic async.auto({ - rounds : function (cb) { - modulesLoader.initModule(Rounds, modulesLoader.scope, cb); - }, + accountLogic : function (cb) { modulesLoader.initLogicWithDb(AccountLogic, cb); }, From 76934439a073d9580946b37eca6067c19792bbbf Mon Sep 17 00:00:00 2001 From: Andrea Baccega Date: Mon, 14 Aug 2017 16:05:26 +0200 Subject: [PATCH 05/11] removed useless code. --- test/unit/logic/transactionPool.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index 449bf472e2e..a4883f57b2e 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -54,7 +54,6 @@ describe('transactionPool', function () { result.delegateModule.onBind({ accounts: __accountModule, - // transactions: result.transactionModule, blocks : result.blockModule }); var sendLogic = result.transactionLogic.attachAssetType(transactionTypes.SEND, new TransferLogic()); @@ -63,7 +62,6 @@ describe('transactionPool', function () { account.onBind({ delegates: result.delegateModule, accounts : account, - // transactions: result.transactionModule }); var accountModuleDependencies = result; From ee798a183656ed29f4eab73d446ed5f46a6a5078 Mon Sep 17 00:00:00 2001 From: Andrea Baccega Date: Mon, 14 Aug 2017 16:10:36 +0200 Subject: [PATCH 06/11] rounds are not used anymore. --- test/unit/logic/transactionPool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index a4883f57b2e..f79983f6d40 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -57,7 +57,7 @@ describe('transactionPool', function () { blocks : result.blockModule }); var sendLogic = result.transactionLogic.attachAssetType(transactionTypes.SEND, new TransferLogic()); - sendLogic.bind(account, /* rounds */ null); + sendLogic.bind(account); account.onBind({ delegates: result.delegateModule, From 01f386bc41b5dd2fa2ee9d0a4b2aad762861fa9d Mon Sep 17 00:00:00 2001 From: Oliver Beddows Date: Mon, 14 Aug 2017 19:33:03 +0200 Subject: [PATCH 07/11] Standardising requires --- test/unit/logic/transactionPool.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index f79983f6d40..56a54fc7957 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -1,13 +1,13 @@ -var TransactionPool = require('../../../logic/transactionPool.js'); -var TransactionLogic = require('../../../logic/transaction.js'); -var DelegateModule = require('../../../modules/delegates.js'); +var TransactionPool = require('../../../logic/transactionPool'); +var TransactionLogic = require('../../../logic/transaction'); +var DelegateModule = require('../../../modules/delegates'); -var TransferLogic = require('../../../logic/transfer.js'); +var TransferLogic = require('../../../logic/transfer'); var transactionTypes = require('../../../helpers/transactionTypes'); -var AccountModule = require('../../../modules/accounts.js'); -var BlocksModule = require('../../../modules/blocks.js'); -var AccountLogic = require('../../../logic/account.js'); +var AccountModule = require('../../../modules/accounts'); +var BlocksModule = require('../../../modules/blocks'); +var AccountLogic = require('../../../logic/account'); var modulesLoader = require('../../common/initModule').modulesLoader; var async = require('async'); var expect = require('chai').expect; From 65c01aff2c28c03bc2fa101c89b9386badb52f8e Mon Sep 17 00:00:00 2001 From: Oliver Beddows Date: Mon, 14 Aug 2017 19:34:21 +0200 Subject: [PATCH 08/11] Normalising space --- test/unit/logic/transactionPool.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index 56a54fc7957..d24bc760353 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -13,19 +13,17 @@ var async = require('async'); var expect = require('chai').expect; var node = require('../../node'); - - describe('transactionPool', function () { + var txPool; before(function (done) { // Init transaction logic async.auto({ - - accountLogic : function (cb) { + accountLogic: function (cb) { modulesLoader.initLogicWithDb(AccountLogic, cb); }, - blockModule : ['accountLogic', function (result, cb) { + blockModule: ['accountLogic', function (result, cb) { modulesLoader.initModuleWithDb(BlocksModule, cb, { logic: { /* dependencies not included */ }, }); @@ -54,7 +52,7 @@ describe('transactionPool', function () { result.delegateModule.onBind({ accounts: __accountModule, - blocks : result.blockModule + blocks: result.blockModule }); var sendLogic = result.transactionLogic.attachAssetType(transactionTypes.SEND, new TransferLogic()); sendLogic.bind(account); @@ -65,7 +63,7 @@ describe('transactionPool', function () { }); var accountModuleDependencies = result; - txPool = new TransactionPool( + txPool = new TransactionPool( modulesLoader.scope.config.broadcasts.broadcastInterval, modulesLoader.scope.config.broadcasts.releaseLimit, result.transactionLogic, @@ -81,10 +79,10 @@ describe('transactionPool', function () { } }); }); - }); describe('receiveTransactions', function () { + it('should do nothing for empty array', function (done) { txPool.receiveTransactions([], false, function (err, data) { expect(err).to.not.exist; @@ -92,15 +90,18 @@ describe('transactionPool', function () { done(); }); }); + it('should return error for invalid tx', function (done) { txPool.receiveTransactions([{ id: '123' }], false, function (err, data) { expect(err).to.exist; done(); }); }); + it('should process tx if valid and insert tx into queue', function (done) { var account = node.randomAccount(); const tx = node.lisk.transaction.createTransaction(account.address, 100000000000, node.gAccount.password); + txPool.receiveTransactions([tx], false, function (err, data) { expect(err).to.not.exist; expect(txPool.transactionInPool(tx.id)).to.be.true; @@ -110,8 +111,9 @@ describe('transactionPool', function () { }); describe('transactionInPool', function () { + it('should return false for an unknown id', function () { expect(txPool.transactionInPool('11111')).to.be.false; }); }); -}); \ No newline at end of file +}); From 11dc29ba6a5156bb96cd8bcb2a5f9cdd68dad943 Mon Sep 17 00:00:00 2001 From: Oliver Beddows Date: Mon, 14 Aug 2017 19:34:37 +0200 Subject: [PATCH 09/11] Standardising comments --- test/unit/logic/transactionPool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index d24bc760353..f9471dee810 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -47,7 +47,7 @@ describe('transactionPool', function () { var account = __accountModule; var accountLogic = result.accountLogic; - // for correctly initializing setting blocks module + // For correctly initializing setting blocks module result.blockModule.lastBlock.set({ height: 10 }); result.delegateModule.onBind({ @@ -67,8 +67,8 @@ describe('transactionPool', function () { modulesLoader.scope.config.broadcasts.broadcastInterval, modulesLoader.scope.config.broadcasts.releaseLimit, result.transactionLogic, - modulesLoader.scope.bus, // bus - modulesLoader.logger// logger + modulesLoader.scope.bus, // Bus + modulesLoader.logger // Logger ); txPool.bind(account, null, modulesLoader.scope.loader); done(); From 7a0a76721122159e40d25d5d3e489f50998fe898 Mon Sep 17 00:00:00 2001 From: Oliver Beddows Date: Mon, 14 Aug 2017 19:43:04 +0200 Subject: [PATCH 10/11] Normalising space --- test/unit/logic/transactionPool.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index f9471dee810..0ee4a911e8f 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -1,17 +1,17 @@ -var TransactionPool = require('../../../logic/transactionPool'); +var TransactionPool = require('../../../logic/transactionPool'); var TransactionLogic = require('../../../logic/transaction'); -var DelegateModule = require('../../../modules/delegates'); +var DelegateModule = require('../../../modules/delegates'); var TransferLogic = require('../../../logic/transfer'); var transactionTypes = require('../../../helpers/transactionTypes'); -var AccountModule = require('../../../modules/accounts'); -var BlocksModule = require('../../../modules/blocks'); -var AccountLogic = require('../../../logic/account'); -var modulesLoader = require('../../common/initModule').modulesLoader; -var async = require('async'); -var expect = require('chai').expect; -var node = require('../../node'); +var AccountModule = require('../../../modules/accounts'); +var BlocksModule = require('../../../modules/blocks'); +var AccountLogic = require('../../../logic/account'); +var modulesLoader = require('../../common/initModule').modulesLoader; +var async = require('async'); +var expect = require('chai').expect; +var node = require('../../node'); describe('transactionPool', function () { @@ -33,7 +33,7 @@ describe('transactionPool', function () { account: result.accountLogic }); }], - delegateModule : ['transactionLogic', function (result, cb) { + delegateModule: ['transactionLogic', function (result, cb) { modulesLoader.initModuleWithDb(DelegateModule, cb, { logic: { transaction: result.transactionLogic @@ -44,7 +44,7 @@ describe('transactionPool', function () { modulesLoader.initModuleWithDb(AccountModule, function (err, __accountModule) { expect(err).to.not.exist; - var account = __accountModule; + var account = __accountModule; var accountLogic = result.accountLogic; // For correctly initializing setting blocks module @@ -59,7 +59,7 @@ describe('transactionPool', function () { account.onBind({ delegates: result.delegateModule, - accounts : account, + accounts: account, }); var accountModuleDependencies = result; @@ -74,7 +74,7 @@ describe('transactionPool', function () { done(); }, { logic: { - account : result.accountLogic, + account: result.accountLogic, transaction: result.transactionLogic } }); @@ -100,7 +100,7 @@ describe('transactionPool', function () { it('should process tx if valid and insert tx into queue', function (done) { var account = node.randomAccount(); - const tx = node.lisk.transaction.createTransaction(account.address, 100000000000, node.gAccount.password); + const tx = node.lisk.transaction.createTransaction(account.address, 100000000000, node.gAccount.password); txPool.receiveTransactions([tx], false, function (err, data) { expect(err).to.not.exist; From 7d4051ad7c8816b3a45fd0c753dbd4f863256c17 Mon Sep 17 00:00:00 2001 From: Oliver Beddows Date: Mon, 14 Aug 2017 19:44:09 +0200 Subject: [PATCH 11/11] Adding use strict --- test/unit/logic/transactionPool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unit/logic/transactionPool.js b/test/unit/logic/transactionPool.js index 0ee4a911e8f..a9b72375363 100644 --- a/test/unit/logic/transactionPool.js +++ b/test/unit/logic/transactionPool.js @@ -1,3 +1,5 @@ +'use strict';/*eslint*/ + var TransactionPool = require('../../../logic/transactionPool'); var TransactionLogic = require('../../../logic/transaction'); var DelegateModule = require('../../../modules/delegates');