Commit 46d30311 authored by Maurelian's avatar Maurelian Committed by GitHub

Add coverage testing script (#348)

* Add coverage config

* Add flags to skip gas tests when running coverage

* Check-in coverage output

* Revert "Check-in coverage output"


Too noisy to have coverage output stored here. I will look for an alternative solution.

This reverts commit fb631f2471903e9b8ab76c66e18f308d92930cae.

* Add test coverage artifacts to gitignore

* Add test coverage instructions to README

* Lint
parent c8e4c555
......@@ -6,3 +6,7 @@ cache-ovm/
yarn-error.log
build/
.DS_STORE
# Coverage output
coverage/
coverage.json
module.exports = {
skipFiles: [
'./test-helpers',
'./test-libraries',
'./optimistic-ethereum/mockOVM'
],
mocha: {
grep: "@skip-on-coverage",
invert: true
}
};
......@@ -54,6 +54,16 @@ Run specific tests by giving a path to the file you want to run:
yarn test ./test/path/to/my/test.spec.ts
```
### Measuring test coverage:
```shell
yarn test-coverage
```
The output is most easily viewable by opening the html file in your browser:
```shell
open ./coverage/index.html
```
### Compiling and Building
Easiest way is to run the primary build script:
```shell
......
import { HardhatUserConfig } from 'hardhat/types'
import 'solidity-coverage'
import {
DEFAULT_ACCOUNTS_HARDHAT,
......
......@@ -28,6 +28,7 @@
"test": "yarn run test:contracts",
"test:contracts": "hardhat test --show-stack-traces",
"test:gas": "hardhat test \"test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts\" --no-compile --show-stack-traces",
"test-coverage": "NODE_OPTIONS=--max_old_space_size=8192 hardhat coverage",
"lint": "yarn run lint:typescript",
"lint:typescript": "tslint --format stylish --project .",
"lint:fix": "yarn run lint:fix:typescript",
......@@ -46,7 +47,8 @@
"@openzeppelin/contracts": "^3.3.0",
"@typechain/hardhat": "^1.0.1",
"ganache-core": "^2.13.2",
"glob": "^7.1.6"
"glob": "^7.1.6",
"solidity-coverage": "^0.7.16"
},
"devDependencies": {
"@eth-optimism/plugins": "^1.0.0-alpha.2",
......
......@@ -129,7 +129,7 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
)
})
describe('appendSequencerBatch', () => {
describe('appendSequencerBatch [ @skip-on-coverage ]', () => {
beforeEach(() => {
OVM_CanonicalTransactionChain = OVM_CanonicalTransactionChain.connect(
sequencer
......
......@@ -101,7 +101,7 @@ describe('OVM_ExecutionManager gas consumption', () => {
).connect(wallet)
})
describe('Measure cost of a very simple contract', async () => {
describe('Measure cost of a very simple contract [ @skip-on-coverage ]', async () => {
it('Gas cost of run', async () => {
const gasCost = await gasMeasurement.getGasCost(
OVM_ExecutionManager,
......
......@@ -21,7 +21,7 @@ const DUMMY_KEY = DUMMY_BYTES32[0]
const DUMMY_VALUE_1 = DUMMY_BYTES32[1]
const DUMMY_VALUE_2 = DUMMY_BYTES32[2]
describe('OVM_StateManager gas consumption', () => {
describe('OVM_StateManager gas consumption [ @skip-on-coverage ]', () => {
let owner: Signer
before(async () => {
;[owner] = await ethers.getSigners()
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment