-
Notifications
You must be signed in to change notification settings - Fork 49
Add tests for increased coverage #93
Conversation
st.end() | ||
}) | ||
|
||
t.test('should validate a genesis block header', st => { |
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.
The new tests added in this PR start here ... sorry for diff, I renamed the files from test/*.ts
to test/*.spec.ts
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.
Do you know that renaming can also be done via git which should preserve the file comparison respectively did you try?
For now it's ok.
@@ -56,18 +55,19 @@ | |||
"@ethereumjs/config-prettier": "^1.1.1", | |||
"@ethereumjs/config-tsc": "^1.1.1", | |||
"@ethereumjs/config-tslint": "^1.1.1", | |||
"@types/lru-cache": "^5.1.0", |
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.
I found I had to add this type because ethereumjs-blockchain
was failing to build in the browser. This might be good motivation to introduce a karma test runner for that repo to catch this and future issues.
The error encountered in karma was:
node_modules/ethereumjs-blockchain/dist/cache.d.ts:2:22 - error TS7016: Could not find a declaration file for module 'lru-cache'.
'/Users/rg/dev/ethereumjs-block/node_modules/ethereumjs-blockchain/node_modules/lru-cache/index.js' implicitly has an 'any' type.
Try `npm install @types/lru-cache` if it exists or add a new declaration (.d.ts) file containing `declare module 'lru-cache';`
2 import * as LRU from 'lru-cache';
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.
Yeah, I think we should have karma tests along all (actively developed) libraries.
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.
Nice, thanks Ryan for wandering with open eyes through the libraries, yes, we still have some cases with significant gaps in test coverage, good to have such a significant step up here.
Will approve and directly merge.
"karma-firefox-launcher": "^1.1.0", | ||
"karma-tap": "^4.1.4", | ||
"nyc": "^14.0.0", | ||
"nyc": "^15.0.0", | ||
"prettier": "^1.17.0", | ||
"tape": "^4.0.3", | ||
"ts-node": "^8.0.3", |
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.
All config-related stuff until here ok.
@@ -284,7 +284,7 @@ export class BlockHeader { | |||
} | |||
|
|||
if (utils.bufferToInt(parentBlock.header.number) + 1 !== utils.bufferToInt(this.number)) { | |||
throw new Error('invalid heigth') | |||
throw new Error('invalid height') | |||
} | |||
|
|||
if (utils.bufferToInt(this.timestamp) <= utils.bufferToInt(parentBlock.header.timestamp)) { |
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.
Ok, some error message corrections.
mainnet: require('./difficultyMainNetwork.json').tests, | ||
ropsten: require('./difficultyRopstenConstantinople.json').tests, | ||
mainnet: require('./testdata/difficultyMainNetwork.json').tests, | ||
ropsten: require('./testdata/difficultyRopstenConstantinople.json').tests, | ||
} | ||
for (const chain in chainTestData) { | ||
const testData = chainTestData[chain] |
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.
Ok, mainly shifts to testdata
directory.
let block = blockHeaderFromRpc(blockData) | ||
st.ok(block.hash().compare(Buffer.from(blockData.hash))) | ||
st.end() | ||
}) |
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.
Ok.
st.end() | ||
}) | ||
|
||
t.test('should validate a genesis block header', st => { |
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.
Do you know that renaming can also be done via git which should preserve the file comparison respectively did you try?
For now it's ok.
st.fail(error) | ||
st.end() | ||
} | ||
}) |
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.
Ok.
st.ok(true) | ||
st.end() | ||
} | ||
}) |
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.
Ok.
st.end() | ||
} | ||
}) | ||
}) |
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.
Ok.
This PR adds tests for increased code coverage:
json
files to their own subdir to unclutter the parent test dir