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

bug: traces field is missing when display option --json is set #6922

Closed
2 tasks done
Tracked by #8794
t4sk opened this issue Jan 27, 2024 · 4 comments · Fixed by #9034
Closed
2 tasks done
Tracked by #8794

bug: traces field is missing when display option --json is set #6922

t4sk opened this issue Jan 27, 2024 · 4 comments · Fixed by #9034
Labels
A-tracing Area: tracing C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug T-to-investigate Type: to investigate
Milestone

Comments

@t4sk
Copy link

t4sk commented Jan 27, 2024

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 (1839c72 2024-01-27T14:45:19.822383666Z)

What command(s) is the bug in?

forge test -vvvv --json

Operating System

Linux

Describe the bug

forge test -vvvv prints the traces but forge test -vvvv --json does not.

Setup

forge init

Commands

forge test -vvvv

Output

[PASS] test_Increment() (gas: 28379)
Traces:
  [28379] CounterTest::test_Increment()
    ├─ [22340] Counter::increment()
    │   └─  ()
    ├─ [283] Counter::number() [staticcall]
    │   └─ ← 1
    └─  ()

Here is the same command with --json. Traces are missing from the output

forge test -vvvv --json | jq
{
  "test/Counter.t.sol:CounterTest": {
    "duration": {
      "secs": 0,
      "nanos": 13219812
    },
    "test_results": {
      "testFuzz_SetNumber(uint256)": {
        "status": "Success",
        "reason": null,
        "counterexample": null,
        "logs": [],
        "decoded_logs": [],
        "kind": {
          "Fuzz": {
            "first_case": {
              "calldata": "0x5c7f60d70000000000000000000000000000000000000000000000000000000000000cdd",
              "gas": 49625,
              "stipend": 21216
            },
            "runs": 256,
            "mean_gas": 27709,
            "median_gas": 28409
          }
        },
        "labeled_addresses": {},
        "debug": null,
        "breakpoints": {}
      },
      "test_Increment()": {
        "status": "Success",
        "reason": null,
        "counterexample": null,
        "logs": [],
        "decoded_logs": [],
        "kind": {
          "Standard": 28379
        },
        "labeled_addresses": {},
        "debug": null,
        "breakpoints": {}
      }
    },
    "warnings": []
  }
}

Is this a bug? If not how can I get the traces like in the older version?

@t4sk t4sk added the T-bug Type: bug label Jan 27, 2024
@gakonst gakonst added this to Foundry Jan 27, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Jan 27, 2024
@DaniPopes
Copy link
Member

cc @onbjerg is this a consequence of the tracing refactor?

@onbjerg
Copy link
Member

onbjerg commented Feb 5, 2024

No this is a consequence of the Alloy port, some types are not ser/de

@DaniPopes
Copy link
Member

DaniPopes commented Feb 19, 2024

Should be fixed with next revm + evm-inspectors update: paradigmxyz/revm-inspectors#47

@zerosnacks
Copy link
Member

zerosnacks commented Jul 10, 2024

Re-running with given setup now yields:

forge test -vvvv
[⠊] Compiling...
[⠢] Compiling 25 files with Solc 0.8.26
[⠰] Solc 0.8.26 finished in 1.16s
Compiler run successful!

Ran 2 tests for test/Counter.t.sol:CounterTest
[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 30977, ~: 31288)
Traces:
  [31288] CounterTest::testFuzz_SetNumber(516)
    ├─ [22290] Counter::setNumber(516)
    │   └─ ← [Stop] 
    ├─ [283] Counter::number() [staticcall]
    │   └─ ← [Return] 516
    ├─ [0] VM::assertEq(516, 516) [staticcall]
    │   └─ ← [Return] 
    └─ ← [Stop] 

[PASS] test_Increment() (gas: 31303)
Traces:
  [31303] CounterTest::test_Increment()
    ├─ [22340] Counter::increment()
    │   └─ ← [Stop] 
    ├─ [283] Counter::number() [staticcall]
    │   └─ ← [Return] 1
    ├─ [0] VM::assertEq(1, 1) [staticcall]
    │   └─ ← [Return] 
    └─ ← [Stop] 

Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 7.51ms (7.06ms CPU time)
{
  "test/Counter.t.sol:CounterTest": {
    "duration": "6ms 584us 664ns",
    "test_results": {
      "testFuzz_SetNumber(uint256)": {
        "status": "Success",
        "reason": null,
        "counterexample": null,
        "logs": [],
        "kind": {
          "Fuzz": {
            "first_case": {
              "calldata": "0x5c7f60d700000000000000000000000000000000000000cc8edadd275ec2b562a63dee4b",
              "gas": 52636,
              "stipend": 21348
            },
            "runs": 256,
            "mean_gas": 31054,
            "median_gas": 31288
          }
        },
        "labeled_addresses": {},
        "duration": {
          "secs": 0,
          "nanos": 6174286
        },
        "breakpoints": {}
      },
      "test_Increment()": {
        "status": "Success",
        "reason": null,
        "counterexample": null,
        "logs": [],
        "kind": {
          "Unit": {
            "gas": 31303
          }
        },
        "labeled_addresses": {},
        "duration": {
          "secs": 0,
          "nanos": 181373
        },
        "breakpoints": {}
      }
    },
    "warnings": []
  }
}

I think this is still an issue

@zerosnacks zerosnacks added Cmd-forge-test Command: forge test C-forge Command: forge A-tracing Area: tracing labels Jul 10, 2024
@zerosnacks zerosnacks changed the title Traces missing when display option --json is set bug: traces field is missing when display option --json is set Jul 10, 2024
@zerosnacks zerosnacks added the T-to-investigate Type: to investigate label Jul 10, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@zerosnacks zerosnacks moved this from Todo to Ready For Review in Foundry Oct 4, 2024
@github-project-automation github-project-automation bot moved this from Ready For Review to Done in Foundry Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tracing Area: tracing C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug T-to-investigate Type: to investigate
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants