-
Notifications
You must be signed in to change notification settings - Fork 457
Fix transaction pool bug in "transactionInPool" plus tests - Closes #707 #708
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @vekexasia 👍
test/unit/logic/transactionPool.js
Outdated
} | ||
|
||
describe('transactionPool', function () { | ||
let txPool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still on es5
. The project is scheduled to be updated at the end of the current milestone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops you're right. missed that let
test/unit/logic/transactionPool.js
Outdated
let txPool; | ||
|
||
before(function (done) { | ||
// Init transaction logic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we now have a test helper for this. Not sure if applicable @4miners?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that is not merged yet.
logic/transactionPool.js
Outdated
].filter(Boolean).length > 0; | ||
].filter(function (index) { | ||
return typeof(index) === 'number'; | ||
}).length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
test/unit/logic/transactionPool.js
Outdated
|
||
}); | ||
|
||
describe('receiveTransactions', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please adjust the formatting to:
describe('description', function () {
it('example 1');
it('example 2');
it('example 3');
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm @karmacoma I might be blind but i don't see what's different between your formatting and mine
logic/transactionPool.js
Outdated
@@ -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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return index !== undefined
is more clear ans should do the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@4miners I'd disagree about the clearness of doing index !== undefined
.
While the result would be the same (Starting from es5 since before undefined used to be mutable) it does not give any hint on what index should be.
Keeping it as I proposed will clearly give code-reader a clue of what self.bundled.*[id]
should be => a number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine for me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to use some
as it returns a boolean and does not iterate through a whole array if finds a match before:
[...].some(function(index){return typeof index === 'number'})
test/unit/logic/transactionPool.js
Outdated
let txPool; | ||
|
||
before(function (done) { | ||
// Init transaction logic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that is not merged yet.
Please fix your ESLINT failures: https://jenkins.lisk.io/job/lisk-core/job/PR-708/6/execution/node/204/log/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eslint failures
test/unit/logic/transactionPool.js
Outdated
// modulesLoader.initModuleWithDb(TransactionModule, cb, { | ||
// transaction: result.transactionLogic | ||
// }); | ||
// }] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get rid of comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- remove the commented code from tests
- I reccomend to use
some
function, explained in the comment
Hello, I've just pushed a commit where I removed some comments in the test files and used |
test/unit/logic/transactionPool.js
Outdated
var AccountModule = require('../../../modules/accounts.js'); | ||
var BlocksModule = require('../../../modules/blocks.js'); | ||
var AccountLogic = require('../../../logic/account.js'); | ||
var Rounds = require('../../../modules/rounds.js'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rounds
module is no longer there, please remove all references to it.
logic/transactionPool.js
Outdated
].filter(Boolean).length > 0; | ||
].some(function (index) { | ||
return typeof(index) === 'number'; | ||
}).length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some returns true
/ false
so need to check the length here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad. sorry.
…ansactionPool tests.
test/unit/logic/transactionPool.js
Outdated
blocks : result.blockModule | ||
}); | ||
var sendLogic = result.transactionLogic.attachAssetType(transactionTypes.SEND, new TransferLogic()); | ||
sendLogic.bind(account, /* rounds */ null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need that null
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's best to leave it like that for clarity as proper initialization for further testing might need rounds too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, rounds are not exist anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm? since when?
Btw i committed with requested modifications :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since #597, thanks :)
test/unit/logic/transactionPool.js
Outdated
|
||
result.delegateModule.onBind({ | ||
accounts: __accountModule, | ||
// transactions: result.transactionModule, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either enable or remove
test/unit/logic/transactionPool.js
Outdated
account.onBind({ | ||
delegates: result.delegateModule, | ||
accounts : account, | ||
// transactions: result.transactionModule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Tests are failing when merged against the 1.0.0 branch:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vekexasia please synchronize your branch with 1.0.0 and resolve the mentioned issues.
This PR is superceded by #725 Thank you for the hard work. |
Fixes #707