Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Fix transaction pool bug in "transactionInPool" plus tests - Closes #707 #708

Closed
wants to merge 13 commits into from
Closed

Conversation

vekexasia
Copy link

Fixes #707

@Isabello Isabello self-assigned this Aug 9, 2017
@Isabello Isabello requested a review from a team August 9, 2017 08:27
@Isabello Isabello changed the base branch from development to 1.0.0 August 9, 2017 08:28
@karmacoma karmacoma changed the title Fix transaction pool bug in "transactionInPool" plus tests. Fix transaction pool bug in "transactionInPool" plus tests Aug 9, 2017
Copy link
Contributor

@karmacoma karmacoma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @vekexasia 👍

}

describe('transactionPool', function () {
let txPool;
Copy link
Contributor

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.

Copy link
Author

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

let txPool;

before(function (done) {
// Init transaction logic
Copy link
Contributor

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?

Copy link
Contributor

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.

].filter(Boolean).length > 0;
].filter(function (index) {
return typeof(index) === 'number';
}).length > 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation


});

describe('receiveTransactions', function () {
Copy link
Contributor

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');
});

Copy link
Author

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

@karmacoma karmacoma changed the title Fix transaction pool bug in "transactionInPool" plus tests Fix transaction pool bug in "transactionInPool" plus tests - Fixes #707 Aug 9, 2017
@@ -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';
Copy link
Contributor

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

Copy link
Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine for me :)

Copy link
Contributor

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'})

let txPool;

before(function (done) {
// Init transaction logic
Copy link
Contributor

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.

@Isabello
Copy link
Contributor

Isabello commented Aug 9, 2017

Copy link
Contributor

@Isabello Isabello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eslint failures

@diego-G diego-G changed the title Fix transaction pool bug in "transactionInPool" plus tests - Fixes #707 Fix transaction pool bug in "transactionInPool" plus tests - Closes #707 Aug 9, 2017
// modulesLoader.initModuleWithDb(TransactionModule, cb, {
// transaction: result.transactionLogic
// });
// }]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of comments

Copy link
Contributor

@MaciejBaj MaciejBaj left a 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

@vekexasia
Copy link
Author

Hello,

I've just pushed a commit where I removed some comments in the test files and used some instead of filter as proposed by @MaciejBaj

var AccountModule = require('../../../modules/accounts.js');
var BlocksModule = require('../../../modules/blocks.js');
var AccountLogic = require('../../../logic/account.js');
var Rounds = require('../../../modules/rounds.js');
Copy link
Contributor

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.

].filter(Boolean).length > 0;
].some(function (index) {
return typeof(index) === 'number';
}).length > 0;
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad. sorry.

blocks : result.blockModule
});
var sendLogic = result.transactionLogic.attachAssetType(transactionTypes.SEND, new TransferLogic());
sendLogic.bind(account, /* rounds */ null);
Copy link
Contributor

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?

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

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 :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since #597, thanks :)


result.delegateModule.onBind({
accounts: __accountModule,
// transactions: result.transactionModule,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either enable or remove

account.onBind({
delegates: result.delegateModule,
accounts : account,
// transactions: result.transactionModule
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@Isabello
Copy link
Contributor

Tests are failing when merged against the 1.0.0 branch:

  transactionPool
    receiveTransactions
      ✓ should do nothing for empty array
      ✓ should return error for invalid tx
>> /home/lisk/workspace/lisk-core_PR-708-EDN5H7BPFPHQW4UHUSL4OK4TW2RIYZ4Z52RCLPU7BZC2MGVJYLVQ/node_modules/js-nacl/lib/nacl_factory.js:27
>> var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="fu
>> AssertionError: expected [TypeError: Cannot read property 'validate' of undefined] to not exist
>>   at Assertion.<anonymous> (/home/lisk/workspace/lisk-core_PR-708-EDN5H7BPFPHQW4UHUSL4OK4TW2RIYZ4Z52RCLPU7BZC2MGVJYLVQ/node_modules/chai/lib/chai/core/assertions.js:758:10)
>>   at Assertion.propertyGetter (/home/lisk/workspace/lisk-core_PR-708-EDN5H7BPFPHQW4UHUSL4OK4TW2RIYZ4Z52RCLPU7BZC2MGVJYLVQ/node_modules/chai/lib/chai/utils/addProperty.js:62:29)
>>   at Object.proxyGetter [as get] (/home/lisk/workspace/lisk-core_PR-708-EDN5H7BPFPHQW4UHUSL4OK4TW2RIYZ4Z52RCLPU7BZC2MGVJYLVQ/node_modules/chai/lib/chai/utils/proxify.js:86:22)
>>   at Immediate.<anonymous> (/home/lisk/workspace/lisk-core_PR-708-EDN5H7BPFPHQW4UHUSL4OK4TW2RIYZ4Z52RCLPU7BZC2MGVJYLVQ/test/unit/logic/transactionPool.js:108:23)
>>   at runCallback (timers.js:676:20)
>>   at tryOnImmediate (timers.js:645:5)
>>   at processImmediate [as _immediateCallback] (timers.js:617:5)
>> Exited with code: 7.
>> Error executing child process: Error: Process exited with code 7.
Warning: Task "exec:coverageSingle" failed.� Use --force to continue.

Copy link
Contributor

@Isabello Isabello left a 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.

@Isabello
Copy link
Contributor

Isabello commented Aug 16, 2017

This PR is superceded by #725

Thank you for the hard work.

@Isabello Isabello closed this Aug 16, 2017
@karmacoma karmacoma self-assigned this Apr 15, 2019
@karmacoma karmacoma removed their assignment Dec 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants