Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
fix: add missing null check (paradigmxyz#3766)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored and merklefruit committed Jul 27, 2023
1 parent a81b444 commit b1c5b68
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 b1c5b68

Please sign in to comment.