Skip to content

Commit

Permalink
feat: tweak write_bytecodes output (#217)
Browse files Browse the repository at this point in the history
Use hex as everywhere else, show return code as if normal return value
without the "x bytes of code"
  • Loading branch information
DaniPopes authored Oct 5, 2024
1 parent 34f8b07 commit dbc58f1
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 23 deletions.
7 changes: 2 additions & 5 deletions src/tracing/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl<W: Write> TraceWriter<W> {
label = trace.decoded.label.as_deref().unwrap_or("<unknown>")
)?;
if self.config.write_bytecodes {
write!(self.writer, "({})", hex::encode(&trace.data))?;
write!(self.writer, "({})", trace.data)?;
}
} else {
let (func_name, inputs) = match &trace.decoded.call_data {
Expand Down Expand Up @@ -399,11 +399,8 @@ impl<W: Write> TraceWriter<W> {
return self.writer.write_all(decoded.as_bytes());
}

if trace.kind.is_any_create() && trace.status.is_ok() {
if !self.config.write_bytecodes && (trace.kind.is_any_create() && trace.status.is_ok()) {
write!(self.writer, "{} bytes of code", trace.output.len())?;
if self.config.write_bytecodes {
write!(self.writer, " ({})", hex::encode(&trace.output))?;
}
} else if !trace.output.is_empty() {
write!(self.writer, "{}", trace.output)?;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/it/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn test_trace_printing() {

let mut evm = TestEvm::new();

let mut tracer = TracingInspector::new(TracingInspectorConfig::all().disable_steps());
let mut tracer = TracingInspector::new(TracingInspectorConfig::all());
let address = evm.deploy(CREATION_CODE.parse().unwrap(), &mut tracer).unwrap();

let mut index = 0;
Expand Down Expand Up @@ -69,7 +69,7 @@ fn deploy_fail() {
let base_path = &Path::new(OUT_DIR).join("deploy_fail");

let mut evm = TestEvm::new();
let mut tracer = TracingInspector::new(TracingInspectorConfig::all().disable_steps());
let mut tracer = TracingInspector::new(TracingInspectorConfig::all());
let _ = evm.try_deploy(bytes!("604260005260206000fd"), &mut tracer).unwrap();

assert_traces(base_path, Some("raw"), None, true, &mut tracer);
Expand Down
4 changes: 2 additions & 2 deletions tests/it/writer/deploy_fail/decoded.write_bytecodes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/it/writer/deploy_fail/decoded.write_bytecodes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[18] → new RevertingConstructor@0xBd770416a3345F91E4B34576cb804a576fa48EB1(604260005260206000fd)
[18] → new RevertingConstructor@0xBd770416a3345F91E4B34576cb804a576fa48EB1(0x604260005260206000fd)
└─ ← [Revert] 42
4 changes: 2 additions & 2 deletions tests/it/writer/deploy_fail/raw.write_bytecodes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/it/writer/deploy_fail/raw.write_bytecodes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[18] → new <unknown>@0xBd770416a3345F91E4B34576cb804a576fa48EB1(604260005260206000fd)
[18] → new <unknown>@0xBd770416a3345F91E4B34576cb804a576fa48EB1(0x604260005260206000fd)
└─ ← [Revert] 0x0000000000000000000000000000000000000000000000000000000000000042
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit dbc58f1

Please sign in to comment.