Skip to content

Commit

Permalink
Switch c8 to @vitest/coverage-v8 (#3845)
Browse files Browse the repository at this point in the history
* switch c8 to `@vitest/coverage-v8`

* Fix some client coverage issues

* fix timeouts

* skip coverage config

* Remove unused scripts and turn on lcov

* fix config

* Skip cli tests

---------

Co-authored-by: Jochem Brouwer <[email protected]>
  • Loading branch information
acolytec3 and jochem-brouwer authored Jan 24, 2025
1 parent 2b44dff commit 60ed998
Show file tree
Hide file tree
Showing 28 changed files with 80 additions and 190 deletions.
1 change: 1 addition & 0 deletions config/eslint.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'vitest.config.ts',
'vitest.config.browser.ts',
'vitest.config.unit.ts',
'vitest.config.coverage.ts',
'vite.*.ts',
'ethereum-tests',
'archive',
Expand Down
18 changes: 18 additions & 0 deletions config/vitest.config.coverage.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from 'vitest/config'

const config = defineConfig({
test: {
silent: true,
testTimeout: 180000,
coverage: {
provider: 'v8',
enabled: true,
all: true,
},
},
optimizeDeps: {
exclude: ['kzg-wasm'],
},
})

export default config
165 changes: 1 addition & 164 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
"@types/tape": "4.13.2",
"@typescript-eslint/eslint-plugin": "5.33.1",
"@typescript-eslint/parser": "5.33.1",
"@vitest/coverage-v8": "3.0.2",
"@vitest/coverage-v8": "^3.0.2",
"@vitest/ui": "3.0.2",
"c8": "7.12.0",
"cspell": "^8.13.3",
"embedme": "1.22.1",
"eslint": "8.57.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "DEBUG=ethjs npx vitest run --coverage.enabled --coverage.reporter=lcov",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"docs:build": "typedoc --options typedoc.cjs",
"examples": "tsx ../../scripts/examples-runner.ts -- block",
"examples:build": "npx embedme README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "DEBUG=ethjs npx vitest run --coverage.enabled --coverage.reporter=lcov",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"docs:build": "typedoc --options typedoc.cjs",
"examples": "tsx ../../scripts/examples-runner.ts -- blockchain",
"examples:build": "npx embedme README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"client:start": "npm run client:start:js --",
"client:start:dev1": "npm run client:start -- --discDns=false --discV4=false --bootnodes",
"client:start:dev2": "npm run client:start -- --discDns=false --discV4=false --port=30304 --dataDir=datadir-dev2",
"coverage": "npx vitest --coverage --coverage.include=src --coverage.reporter=lcov run test/* -c=./vitest.config.unit.ts",
"coverage": "DEBUG=ethjs npx vitest run -c ./vitest.config.coverage.ts",
"docs:build": "typedoc --options typedoc.cjs --tsconfig tsconfig.prod.cjs.json",
"examples": "tsx ../../scripts/examples-runner.ts -- client",
"lint": "npm run biome && eslint --config .eslintrc.cjs . --ext .js,.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/execution/vmexecution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,4 @@ describe('[VMExecution]', () => {

closeRPC(server)
})
}, 30000)
})
2 changes: 1 addition & 1 deletion packages/client/test/rpc/debug/setHead.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe(method, async () => {
`vm execution should set hash to new head`,
)
}
}, 30000)
})

it('should return error for pending block', async () => {
const blockchain = await createBlockchainFromBlocksData(mainnetData, {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/rpc/eth/estimateGas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ describe(method, () => {
assert.equal(res.error.code, INVALID_PARAMS)
assert.ok(res.error.message.includes('"pending" is not yet supported'))
})
}, 20000)
})
2 changes: 1 addition & 1 deletion packages/client/test/rpc/eth/getBalance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ describe(method, () => {
assert.equal(res.error.code, INVALID_PARAMS)
assert.ok(res.error.message.includes('"pending" is not yet supported'))
})
}, 40000)
})
4 changes: 2 additions & 2 deletions packages/client/test/rpc/eth/getTransactionCount.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe(method, () => {
// call with nonexistent account
res = await rpc.request(method, [`0x${'11'.repeat(20)}`, 'latest'])
assert.equal(res.result, `0x0`, 'should return 0x0 for nonexistent account')
}, 40000)
})

it('call with pending block argument', async () => {
const blockchain = await createBlockchain()
Expand Down Expand Up @@ -109,5 +109,5 @@ describe(method, () => {

const res = await rpc.request(method, [address.toString(), 'pending'])
assert.equal(res.result, '0x1')
}, 40000)
})
})
19 changes: 19 additions & 0 deletions packages/client/vitest.config.coverage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
silent: true,
exclude: ['test/integration', 'test/sim', 'test/cli/*.spec.ts', 'test/logging.spec.ts'],
testTimeout: 300000,
alias: { '@polkadot/util': 'false' },
typecheck: {
tsconfig: './tsconfig.prod.esm.json',
},
coverage: {
provider: 'v8',
enabled: true,
all: true,
reporter: ['lcov'],
},
},
})
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "DEBUG=ethjs npx vitest run --coverage.enabled --coverage.reporter=lcov",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"docs:build": "typedoc --options typedoc.cjs",
"examples": "tsx ../../scripts/examples-runner.ts -- common",
"examples:build": "npx embedme README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/devp2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "DEBUG=ethjs npx vitest run --coverage.enabled --coverage.reporter=lcov",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"docs:build": "typedoc --options typedoc.cjs",
"examples": "tsx ../../scripts/examples-runner.ts -- devp2p",
"examples:build": "npx embedme README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/ethash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "npx vitest --coverage --coverage.include=src --coverage.reporter=lcov run test/*",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"docs:build": "typedoc --options typedoc.cjs",
"examples": "tsx ../../scripts/examples-runner.ts -- ethash",
"examples:build": "npx embedme README.md",
Expand Down
3 changes: 1 addition & 2 deletions packages/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "DEBUG=ethjs npx vitest run --coverage.enabled --coverage.reporter=lcov",
"coverage:test": "npm run test:node && cd ../vm && npm run tester -- --state",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"docs:build": "typedoc --options typedoc.cjs",
"examples": "tsx ../../scripts/examples-runner.ts -- evm",
"examples:build": "npx embedme README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/genesis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "DEBUG=ethjs npx vitest run --coverage.enabled --coverage.reporter=lcov",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"examples": "tsx ../../scripts/examples-runner.ts -- genesis",
"examples:build": "npx embedme README.md",
"docs:build": "typedoc --options typedoc.cjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/mpt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "DEBUG=ethjs npx vitest run --coverage.enabled --coverage.reporter=lcov",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"docs:build": "typedoc --options typedoc.cjs",
"examples": "tsx ../../scripts/examples-runner.ts -- mpt",
"examples:build": "npx embedme README.md",
Expand Down
Loading

0 comments on commit 60ed998

Please sign in to comment.