foundry: Fuzz testing only catches console.log in `setUp()` and in failing test functions, not passing functions

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (2e99f7f 2022-12-03T00:08:28.619060629Z)

What command(s) is the bug in?

forge test

Operating System

Linux

Describe the bug

Similar to issue #655, which was closed as stale (creating a new issue since there have been changes since that issue, and mine may be subtly different).

Only console logs in failing functions and setUp() are showing in the Logs section of the results, above the traces, but not the logs in passing functions. I can see the other calls to console::log in the traces, but they’re not getting formatted.

Running 1 test for src/test/compound/Comptroller-fork-diff.sol:TestComptroller
[PASS] test_claimComp_diff_before_after(uint8) (runs: 1, μ: 2924860, ~: 2924860)
Logs:
  Number of addresses: 74

Traces:
  [4852548] TestComptroller::setUp() 
    ├─ [0] console::log(Number of addresses: %s, 74) [staticcall]
    │   └─ ← ()
...
  [2924860] TestComptroller::test_claimComp_diff_before_after(5) 
    ├─ [0] console::log(Address %s, 0x000008599eB841e58b3e13305Da3dA5df5Ed8fFD) [staticcall]
    │   └─ ← ()

This would be fine if I were only trying to do one run, but since I’m fuzzing, I’d like to see all of the logs without printing all of the traces.

I have added a minimized test contract in my repo for reproducing this bug: https://github.com/webthethird/solidity-diff-fuzz-upgrades/blob/main/src/test/test_logging.sol

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 7
  • Comments: 16 (1 by maintainers)

Most upvoted comments

even though just fixing it could make everyone’s CI or local runs extremely noisy as a default

We already would show the logs if it was a regular test and not a fuzz test, so I think this is ok? Unclear why we’d want to handle the console.logs differently between the two, it seems unintuitive. To hide the logs you’d just run with -v as the verbosity

+1 to this

Bump to this, also looking to get output on each fuzz test, not just the failing ones