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

Commit

Permalink
Add unit tests for transactionInPool function
Browse files Browse the repository at this point in the history
  • Loading branch information
4miners authored and Usman committed Mar 5, 2018
1 parent ae2f7d5 commit 6ab26b5
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions test/unit/logic/transaction_pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,4 +644,84 @@ describe('transactionPool', () => {
});
});
});

describe('transactionInPool', () => {
afterEach(() => {
return resetStates();
});

describe('when transaction is in pool', () => {
var tx = '123';

describe('unconfirmed list', () => {
describe('with index 0', () => {
it('should return true', () => {
transactionPool.unconfirmed.index[tx] = 0;
return expect(transactionPool.transactionInPool(tx)).to.equal(true);
});
});

describe('with other index', () => {
it('should return true', () => {
transactionPool.unconfirmed.index[tx] = 1;
return expect(transactionPool.transactionInPool(tx)).to.equal(true);
});
});
});

describe('bundled list', () => {
describe('with index 0', () => {
it('should return true', () => {
transactionPool.bundled.index[tx] = 0;
return expect(transactionPool.transactionInPool(tx)).to.equal(true);
});
});

describe('with other index', () => {
it('should return true', () => {
transactionPool.bundled.index[tx] = 1;
return expect(transactionPool.transactionInPool(tx)).to.equal(true);
});
});
});

describe('queued list', () => {
describe('with index 0', () => {
it('should return true', () => {
transactionPool.queued.index[tx] = 0;
return expect(transactionPool.transactionInPool(tx)).to.equal(true);
});
});

describe('with other index', () => {
it('should return true', () => {
transactionPool.queued.index[tx] = 1;
return expect(transactionPool.transactionInPool(tx)).to.equal(true);
});
});
});

describe('multisignature list', () => {
describe('with index 0', () => {
it('should return true', () => {
transactionPool.multisignature.index[tx] = 0;
return expect(transactionPool.transactionInPool(tx)).to.equal(true);
});
});

describe('with other index', () => {
it('should return true', () => {
transactionPool.multisignature.index[tx] = 1;
return expect(transactionPool.transactionInPool(tx)).to.equal(true);
});
});
});
});

describe('when transaction is not in pool', () => {
it('should return false', () => {
return expect(transactionPool.transactionInPool('123')).to.equal(false);
});
});
});
});

0 comments on commit 6ab26b5

Please sign in to comment.