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

Review unit test coverage for logic transaction pool - Closes #1662 #1692

Merged

Conversation

ManuGowda
Copy link
Contributor

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

@karmacoma karmacoma requested a review from LucasIsasmendi March 9, 2018 11:23
@@ -110,27 +170,1073 @@ describe('transactionPool', () => {
);
});

it('bundled should be initialized', () => {
return expect(transactionPool.bundled).to.deep.equal(freshListState);
it('bundled should be initialized', () => {
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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() {
Copy link
Contributor

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;
Copy link
Contributor

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;
};
Copy link
Contributor

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

@ManuGowda
Copy link
Contributor Author

@LucasIsasmendi I have converted the missing tests and we have all the methods coverage, as we discussed I have stubbed wherever required.

Manu Nelamane Siddalingegowda added 2 commits March 13, 2018 09:10
@karmacoma karmacoma assigned MaciejBaj and unassigned karmacoma Mar 13, 2018
@MaciejBaj MaciejBaj merged commit 0e8483a into 1.0.0 Mar 14, 2018
@MaciejBaj MaciejBaj deleted the 1662-Review_unit_test_coverage_for_logic_transaction_pool branch March 14, 2018 16:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants