Skip to content

Commit

Permalink
feat: write instruction result when displaying call traces (#7465)
Browse files Browse the repository at this point in the history
* feat: write instruction result when displaying call traces

* fix: new line, update tests

* space
  • Loading branch information
DaniPopes authored Mar 21, 2024
1 parent b342ff2 commit c2233ec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
30 changes: 14 additions & 16 deletions crates/evm/traces/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,21 @@ pub async fn render_trace_arena(

// Display trace return data
let color = trace_color(&node.trace);
write!(s, "{child}{EDGE}{}", color.paint(RETURN))?;
if node.trace.kind.is_any_create() {
match &return_data {
None => {
writeln!(s, "{} bytes of code", node.trace.output.len())?;
}
Some(val) => {
writeln!(s, "{val}")?;
}
write!(
s,
"{child}{EDGE}{}{}",
color.paint(RETURN),
color.paint(format!("[{:?}] ", node.trace.status))
)?;
match return_data {
Some(val) => write!(s, "{val}"),
None if node.trace.kind.is_any_create() => {
write!(s, "{} bytes of code", node.trace.output.len())
}
} else {
match &return_data {
None if node.trace.output.is_empty() => writeln!(s, "()")?,
None => writeln!(s, "{}", node.trace.output)?,
Some(val) => writeln!(s, "{val}")?,
}
}
None if node.trace.output.is_empty() => Ok(()),
None => write!(s, "{}", node.trace.output),
}?;
writeln!(s)?;

Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Ran 2 tests for test/Contract.t.sol:CustomTypesTest
[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 231)
Traces:
[231] CustomTypesTest::testErr()
└─ ← PoolNotInitialized()
└─ ← [Revert] PoolNotInitialized()

[PASS] testEvent() (gas: 1312)
Traces:
[1312] CustomTypesTest::testEvent()
├─ emit MyEvent(a: 100)
└─ ← ()
└─ ← [Stop]

Suite result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.88ms

Expand Down
6 changes: 3 additions & 3 deletions crates/forge/tests/fixtures/repro_6531.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Ran 1 test for test/Contract.t.sol:USDTCallingTest
Traces:
[9559] USDTCallingTest::test()
├─ [0] VM::createSelectFork("<url>")
│ └─ ← 0
│ └─ ← [Return] 0
├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall]
│ └─ ← "Tether USD"
└─ ← ()
│ └─ ← [Return] "Tether USD"
└─ ← [Stop]

Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.43s

Expand Down

0 comments on commit c2233ec

Please sign in to comment.