From 6231d8a35ff50bbaa7c4afddc88b89a8d7bc777b Mon Sep 17 00:00:00 2001 From: jsvisa Date: Tue, 24 Sep 2024 19:48:49 +0800 Subject: [PATCH] add testcase Signed-off-by: jsvisa --- tests/it/geth.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/it/geth.rs b/tests/it/geth.rs index eaa3e730..5ecd3651 100644 --- a/tests/it/geth.rs +++ b/tests/it/geth.rs @@ -14,7 +14,9 @@ use revm::{ }, DatabaseCommit, }; -use revm_inspectors::tracing::{MuxInspector, TracingInspector, TracingInspectorConfig}; +use revm_inspectors::tracing::{ + js::JsInspector, MuxInspector, TracingInspector, TracingInspectorConfig, +}; #[test] fn test_geth_calltracer_logs() { @@ -106,23 +108,28 @@ fn test_geth_calltracer_logs() { .geth_builder() .geth_call_traces(CallConfig::default().with_log(), res.result.gas_used()); - // three subcalls + // top-level call succeeded, no log and three subcalls assert_eq!(call_frame.calls.len(), 3); - - // top-level call emitted one log assert_eq!(call_frame.logs.len(), 1); + assert!(call_frame.error.is_none()); - // first call failed, no logs + // first subcall failed, and no logs assert!(call_frame.calls[0].logs.is_empty()); + assert!(call_frame.calls[0].error.is_some()); - // second call failed, with a two nested subcalls that emitted logs, but none should be included + // second subcall failed, with a two nested subcalls that emitted logs, but none should be + // included assert_eq!(call_frame.calls[1].calls.len(), 1); assert!(call_frame.calls[1].logs.is_empty()); + assert!(call_frame.calls[1].error.is_some()); assert!(call_frame.calls[1].calls[0].logs.is_empty()); + assert!(call_frame.calls[1].calls[0].error.is_none()); assert!(call_frame.calls[1].calls[0].calls[0].logs.is_empty()); + assert!(call_frame.calls[1].calls[0].calls[0].error.is_none()); - // third call succeeded, one log + // third subcall succeeded, one log assert_eq!(call_frame.calls[2].logs.len(), 1); + assert!(call_frame.calls[2].error.is_none()); } #[test] @@ -423,11 +430,9 @@ fn test_geth_jstracer_op_gascost() { ); let mut insp = JsInspector::new(code.to_string(), serde_json::Value::Null).unwrap(); let (res, _) = inspect(&mut db, env.clone(), &mut insp).unwrap(); - println!("result: {:?}", res); assert!(res.result.is_success()); let result = insp.json_result(res, &env, &db).unwrap(); - println!("result: {}", result.to_string()); assert!(!result["error"].as_bool().unwrap()); assert_eq!(