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

feat: write instruction result when displaying call traces #7465

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading