-
Notifications
You must be signed in to change notification settings - Fork 457
Review unit test coverage for logic transaction pool - Closes #1662 #1692
Review unit test coverage for logic transaction pool - Closes #1662 #1692
Conversation
…ons, processBundled tests
…ol' of https://github.com/LiskHQ/lisk into 1662-Review_unit_test_coverage_for_logic_transaction_pool
test/unit/logic/transaction_pool.js
Outdated
@@ -110,27 +170,1073 @@ describe('transactionPool', () => { | |||
); | |||
}); | |||
|
|||
it('bundled should be initialized', () => { | |||
return expect(transactionPool.bundled).to.deep.equal(freshListState); | |||
it('bundled should be initialized', () => { |
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.
Pending:
- check if library was loaded with correct content
- check jobsQueue.register called with transactionPoolNextExpiry and transactionPoolNextBundle
- scenario for Bundled transaction timer error
- scenario for Transaction expiry timer error
- check if other values were loaded with correct values (bundledInterval, bundleLimit, processed, etc)
describe('getUnconfirmedTransaction', () => { | ||
const validTransaction = { id: '123' }; | ||
beforeEach(() => { | ||
return transactionPool.addUnconfirmedTransaction(validTransaction); |
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.
Instead of call another function to set the scenario for this specific test, it should assign directly the value to self.unconfirmed.transactions
describe('getBundledTransaction', () => { | ||
const validTransaction = { id: '123' }; | ||
beforeEach(() => { | ||
return transactionPool.addBundledTransaction(validTransaction); |
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.
Instead of call another function to set the scenario for this specific test, it should assign directly the value to self.bundled.transactions
describe('getQueuedTransaction', () => { | ||
const validTransaction = { id: '123' }; | ||
beforeEach(() => { | ||
return transactionPool.addQueuedTransaction(validTransaction); |
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.
Instead of call another function to set the scenario for this specific test, it should assign directly the value to self.queued.transactions
describe('getMultisignatureTransaction', () => { | ||
const validTransaction = { id: '123' }; | ||
beforeEach(() => { | ||
return transactionPool.addMultisignatureTransaction(validTransaction); |
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.
Instead of call another function to set the scenario for this specific test, it should assign directly the value to self.multisignature.transactions
}); | ||
}); | ||
|
||
after(resetStates); |
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 need to resetStates when beforeEach creates the object and afterEach restore sinonSandbox
const transactions = [validTransaction]; | ||
|
||
before(done => { | ||
transactionPool.addUnconfirmedTransaction(validTransaction); |
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 need to use this function
|
||
before(done => { | ||
transactionPool.addUnconfirmedTransaction(validTransaction); | ||
transactionPool.getUnconfirmedTransactionList = 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.
Stub this function
}); | ||
|
||
describe('lists', () => { | ||
let index; |
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.
unconfirmed.index, queued.index and multisignature.index are out of the scope of this unit test
transactionPool.addUnconfirmedTransaction(badTransaction); | ||
transactionPool.getUnconfirmedTransactionList = function() { | ||
return transactions; | ||
}; |
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 need to call these functions in this unit test, everything should be stub or directly assigned
@LucasIsasmendi I have converted the missing tests and we have all the methods coverage, as we discussed I have stubbed wherever required. |
…ol' of https://github.com/LiskHQ/lisk into 1662-Review_unit_test_coverage_for_logic_transaction_pool
To avoid misconception that transaction ids might be account addresses
What was the problem?
Missing test for logic
transaction_pool
How did I fix it?
Adding the missing tests
How to test it?
mocha test/unit/logic/transaction_pool.js
Review checklist