Skip to content

Commit

Permalink
fix: add missing null check (#3766)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jul 14, 2023
1 parent e3ac77a commit 3b16a6b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/rpc/rpc-types/src/eth/trace/geth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ impl GethDebugTracerConfig {

/// Returns the [CallConfig] if it is a call config.
pub fn into_call_config(self) -> Result<CallConfig, serde_json::Error> {
if self.0.is_null() {
return Ok(Default::default())
}
self.from_value()
}

Expand All @@ -219,6 +222,9 @@ impl GethDebugTracerConfig {

/// Returns the [PreStateConfig] if it is a call config.
pub fn into_pre_state_config(self) -> Result<PreStateConfig, serde_json::Error> {
if self.0.is_null() {
return Ok(Default::default())
}
self.from_value()
}
}
Expand Down Expand Up @@ -370,6 +376,18 @@ fn serialize_string_storage_map_opt<S: Serializer>(
mod tests {
use super::*;

#[test]
fn test_tracer_config() {
let s = "{\"tracer\": \"callTracer\"}";
let opts = serde_json::from_str::<GethDebugTracingOptions>(s).unwrap();
assert_eq!(
opts.tracer,
Some(GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::CallTracer))
);
let _call_config = opts.tracer_config.clone().into_call_config().unwrap();
let _prestate_config = opts.tracer_config.into_pre_state_config().unwrap();
}

#[test]
fn test_memory_capture() {
let mut config = GethDefaultTracingOptions::default();
Expand Down

0 comments on commit 3b16a6b

Please sign in to comment.