Skip to content

Commit

Permalink
Test fix #3
Browse files Browse the repository at this point in the history
  • Loading branch information
josipbagaric committed Nov 20, 2018
1 parent e5c98cb commit c51fe39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default class W3Util {
const currentBlockNumber: number = await this.getBlockNumber();
const firstBlock: IBlock = await this.getBlock(currentBlockNumber - numLookbackBlocks);

for (let i = currentBlockNumber - numLookbackBlocks; i < currentBlockNumber; i++) {
for (let i = firstBlock.number; i < currentBlockNumber; i++) {
blockPromises.push(this.getBlock(i));
}

Expand Down
16 changes: 8 additions & 8 deletions test/unit/UnitTestUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ describe('Util Unit Tests', async () => {
const config: Config = await mockConfig();
const util: W3Util = new W3Util(config.web3);

describe('getAverageBlockTime()', () => {
it('returns the average blocktime of last 100 blocks', async () => {
const avgBlockTime = await util.getAverageBlockTime();
assert.isNumber(avgBlockTime);
assert.isAbove(avgBlockTime, 0);
});
});

describe('estimateGas()', () => {
it('returns a number', async () => {
const gas = await util.estimateGas({});
Expand Down Expand Up @@ -65,12 +73,4 @@ describe('Util Unit Tests', async () => {
assert.isTrue(watching);
});
});

describe('getAverageBlockTime()', () => {
it('returns the average blocktime of last 100 blocks', async () => {
const avgBlockTime = await util.getAverageBlockTime();
assert.isNumber(avgBlockTime);
assert.isAbove(avgBlockTime, 0);
});
});
});

0 comments on commit c51fe39

Please sign in to comment.