diff --git a/crates/rpc/rpc-testing-util/src/debug.rs b/crates/rpc/rpc-testing-util/src/debug.rs index cc9111821657..14a6b86908b9 100644 --- a/crates/rpc/rpc-testing-util/src/debug.rs +++ b/crates/rpc/rpc-testing-util/src/debug.rs @@ -4,12 +4,14 @@ use futures::{Stream, StreamExt}; use jsonrpsee::core::Error as RpcError; use reth_primitives::{BlockId, TxHash, B256}; use reth_rpc_api::{clients::DebugApiClient, EthApiClient}; -use reth_rpc_types::trace::geth::{GethDebugTracerType, GethDebugTracingOptions}; +use reth_rpc_types::{ + trace::geth::{GethDebugTracerType, GethDebugTracingOptions}, + CallRequest, +}; use std::{ pin::Pin, task::{Context, Poll}, }; - const NOOP_TRACER: &str = include_str!("../assets/noop-tracer.js"); const JS_TRACER_TEMPLATE: &str = include_str!("../assets/tracer-template.js"); @@ -37,6 +39,19 @@ pub trait DebugApiExt { ) -> Result, jsonrpsee::core::Error> where B: Into + Send; + /// method for debug_traceCall + async fn debug_trace_call_json( + &self, + request: CallRequest, + opts: GethDebugTracingOptions, + ) -> Result; + + /// method for debug_traceCall using raw JSON strings for the request and options. + async fn debug_trace_call_raw_json( + &self, + request_json: String, + opts_json: String, + ) -> Result; } #[async_trait::async_trait] @@ -81,6 +96,29 @@ where Ok(DebugTraceTransactionsStream { stream: Box::pin(stream) }) } + async fn debug_trace_call_json( + &self, + request: CallRequest, + opts: GethDebugTracingOptions, + ) -> Result { + let mut params = jsonrpsee::core::params::ArrayParams::new(); + params.insert(request).unwrap(); + params.insert(opts).unwrap(); + self.request("debug_traceCall", params).await + } + + async fn debug_trace_call_raw_json( + &self, + request_json: String, + opts_json: String, + ) -> Result { + let request = serde_json::from_str::(&request_json) + .map_err(|e| RpcError::Custom(e.to_string()))?; + let opts = serde_json::from_str::(&opts_json) + .map_err(|e| RpcError::Custom(e.to_string()))?; + + self.debug_trace_call_json(request, opts).await + } } /// A helper type that can be used to build a javascript tracer.