Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve vitest output #6786

Closed
wants to merge 25 commits into from

Conversation

jeluard
Copy link
Member

@jeluard jeluard commented May 15, 2024

Motivation

Current tests output can be quite verbose, and display interleaved console output.

Description

Default behavior is unchanged. 2 env variables allow to tweak vitest output:

  • TEST_COMPACT_OUTPUT to produce a basic tests summary
  • TEST_QUIET_CONSOLE to strip console output from tests summary

e.g. TEST_QUIET_CONSOLE=true TEST_COMPACT_OUTPUT=true yarn test:spec:mainnet will produce the following output:

 ✓ test/spec/presets/merkle.test.ts  (0 test)
 ✓ test/spec/presets/genesis.test.ts  (0 test)
 ✓ test/spec/presets/shuffling.test.ts  (300 tests) 565ms
 ✓ test/spec/presets/light_client/index.test.ts  (14 tests | 2 skipped) 4700ms
(node:55726) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
 ✓ test/spec/presets/fork.test.ts  (62 tests) 16235ms
 ✓ test/spec/presets/finality.test.ts  (30 tests) 21080ms
 ✓ test/spec/presets/rewards.test.ts  (219 tests) 26226ms
 ✓ test/spec/presets/fork_choice.test.ts  (117 tests | 2 skipped) 51488ms

 ✓ test/spec/presets/epoch_processing.test.ts  (453 tests | 6 skipped) 73137ms
 ❯ test/spec/presets/transition.test.ts  (178 tests | 3 failed) 80438ms
   ❯ test/spec/presets/transition.test.ts > electra/transition/core/pyspec_tests > electra/transition/core/pyspec_tests/transition_randomized_state
     → Invalid state root at slot 288, expected=0x708fd518df60ae030fecbaed6ef1668db0589de82e99700d25163fd8ffc9f131, actual=0x922edb35a7dd26410c63eb6548141dda28d522658f21988485eb86d451152fe4
   ❯ test/spec/presets/transition.test.ts > electra/transition/core/pyspec_tests > electra/transition/core/pyspec_tests/transition_with_deposit_right_before_fork
     → Invalid state root at slot 96, expected=0x5241d607d5383dd1daf9d059ca01506f1b80b837f85329fd6890a5612d22253d, actual=0xc474453d632eabffb5d408eaddf857918129b97e5bf40a7f4994bf8b04dc55fb
   ❯ test/spec/presets/transition.test.ts > electra/transition/core/pyspec_tests > electra/transition/core/pyspec_tests/transition_with_non_empty_activation_queue
     → Invalid state root at slot 96, expected=0xce646a5d98c6661bdd1c70634e1d2295449e3347b7915b6bb5ab3ac4e12ad4e7, actual=0x70461c653c78d1597687e396b0a7fbabcc45486044b34dc8f20520c964cd48f9
 ✓ test/spec/presets/ssz_static.test.ts  (1285 tests) 100868ms
 ✓ test/spec/presets/operations.test.ts  (1244 tests) 125409ms
 ✓ test/spec/presets/sanity.test.ts  (478 tests) 217204ms

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/spec/presets/transition.test.ts > electra/transition/core/pyspec_tests > electra/transition/core/pyspec_tests/transition_randomized_state
Error: Invalid state root at slot 288, expected=0x708fd518df60ae030fecbaed6ef1668db0589de82e99700d25163fd8ffc9f131, actual=0x922edb35a7dd26410c63eb6548141dda28d522658f21988485eb86d451152fe4
 ❯ Module.stateTransition ../state-transition/src/stateTransition.ts:126:13
 ❯ testFunction test/spec/presets/transition.test.ts:57:19
     55|         for (let i = 0; i < meta.blocks_count; i++) {
     56|           const signedBlock = testcase[`blocks_${i}`] as allForks.SignedBeaconBlock;
     57|           state = stateTransition(state, signedBlock, {
       |                   ^
     58|             // Assume valid and available for this test
     59|             executionPayloadStatus: ExecutionPayloadStatus.valid,
 ❯ ../spec-test-util/src/single.ts:138:32

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/3]⎯

 FAIL  test/spec/presets/transition.test.ts > electra/transition/core/pyspec_tests > electra/transition/core/pyspec_tests/transition_with_deposit_right_before_fork
Error: Invalid state root at slot 96, expected=0x5241d607d5383dd1daf9d059ca01506f1b80b837f85329fd6890a5612d22253d, actual=0xc474453d632eabffb5d408eaddf857918129b97e5bf40a7f4994bf8b04dc55fb
 ❯ Module.stateTransition ../state-transition/src/stateTransition.ts:126:13
 ❯ testFunction test/spec/presets/transition.test.ts:57:19
     55|         for (let i = 0; i < meta.blocks_count; i++) {
     56|           const signedBlock = testcase[`blocks_${i}`] as allForks.SignedBeaconBlock;
     57|           state = stateTransition(state, signedBlock, {
       |                   ^
     58|             // Assume valid and available for this test
     59|             executionPayloadStatus: ExecutionPayloadStatus.valid,
 ❯ ../spec-test-util/src/single.ts:138:32

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/3]⎯

 FAIL  test/spec/presets/transition.test.ts > electra/transition/core/pyspec_tests > electra/transition/core/pyspec_tests/transition_with_non_empty_activation_queue
Error: Invalid state root at slot 96, expected=0xce646a5d98c6661bdd1c70634e1d2295449e3347b7915b6bb5ab3ac4e12ad4e7, actual=0x70461c653c78d1597687e396b0a7fbabcc45486044b34dc8f20520c964cd48f9
 ❯ Module.stateTransition ../state-transition/src/stateTransition.ts:126:13
 ❯ testFunction test/spec/presets/transition.test.ts:57:19
     55|         for (let i = 0; i < meta.blocks_count; i++) {
     56|           const signedBlock = testcase[`blocks_${i}`] as allForks.SignedBeaconBlock;
     57|           state = stateTransition(state, signedBlock, {
       |                   ^
     58|             // Assume valid and available for this test
     59|             executionPayloadStatus: ExecutionPayloadStatus.valid,
 ❯ ../spec-test-util/src/single.ts:138:32

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/3]⎯

 Test Files  1 failed | 12 passed (13)
      Tests  3 failed | 4367 passed | 10 skipped (4380)
   Start at  20:50:50
   Duration  218.15s (transform 2.94s, setup 220ms, collect 9.30s, tests 717.35s, environment 1ms, prepare 557ms)

@jeluard jeluard requested a review from a team as a code owner May 15, 2024 15:48
@jeluard jeluard requested a review from nazarhussain May 15, 2024 15:48
Copy link

codecov bot commented May 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.20%. Comparing base (c39b914) to head (7855122).
Report is 22 commits behind head on unstable.

Current head 7855122 differs from pull request most recent head d84bcf4

Please upload reports for the commit d84bcf4 to get more accurate results.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #6786      +/-   ##
============================================
+ Coverage     61.88%   62.20%   +0.32%     
============================================
  Files           562      571       +9     
  Lines         59331    60015     +684     
  Branches       1916     1976      +60     
============================================
+ Hits          36715    37335     +620     
- Misses        22573    22637      +64     
  Partials         43       43              

@@ -20,7 +20,7 @@ export default defineConfig({
],
reporters: process.env.GITHUB_ACTIONS
? ["verbose", "hanging-process", "github-actions"]
: ["verbose", "hanging-process"],
: [process.env.TEST_COMPACT_OUTPUT === "true" ? "basic" : "verbose", "hanging-process"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a more consistent approach on how we check env variables, something we check strictly for "true" and other times we just check if the env variable is set

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Any preference?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no hard opinion about it but what ever we do should do consistently. And if that rule can be enforced by linter then let it be individual choice.

vitest.base.unit.config.ts Outdated Show resolved Hide resolved
@@ -42,5 +42,6 @@ export default defineConfig({
],
},
diff: process.env.TEST_COMPACT_DIFF ? path.join(import.meta.dirname, "./scripts/vitest/vitest.diff.ts") : undefined,
onConsoleLog: () => process.env.TEST_QUIET_CONSOLE !== "true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be expensive check, as for every log message this function will be called. Not fully against it, but we should document somewhere that it's a expensive.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be neglectable compared to the cost of logging a line to the console. I haven't notices any slowdown.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be checking against "true" here

Co-authored-by: Nazar Hussain <nazarhussain@gmail.com>
| ENV variable | Effect | Impact |
| ------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------- |
| TEST_COMPACT_DIFF | All | Will strip down the object difference rendered during test failures. Very useful for large object matching. |
| TEST_QUIET_CONSOLE | All | Will strip down console output. Reduce console flickering. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you mean by "strip down" here? doesn't this disable console logging if set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still the vitest output, this disables lodestar console output. Open to description clarifications.

@@ -42,5 +42,6 @@ export default defineConfig({
],
},
diff: process.env.TEST_COMPACT_DIFF ? path.join(import.meta.dirname, "./scripts/vitest/vitest.diff.ts") : undefined,
onConsoleLog: () => process.env.TEST_QUIET_CONSOLE !== "true",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be checking against "true" here

jeluard and others added 21 commits June 4, 2024 12:29
* chore: upgrade classic-level

* chore: address comments
…ainSafe#6727)

* Restructure the assertions

* Add an inspector to run the logic to detect providers

* Update web3 provdier logic to use inspetor

* Fix the types for proxy

* Make the default type for mutation

* Rename elrpc to elrpcprovider

* Apply suggestions from code review

Co-authored-by: Julien <jeluard@users.noreply.github.com>

* Fix build error

* Update the readme doc

* Apply suggestions from code review

Co-authored-by: Julien <jeluard@users.noreply.github.com>

* Fix the docs linting

* Add missing words

---------

Co-authored-by: Julien <jeluard@users.noreply.github.com>
* docs: added debugging section

* chore: spell checks

* chore: added extra docs

* chore: address comments

* chore: added extra configuration

* chore: updated docs

* chore: added extra configuration

* chore: fix lint

* chore: fix typos

* chore: .gitignore

* chore: address comments

* chore: address comments
* Rename simulation test to crucible

* Rename SimulationEnvironment to Simulation

* Use consistent function names

* Update readme

* Rename interfaces for consistent pattern

* Fix lint error
* Add grandine

* add grandine to wordlist
* chore: refactor sleep(0) usage

* chore: refactor setTimeout

* chore: address comments

* chore: cleanup

* Apply suggestions from code review

---------

Co-authored-by: Cayman <caymannava@gmail.com>
* chore: do not rely on leveldown

* chore: replace level with classic-level
* chore: added docker support for osx

* chore: address comments

* chore: address comments

* Update docker-compose.yml

Co-authored-by: Nico Flaig <nflaig@protonmail.com>

* chore: address comments

---------

Co-authored-by: Nico Flaig <nflaig@protonmail.com>
* feat: use @chainsafe/blst directly

* chore: update to blst@1.0.1

* refactor: remove randomBytesNonZero and user blst exported version

* chore: update blst references

* test: catch invalid deserialization in spec tests and return false

* feat: create signatureFromBytes and signatureFromBytesNoCheck in utils package

* feat: implement signatureFromBytes from utils package

* feat: implement signatureFromBytes everywhere

* fix: light-client empty module for blst

---------

Co-authored-by: matthewkeil <me@matthewkeil.com>
* fix: avoid Buffer.from copies

* chore: simplify shuffling

* fix: use subarray instead of slice in shuffling

* chore: remove unnecessary devDependencies

* chore: rely on fastify 4.x behavior

* chore: avoid copy in verifyMerkleBranch

* use toBase64

* relax assertions in shuffle function

* Update packages/state-transition/src/util/shuffle.ts

Co-authored-by: twoeths <tuyen@chainsafe.io>

---------

Co-authored-by: twoeths <tuyen@chainsafe.io>
* Upgrade node js version to 22

* Update node types

* Revert action config

* Add package from git hash

* Fix the build error

* Update the docs for node-22

* Update docker version for Nodejs to 22

* Update package.json

* Update package.json

Co-authored-by: Nico Flaig <nflaig@protonmail.com>

* Update readme docs

* Add word in dictionary

* Add word in dictionary

---------

Co-authored-by: Cayman <caymannava@gmail.com>
Co-authored-by: Nico Flaig <nflaig@protonmail.com>
* test: increase timeout of keystore cache tests

* Increase hook timeout

* Consistent number formatting
@jeluard jeluard closed this Jun 4, 2024
@jeluard
Copy link
Member Author

jeluard commented Jun 4, 2024

Replaced by #6850

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants