From dbc58f161489f50188c4e67706aaaf0abf6a461d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 5 Oct 2024 05:36:16 +0200 Subject: [PATCH] feat: tweak write_bytecodes output (#217) Use hex as everywhere else, show return code as if normal return value without the "x bytes of code" --- src/tracing/writer.rs | 7 ++----- tests/it/writer.rs | 4 ++-- tests/it/writer/deploy_fail/decoded.write_bytecodes.svg | 4 ++-- tests/it/writer/deploy_fail/decoded.write_bytecodes.txt | 2 +- tests/it/writer/deploy_fail/raw.write_bytecodes.svg | 4 ++-- tests/it/writer/deploy_fail/raw.write_bytecodes.txt | 2 +- .../test_trace_printing/0.write_bytecodes.decoded.svg | 6 +++--- .../test_trace_printing/0.write_bytecodes.decoded.txt | 4 ++-- tests/it/writer/test_trace_printing/0.write_bytecodes.svg | 6 +++--- tests/it/writer/test_trace_printing/0.write_bytecodes.txt | 4 ++-- 10 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/tracing/writer.rs b/src/tracing/writer.rs index 23ca1747..9b721825 100644 --- a/src/tracing/writer.rs +++ b/src/tracing/writer.rs @@ -242,7 +242,7 @@ impl TraceWriter { label = trace.decoded.label.as_deref().unwrap_or("") )?; 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 { @@ -399,11 +399,8 @@ impl TraceWriter { 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)?; } diff --git a/tests/it/writer.rs b/tests/it/writer.rs index d19c6215..37bccb3b 100644 --- a/tests/it/writer.rs +++ b/tests/it/writer.rs @@ -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; @@ -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); diff --git a/tests/it/writer/deploy_fail/decoded.write_bytecodes.svg b/tests/it/writer/deploy_fail/decoded.write_bytecodes.svg index 79e6d0cb..c688d96b 100644 --- a/tests/it/writer/deploy_fail/decoded.write_bytecodes.svg +++ b/tests/it/writer/deploy_fail/decoded.write_bytecodes.svg @@ -1,4 +1,4 @@ - +