Skip to content

Commit

Permalink
add testcase
Browse files Browse the repository at this point in the history
Signed-off-by: jsvisa <[email protected]>
  • Loading branch information
jsvisa committed Oct 7, 2024
1 parent a6d51d3 commit 6231d8a
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tests/it/geth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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!(
Expand Down

0 comments on commit 6231d8a

Please sign in to comment.