From ad8e962a65aa2a6ec6f2b4830f5eeebd84dce888 Mon Sep 17 00:00:00 2001 From: Navie Date: Sat, 11 Feb 2023 13:37:44 +0800 Subject: [PATCH 1/9] Initial commit --- crates/rpc/rpc-builder/tests/it/http.rs | 40 ++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index e00324732e09..8374a4e35f85 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -3,7 +3,7 @@ use crate::utils::{launch_http, launch_http_ws, launch_ws}; use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; use reth_primitives::NodeRecord; -use reth_rpc_api::clients::AdminApiClient; +use reth_rpc_api::{clients::AdminApiClient, EthApiClient}; use reth_rpc_builder::RethRpcModule; async fn test_basic_admin_calls(client: &C) @@ -20,6 +20,17 @@ where AdminApiClient::node_info(client).await.unwrap(); } +async fn test_basic_eth_calls(client: &C) +where C: ClientT + SubscriptionClientT + Sync { + + EthApiClient::protocol_version(client).await.unwrap(); + EthApiClient::syncing(client).await.unwrap(); + EthApiClient::author(client).await.unwrap(); + panic!(); + +} + + #[tokio::test(flavor = "multi_thread")] async fn test_call_admin_functions_http() { reth_tracing::init_test_tracing(); @@ -46,3 +57,30 @@ async fn test_call_admin_functions_http_and_ws() { let client = handle.http_client().unwrap(); test_basic_admin_calls(&client).await; } + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_eth_functions_http() { + reth_tracing::init_test_tracing(); + + let handle = launch_http(vec![RethRpcModule::Eth]).await; + let client = handle.http_client().unwrap(); + test_basic_eth_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_eth_functions_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_ws(vec![RethRpcModule::Eth]).await; + let client = handle.ws_client().await.unwrap(); + test_basic_eth_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_eth_functions_http_and_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_http_ws(vec![RethRpcModule::Eth]).await; + let client = handle.http_client().unwrap(); + test_basic_eth_calls(&client).await; +} \ No newline at end of file From a681bdff95bddfb97c1ed1ec03b1e4b90e080692 Mon Sep 17 00:00:00 2001 From: navie Date: Sat, 11 Feb 2023 20:06:45 +0800 Subject: [PATCH 2/9] Added partial ETH tests --- crates/rpc/rpc-builder/tests/it/http.rs | 61 +++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index 8374a4e35f85..b8dc66c2316c 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -2,9 +2,20 @@ use crate::utils::{launch_http, launch_http_ws, launch_ws}; use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; -use reth_primitives::NodeRecord; +use reth_primitives::{NodeRecord, H256, BlockNumber, U256, H64}; use reth_rpc_api::{clients::AdminApiClient, EthApiClient}; use reth_rpc_builder::RethRpcModule; +use jsonrpsee::core::error::Error; +use jsonrpsee::types::error::{CallError, ErrorCode}; + +fn is_unimplemented(err: Error) -> bool { + match err { + Error::Call(CallError::Custom(error_obj)) => { + error_obj.code() == ErrorCode::InternalError.code() && error_obj.message() == "unimplemented" + } + _ => return false, + } +} async fn test_basic_admin_calls(client: &C) where @@ -23,10 +34,50 @@ where async fn test_basic_eth_calls(client: &C) where C: ClientT + SubscriptionClientT + Sync { + // Implemented EthApiClient::protocol_version(client).await.unwrap(); - EthApiClient::syncing(client).await.unwrap(); - EthApiClient::author(client).await.unwrap(); - panic!(); + EthApiClient::chain_id(client).await.unwrap(); + EthApiClient::chain_id(client).await.unwrap(); + EthApiClient::accounts(client).await.unwrap(); + EthApiClient::block_number(client).await.unwrap(); + + + // Unimplemented + assert!(is_unimplemented(EthApiClient::syncing(client).await.err().unwrap())); + EthApiClient::author(client).await.unwrap_err(); + EthApiClient::block_by_hash(client, H256::default(), false).await.unwrap_err(); + EthApiClient::block_by_number(client, BlockNumber::default(), false).await.unwrap_err(); + EthApiClient::block_transaction_count_by_hash(client, H256::default()).await.unwrap_err(); + EthApiClient::block_transaction_count_by_number(client, BlockNumber::default()).await.unwrap_err(); + EthApiClient::block_uncles_count_by_hash(client, H256::default()).await.unwrap_err(); + EthApiClient::block_uncles_count_by_number(client, BlockNumber::default()).await.unwrap_err(); + // EthApiClient::uncle_by_block_hash_and_index(client, H256::default(), Index::default()).await.unwrap_err(); + // EthApiClient::uncle_by_block_number_and_index(client).await.unwrap_err(); + // EthApiClient::transaction_by_hash(client, H256::default()).await.unwrap_err(); + // EthApiClient::transaction_by_block_hash_and_index(client).await.unwrap_err(); + // EthApiClient::transaction_by_block_number_and_index(client).await.unwrap_err(); + EthApiClient::transaction_receipt(client, H256::default()).await.unwrap_err(); + // EthApiClient::balance(client).await.unwrap_err(); + // EthApiClient::storage_at(client).await.unwrap_err(); + // EthApiClient::transaction_count(client).await.unwrap_err(); + // EthApiClient::get_code(client).await.unwrap_err(); + // EthApiClient::call(client).await.unwrap_err(); + // EthApiClient::create_access_list(client).await.unwrap_err(); + // EthApiClient::estimate_gas(client).await.unwrap_err(); + EthApiClient::gas_price(client).await.unwrap_err(); + EthApiClient::fee_history(client, U256::default(), BlockNumber::default(), None).await.unwrap_err(); + EthApiClient::max_priority_fee_per_gas(client).await.unwrap_err(); + EthApiClient::is_mining(client).await.unwrap_err(); + EthApiClient::hashrate(client).await.unwrap_err(); + EthApiClient::get_work(client).await.unwrap_err(); + EthApiClient::submit_hashrate(client, U256::default(), H256::default()).await.unwrap_err(); + EthApiClient::submit_work(client, H64::default(), H256::default(), H256::default()).await.unwrap_err(); + // EthApiClient::send_transaction(client).await.unwrap_err(); + // EthApiClient::send_raw_transaction(client).await.unwrap_err(); + // EthApiClient::sign(client).await.unwrap_err(); + // EthApiClient::sign_transaction(client).await.unwrap_err(); + // EthApiClient::sign_typed_data(client).await.unwrap_err(); + // EthApiClient::get_proof(client).await.unwrap_err(); } @@ -83,4 +134,4 @@ async fn test_call_eth_functions_http_and_ws() { let handle = launch_http_ws(vec![RethRpcModule::Eth]).await; let client = handle.http_client().unwrap(); test_basic_eth_calls(&client).await; -} \ No newline at end of file +} From ce87fe47ff06e65fcf7845e48155d56b83773671 Mon Sep 17 00:00:00 2001 From: navie Date: Sat, 11 Feb 2023 21:09:18 +0800 Subject: [PATCH 3/9] added debug tests --- crates/rpc/rpc-builder/tests/it/http.rs | 207 +++++++++++++++++++----- 1 file changed, 171 insertions(+), 36 deletions(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index b8dc66c2316c..edbc25c36415 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -2,8 +2,9 @@ use crate::utils::{launch_http, launch_http_ws, launch_ws}; use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; -use reth_primitives::{NodeRecord, H256, BlockNumber, U256, H64}; -use reth_rpc_api::{clients::AdminApiClient, EthApiClient}; +use reth_primitives::{NodeRecord, H256, BlockNumber, U256, H64, rpc::{BlockId, BlockNumber as RpcBlockNumber }}; +use reth_rpc_api::DebugApiClient; +use reth_rpc_api::clients::{AdminApiClient, EthApiClient}; use reth_rpc_builder::RethRpcModule; use jsonrpsee::core::error::Error; use jsonrpsee::types::error::{CallError, ErrorCode}; @@ -44,43 +45,69 @@ where C: ClientT + SubscriptionClientT + Sync { // Unimplemented assert!(is_unimplemented(EthApiClient::syncing(client).await.err().unwrap())); - EthApiClient::author(client).await.unwrap_err(); - EthApiClient::block_by_hash(client, H256::default(), false).await.unwrap_err(); - EthApiClient::block_by_number(client, BlockNumber::default(), false).await.unwrap_err(); - EthApiClient::block_transaction_count_by_hash(client, H256::default()).await.unwrap_err(); - EthApiClient::block_transaction_count_by_number(client, BlockNumber::default()).await.unwrap_err(); - EthApiClient::block_uncles_count_by_hash(client, H256::default()).await.unwrap_err(); - EthApiClient::block_uncles_count_by_number(client, BlockNumber::default()).await.unwrap_err(); - // EthApiClient::uncle_by_block_hash_and_index(client, H256::default(), Index::default()).await.unwrap_err(); - // EthApiClient::uncle_by_block_number_and_index(client).await.unwrap_err(); - // EthApiClient::transaction_by_hash(client, H256::default()).await.unwrap_err(); - // EthApiClient::transaction_by_block_hash_and_index(client).await.unwrap_err(); - // EthApiClient::transaction_by_block_number_and_index(client).await.unwrap_err(); - EthApiClient::transaction_receipt(client, H256::default()).await.unwrap_err(); - // EthApiClient::balance(client).await.unwrap_err(); - // EthApiClient::storage_at(client).await.unwrap_err(); - // EthApiClient::transaction_count(client).await.unwrap_err(); - // EthApiClient::get_code(client).await.unwrap_err(); - // EthApiClient::call(client).await.unwrap_err(); - // EthApiClient::create_access_list(client).await.unwrap_err(); - // EthApiClient::estimate_gas(client).await.unwrap_err(); - EthApiClient::gas_price(client).await.unwrap_err(); - EthApiClient::fee_history(client, U256::default(), BlockNumber::default(), None).await.unwrap_err(); - EthApiClient::max_priority_fee_per_gas(client).await.unwrap_err(); - EthApiClient::is_mining(client).await.unwrap_err(); - EthApiClient::hashrate(client).await.unwrap_err(); - EthApiClient::get_work(client).await.unwrap_err(); - EthApiClient::submit_hashrate(client, U256::default(), H256::default()).await.unwrap_err(); - EthApiClient::submit_work(client, H64::default(), H256::default(), H256::default()).await.unwrap_err(); - // EthApiClient::send_transaction(client).await.unwrap_err(); - // EthApiClient::send_raw_transaction(client).await.unwrap_err(); - // EthApiClient::sign(client).await.unwrap_err(); - // EthApiClient::sign_transaction(client).await.unwrap_err(); - // EthApiClient::sign_typed_data(client).await.unwrap_err(); - // EthApiClient::get_proof(client).await.unwrap_err(); + assert!(is_unimplemented(EthApiClient::author(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_by_hash(client, H256::default(), false).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_by_number(client, BlockNumber::default(), false).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_transaction_count_by_hash(client, H256::default()).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_transaction_count_by_number(client, BlockNumber::default()).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_uncles_count_by_hash(client, H256::default()).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_uncles_count_by_number(client, BlockNumber::default()).await.err().unwrap())); + // EthApiClient::uncle_by_block_hash_and_index(client, H256::default(), Index::default()).await.err().unwrap())); + // EthApiClient::uncle_by_block_number_and_index(client).await.err().unwrap())); + // EthApiClient::transaction_by_hash(client, H256::default()).await.err().unwrap())); + // EthApiClient::transaction_by_block_hash_and_index(client).await.err().unwrap())); + // EthApiClient::transaction_by_block_number_and_index(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::transaction_receipt(client, H256::default()).await.err().unwrap())); + // EthApiClient::balance(client).await.err().unwrap())); + // EthApiClient::storage_at(client).await.err().unwrap())); + // EthApiClient::transaction_count(client).await.err().unwrap())); + // EthApiClient::get_code(client).await.err().unwrap())); + // EthApiClient::call(client).await.err().unwrap())); + // EthApiClient::create_access_list(client).await.err().unwrap())); + // EthApiClient::estimate_gas(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::gas_price(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::fee_history(client, U256::default(), BlockNumber::default(), None).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::max_priority_fee_per_gas(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::is_mining(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::hashrate(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::get_work(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::submit_hashrate(client, U256::default(), H256::default()).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::submit_work(client, H64::default(), H256::default(), H256::default()).await.err().unwrap())); + // EthApiClient::send_transaction(client).await.err().unwrap())); + // EthApiClient::send_raw_transaction(client).await.err().unwrap())); + // EthApiClient::sign(client).await.err().unwrap())); + // EthApiClient::sign_transaction(client).await.err().unwrap())); + // EthApiClient::sign_typed_data(client).await.err().unwrap())); + // EthApiClient::get_proof(client).await.err().unwrap())); } +async fn test_basic_debug_calls(client: &C) +where C: ClientT + SubscriptionClientT + Sync { + let block_id = BlockId::Number(RpcBlockNumber::default()); + + assert!(is_unimplemented(DebugApiClient::raw_block(client, block_id).await.err().unwrap())); + assert!(is_unimplemented(DebugApiClient::raw_transaction(client, H256::default()).await.err().unwrap())); + assert!(is_unimplemented(DebugApiClient::raw_header(client, block_id).await.err().unwrap())); + assert!(is_unimplemented(DebugApiClient::raw_receipts(client, block_id).await.err().unwrap())); + assert!(is_unimplemented(DebugApiClient::bad_blocks(client).await.err().unwrap())); +} + +async fn test_basic_net_calls(client: &C) +where C: ClientT + SubscriptionClientT + Sync { + +} + +async fn test_basic_trace_calls(client: &C) +where C: ClientT + SubscriptionClientT + Sync { + +} + +async fn test_basic_web3_calls(client: &C) +where C: ClientT + SubscriptionClientT + Sync { + +} + #[tokio::test(flavor = "multi_thread")] async fn test_call_admin_functions_http() { @@ -135,3 +162,111 @@ async fn test_call_eth_functions_http_and_ws() { let client = handle.http_client().unwrap(); test_basic_eth_calls(&client).await; } + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_debug_functions_http() { + reth_tracing::init_test_tracing(); + + let handle = launch_http(vec![RethRpcModule::Debug]).await; + let client = handle.http_client().unwrap(); + test_basic_debug_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_debug_functions_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_ws(vec![RethRpcModule::Debug]).await; + let client = handle.ws_client().await.unwrap(); + test_basic_debug_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_debug_functions_http_and_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_http_ws(vec![RethRpcModule::Debug]).await; + let client = handle.http_client().unwrap(); + test_basic_debug_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_net_functions_http() { + reth_tracing::init_test_tracing(); + + let handle = launch_http(vec![RethRpcModule::Net]).await; + let client = handle.http_client().unwrap(); + test_basic_net_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_net_functions_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_ws(vec![RethRpcModule::Net]).await; + let client = handle.ws_client().await.unwrap(); + test_basic_net_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_net_functions_http_and_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_http_ws(vec![RethRpcModule::Net]).await; + let client = handle.http_client().unwrap(); + test_basic_net_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_trace_functions_http() { + reth_tracing::init_test_tracing(); + + let handle = launch_http(vec![RethRpcModule::Trace]).await; + let client = handle.http_client().unwrap(); + test_basic_trace_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_trace_functions_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_ws(vec![RethRpcModule::Trace]).await; + let client = handle.ws_client().await.unwrap(); + test_basic_trace_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_trace_functions_http_and_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_http_ws(vec![RethRpcModule::Trace]).await; + let client = handle.http_client().unwrap(); + test_basic_trace_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_web3_functions_http() { + reth_tracing::init_test_tracing(); + + let handle = launch_http(vec![RethRpcModule::Web3]).await; + let client = handle.http_client().unwrap(); + test_basic_web3_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_web3_functions_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_ws(vec![RethRpcModule::Web3]).await; + let client = handle.ws_client().await.unwrap(); + test_basic_web3_calls(&client).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_call_web3_functions_http_and_ws() { + reth_tracing::init_test_tracing(); + + let handle = launch_http_ws(vec![RethRpcModule::Web3]).await; + let client = handle.http_client().unwrap(); + test_basic_web3_calls(&client).await; +} From f52cfece288562188116bf07321a20f9442f04b8 Mon Sep 17 00:00:00 2001 From: navie Date: Sat, 11 Feb 2023 21:21:46 +0800 Subject: [PATCH 4/9] Added net and trace --- crates/rpc/rpc-builder/tests/it/http.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index edbc25c36415..e1db53c1e8ae 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -1,9 +1,11 @@ //! Standalone http tests +use std::collections::HashSet; + use crate::utils::{launch_http, launch_http_ws, launch_ws}; use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; -use reth_primitives::{NodeRecord, H256, BlockNumber, U256, H64, rpc::{BlockId, BlockNumber as RpcBlockNumber }}; -use reth_rpc_api::DebugApiClient; +use reth_primitives::{NodeRecord, H256, BlockNumber, U256, H64, rpc::{BlockId, BlockNumber as RpcBlockNumber}, Bytes}; +use reth_rpc_api::{DebugApiClient, NetApiClient, TraceApiClient}; use reth_rpc_api::clients::{AdminApiClient, EthApiClient}; use reth_rpc_builder::RethRpcModule; use jsonrpsee::core::error::Error; @@ -86,21 +88,33 @@ async fn test_basic_debug_calls(client: &C) where C: ClientT + SubscriptionClientT + Sync { let block_id = BlockId::Number(RpcBlockNumber::default()); + assert!(is_unimplemented(DebugApiClient::raw_header(client, block_id).await.err().unwrap())); assert!(is_unimplemented(DebugApiClient::raw_block(client, block_id).await.err().unwrap())); assert!(is_unimplemented(DebugApiClient::raw_transaction(client, H256::default()).await.err().unwrap())); - assert!(is_unimplemented(DebugApiClient::raw_header(client, block_id).await.err().unwrap())); assert!(is_unimplemented(DebugApiClient::raw_receipts(client, block_id).await.err().unwrap())); assert!(is_unimplemented(DebugApiClient::bad_blocks(client).await.err().unwrap())); } async fn test_basic_net_calls(client: &C) where C: ClientT + SubscriptionClientT + Sync { - + NetApiClient::version(client).await.unwrap(); + NetApiClient::peer_count(client).await.unwrap(); + NetApiClient::is_listening(client).await.unwrap(); } async fn test_basic_trace_calls(client: &C) where C: ClientT + SubscriptionClientT + Sync { + let block_id = BlockId::Number(RpcBlockNumber::default()); + // TraceApiClient::call(client) + // TraceApiClient::call_many(client) + assert!(is_unimplemented(TraceApiClient::raw_transaction(client, Bytes::default(), HashSet::default(), None).await.err().unwrap())); + assert!(is_unimplemented(TraceApiClient::replay_block_transactions(client, block_id, HashSet::default()).await.err().unwrap())); + assert!(is_unimplemented(TraceApiClient::replay_transaction(client, H256::default(), HashSet::default()).await.err().unwrap())); + assert!(is_unimplemented(TraceApiClient::block(client, block_id).await.err().unwrap())); + // TraceApiClient::filter(client) + assert!(is_unimplemented(TraceApiClient::trace(client, H256::default(), vec![]).await.err().unwrap())); + assert!(is_unimplemented(TraceApiClient::transaction_traces(client, H256::default()).await.err().unwrap())); } async fn test_basic_web3_calls(client: &C) From 77fa12bbefef7f9c7bdbbe2a86146fc35585ee88 Mon Sep 17 00:00:00 2001 From: navie Date: Sat, 11 Feb 2023 21:25:22 +0800 Subject: [PATCH 5/9] Added web3 --- crates/rpc/rpc-builder/tests/it/http.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index e1db53c1e8ae..2e8540d82069 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -5,7 +5,7 @@ use std::collections::HashSet; use crate::utils::{launch_http, launch_http_ws, launch_ws}; use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; use reth_primitives::{NodeRecord, H256, BlockNumber, U256, H64, rpc::{BlockId, BlockNumber as RpcBlockNumber}, Bytes}; -use reth_rpc_api::{DebugApiClient, NetApiClient, TraceApiClient}; +use reth_rpc_api::{DebugApiClient, NetApiClient, TraceApiClient, Web3ApiClient}; use reth_rpc_api::clients::{AdminApiClient, EthApiClient}; use reth_rpc_builder::RethRpcModule; use jsonrpsee::core::error::Error; @@ -119,7 +119,8 @@ where C: ClientT + SubscriptionClientT + Sync { async fn test_basic_web3_calls(client: &C) where C: ClientT + SubscriptionClientT + Sync { - + Web3ApiClient::client_version(client).await.unwrap(); + Web3ApiClient::sha3(client, Bytes::default()).await.unwrap(); } From f1c478eacb3ad9a819a614174e0bbda9659b3a31 Mon Sep 17 00:00:00 2001 From: navie Date: Sun, 12 Feb 2023 02:01:42 +0800 Subject: [PATCH 6/9] Complete all tests --- crates/rpc/rpc-builder/tests/it/http.rs | 79 +++++++++++++++---------- crates/rpc/rpc-types/src/eth/index.rs | 2 +- 2 files changed, 49 insertions(+), 32 deletions(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index 2e8540d82069..2c17c6b7735e 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -4,10 +4,11 @@ use std::collections::HashSet; use crate::utils::{launch_http, launch_http_ws, launch_ws}; use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; -use reth_primitives::{NodeRecord, H256, BlockNumber, U256, H64, rpc::{BlockId, BlockNumber as RpcBlockNumber}, Bytes}; +use reth_primitives::{NodeRecord, H256, BlockNumber, U256, H64, rpc::{BlockId, BlockNumber as RpcBlockNumber}, Bytes, Address, hex_literal::hex}; use reth_rpc_api::{DebugApiClient, NetApiClient, TraceApiClient, Web3ApiClient}; use reth_rpc_api::clients::{AdminApiClient, EthApiClient}; use reth_rpc_builder::RethRpcModule; +use reth_rpc_types::{CallRequest, Index, trace::filter::TraceFilter, TransactionRequest}; use jsonrpsee::core::error::Error; use jsonrpsee::types::error::{CallError, ErrorCode}; @@ -36,6 +37,14 @@ where async fn test_basic_eth_calls(client: &C) where C: ClientT + SubscriptionClientT + Sync { + let address = Address::default(); + let index = Index::default(); + let hash = H256::default(); + let block_number = BlockNumber::default(); + let call_request = CallRequest::default(); + let transaction_request = TransactionRequest::default(); + let bytes = Bytes::default(); + let tx = Bytes::from(hex!("02f871018303579880850555633d1b82520894eee27662c2b8eba3cd936a23f039f3189633e4c887ad591c62bdaeb180c080a07ea72c68abfb8fca1bd964f0f99132ed9280261bdca3e549546c0205e800f7d0a05b4ef3039e9c9b9babc179a1878fb825b5aaf5aed2fa8744854150157b08d6f3")); // Implemented EthApiClient::protocol_version(client).await.unwrap(); @@ -43,44 +52,44 @@ where C: ClientT + SubscriptionClientT + Sync { EthApiClient::chain_id(client).await.unwrap(); EthApiClient::accounts(client).await.unwrap(); EthApiClient::block_number(client).await.unwrap(); + EthApiClient::get_code(client, address, None).await.unwrap(); + EthApiClient::send_raw_transaction(client, tx).await.unwrap(); // Unimplemented assert!(is_unimplemented(EthApiClient::syncing(client).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::author(client).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_by_hash(client, H256::default(), false).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_by_number(client, BlockNumber::default(), false).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_transaction_count_by_hash(client, H256::default()).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_transaction_count_by_number(client, BlockNumber::default()).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_uncles_count_by_hash(client, H256::default()).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_uncles_count_by_number(client, BlockNumber::default()).await.err().unwrap())); - // EthApiClient::uncle_by_block_hash_and_index(client, H256::default(), Index::default()).await.err().unwrap())); - // EthApiClient::uncle_by_block_number_and_index(client).await.err().unwrap())); - // EthApiClient::transaction_by_hash(client, H256::default()).await.err().unwrap())); - // EthApiClient::transaction_by_block_hash_and_index(client).await.err().unwrap())); - // EthApiClient::transaction_by_block_number_and_index(client).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::transaction_receipt(client, H256::default()).await.err().unwrap())); - // EthApiClient::balance(client).await.err().unwrap())); - // EthApiClient::storage_at(client).await.err().unwrap())); - // EthApiClient::transaction_count(client).await.err().unwrap())); - // EthApiClient::get_code(client).await.err().unwrap())); - // EthApiClient::call(client).await.err().unwrap())); - // EthApiClient::create_access_list(client).await.err().unwrap())); - // EthApiClient::estimate_gas(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_by_hash(client, hash, false).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_by_number(client, block_number, false).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_transaction_count_by_hash(client, hash).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_transaction_count_by_number(client, block_number).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_uncles_count_by_hash(client, hash).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::block_uncles_count_by_number(client, block_number).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::uncle_by_block_hash_and_index(client, hash, index).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::uncle_by_block_number_and_index(client, block_number, index).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::transaction_by_hash(client, hash).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::transaction_by_block_hash_and_index(client, hash, index).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::transaction_by_block_number_and_index(client, block_number, index).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::transaction_receipt(client, hash).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::balance(client, address, None).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::storage_at(client, address, U256::default(), None).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::transaction_count(client, address, None).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::call(client, call_request.clone(), None).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::create_access_list(client, call_request.clone(), None).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::estimate_gas(client, call_request.clone(), None).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::gas_price(client).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::fee_history(client, U256::default(), BlockNumber::default(), None).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::fee_history(client, U256::default(), block_number, None).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::max_priority_fee_per_gas(client).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::is_mining(client).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::hashrate(client).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::get_work(client).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::submit_hashrate(client, U256::default(), H256::default()).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::submit_work(client, H64::default(), H256::default(), H256::default()).await.err().unwrap())); - // EthApiClient::send_transaction(client).await.err().unwrap())); - // EthApiClient::send_raw_transaction(client).await.err().unwrap())); - // EthApiClient::sign(client).await.err().unwrap())); - // EthApiClient::sign_transaction(client).await.err().unwrap())); - // EthApiClient::sign_typed_data(client).await.err().unwrap())); - // EthApiClient::get_proof(client).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::send_transaction(client, transaction_request).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::sign(client, address, bytes.clone()).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::sign_transaction(client, call_request.clone()).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::sign_typed_data(client, address, jsonrpsee::core::JsonValue::Null).await.err().unwrap())); + assert!(is_unimplemented(EthApiClient::get_proof(client, address, vec![], None).await.err().unwrap())); } @@ -105,14 +114,22 @@ where C: ClientT + SubscriptionClientT + Sync { async fn test_basic_trace_calls(client: &C) where C: ClientT + SubscriptionClientT + Sync { let block_id = BlockId::Number(RpcBlockNumber::default()); - - // TraceApiClient::call(client) - // TraceApiClient::call_many(client) + let trace_filter = TraceFilter { + from_block: None, + to_block: None, + from_address: None, + to_address: None, + after: None, + count: None, + }; + + assert!(is_unimplemented(TraceApiClient::call(client, CallRequest::default(), HashSet::default(), None).await.err().unwrap())); + assert!(is_unimplemented(TraceApiClient::call_many(client, vec![], None).await.err().unwrap())); assert!(is_unimplemented(TraceApiClient::raw_transaction(client, Bytes::default(), HashSet::default(), None).await.err().unwrap())); assert!(is_unimplemented(TraceApiClient::replay_block_transactions(client, block_id, HashSet::default()).await.err().unwrap())); assert!(is_unimplemented(TraceApiClient::replay_transaction(client, H256::default(), HashSet::default()).await.err().unwrap())); assert!(is_unimplemented(TraceApiClient::block(client, block_id).await.err().unwrap())); - // TraceApiClient::filter(client) + assert!(is_unimplemented(TraceApiClient::filter(client, trace_filter).await.err().unwrap())); assert!(is_unimplemented(TraceApiClient::trace(client, H256::default(), vec![]).await.err().unwrap())); assert!(is_unimplemented(TraceApiClient::transaction_traces(client, H256::default()).await.err().unwrap())); } diff --git a/crates/rpc/rpc-types/src/eth/index.rs b/crates/rpc/rpc-types/src/eth/index.rs index 8e889e6c52b2..217a928e3ed8 100644 --- a/crates/rpc/rpc-types/src/eth/index.rs +++ b/crates/rpc/rpc-types/src/eth/index.rs @@ -5,7 +5,7 @@ use serde::{ use std::fmt; /// A hex encoded or decimal index -#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Default)] pub struct Index(usize); impl From for usize { From c57d5c0dfc16cd0b9035e4293a22ce5a429cfee3 Mon Sep 17 00:00:00 2001 From: navie Date: Sun, 12 Feb 2023 02:04:12 +0800 Subject: [PATCH 7/9] Lint --- crates/rpc/rpc-builder/tests/it/http.rs | 189 ++++++++++++++++++------ 1 file changed, 144 insertions(+), 45 deletions(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index 2c17c6b7735e..96ee2b9e6d6f 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -4,18 +4,23 @@ use std::collections::HashSet; use crate::utils::{launch_http, launch_http_ws, launch_ws}; use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; -use reth_primitives::{NodeRecord, H256, BlockNumber, U256, H64, rpc::{BlockId, BlockNumber as RpcBlockNumber}, Bytes, Address, hex_literal::hex}; -use reth_rpc_api::{DebugApiClient, NetApiClient, TraceApiClient, Web3ApiClient}; -use reth_rpc_api::clients::{AdminApiClient, EthApiClient}; -use reth_rpc_builder::RethRpcModule; -use reth_rpc_types::{CallRequest, Index, trace::filter::TraceFilter, TransactionRequest}; use jsonrpsee::core::error::Error; use jsonrpsee::types::error::{CallError, ErrorCode}; +use reth_primitives::{ + hex_literal::hex, + rpc::{BlockId, BlockNumber as RpcBlockNumber}, + Address, BlockNumber, Bytes, NodeRecord, H256, H64, U256, +}; +use reth_rpc_api::clients::{AdminApiClient, EthApiClient}; +use reth_rpc_api::{DebugApiClient, NetApiClient, TraceApiClient, Web3ApiClient}; +use reth_rpc_builder::RethRpcModule; +use reth_rpc_types::{trace::filter::TraceFilter, CallRequest, Index, TransactionRequest}; fn is_unimplemented(err: Error) -> bool { match err { Error::Call(CallError::Custom(error_obj)) => { - error_obj.code() == ErrorCode::InternalError.code() && error_obj.message() == "unimplemented" + error_obj.code() == ErrorCode::InternalError.code() + && error_obj.message() == "unimplemented" } _ => return false, } @@ -36,7 +41,9 @@ where } async fn test_basic_eth_calls(client: &C) -where C: ClientT + SubscriptionClientT + Sync { +where + C: ClientT + SubscriptionClientT + Sync, +{ let address = Address::default(); let index = Index::default(); let hash = H256::default(); @@ -55,64 +62,131 @@ where C: ClientT + SubscriptionClientT + Sync { EthApiClient::get_code(client, address, None).await.unwrap(); EthApiClient::send_raw_transaction(client, tx).await.unwrap(); - // Unimplemented assert!(is_unimplemented(EthApiClient::syncing(client).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::author(client).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_by_hash(client, hash, false).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_by_number(client, block_number, false).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_transaction_count_by_hash(client, hash).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_transaction_count_by_number(client, block_number).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_uncles_count_by_hash(client, hash).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::block_uncles_count_by_number(client, block_number).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::uncle_by_block_hash_and_index(client, hash, index).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::uncle_by_block_number_and_index(client, block_number, index).await.err().unwrap())); + assert!(is_unimplemented( + EthApiClient::block_by_hash(client, hash, false).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::block_by_number(client, block_number, false).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::block_transaction_count_by_hash(client, hash).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::block_transaction_count_by_number(client, block_number).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::block_uncles_count_by_hash(client, hash).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::block_uncles_count_by_number(client, block_number).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::uncle_by_block_hash_and_index(client, hash, index).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::uncle_by_block_number_and_index(client, block_number, index) + .await + .err() + .unwrap() + )); assert!(is_unimplemented(EthApiClient::transaction_by_hash(client, hash).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::transaction_by_block_hash_and_index(client, hash, index).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::transaction_by_block_number_and_index(client, block_number, index).await.err().unwrap())); + assert!(is_unimplemented( + EthApiClient::transaction_by_block_hash_and_index(client, hash, index).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::transaction_by_block_number_and_index(client, block_number, index) + .await + .err() + .unwrap() + )); assert!(is_unimplemented(EthApiClient::transaction_receipt(client, hash).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::balance(client, address, None).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::storage_at(client, address, U256::default(), None).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::transaction_count(client, address, None).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::call(client, call_request.clone(), None).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::create_access_list(client, call_request.clone(), None).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::estimate_gas(client, call_request.clone(), None).await.err().unwrap())); + assert!(is_unimplemented( + EthApiClient::storage_at(client, address, U256::default(), None).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::transaction_count(client, address, None).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::call(client, call_request.clone(), None).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::create_access_list(client, call_request.clone(), None).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::estimate_gas(client, call_request.clone(), None).await.err().unwrap() + )); assert!(is_unimplemented(EthApiClient::gas_price(client).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::fee_history(client, U256::default(), block_number, None).await.err().unwrap())); + assert!(is_unimplemented( + EthApiClient::fee_history(client, U256::default(), block_number, None).await.err().unwrap() + )); assert!(is_unimplemented(EthApiClient::max_priority_fee_per_gas(client).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::is_mining(client).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::hashrate(client).await.err().unwrap())); assert!(is_unimplemented(EthApiClient::get_work(client).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::submit_hashrate(client, U256::default(), H256::default()).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::submit_work(client, H64::default(), H256::default(), H256::default()).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::send_transaction(client, transaction_request).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::sign(client, address, bytes.clone()).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::sign_transaction(client, call_request.clone()).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::sign_typed_data(client, address, jsonrpsee::core::JsonValue::Null).await.err().unwrap())); - assert!(is_unimplemented(EthApiClient::get_proof(client, address, vec![], None).await.err().unwrap())); - + assert!(is_unimplemented( + EthApiClient::submit_hashrate(client, U256::default(), H256::default()) + .await + .err() + .unwrap() + )); + assert!(is_unimplemented( + EthApiClient::submit_work(client, H64::default(), H256::default(), H256::default()) + .await + .err() + .unwrap() + )); + assert!(is_unimplemented( + EthApiClient::send_transaction(client, transaction_request).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::sign(client, address, bytes.clone()).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::sign_transaction(client, call_request.clone()).await.err().unwrap() + )); + assert!(is_unimplemented( + EthApiClient::sign_typed_data(client, address, jsonrpsee::core::JsonValue::Null) + .await + .err() + .unwrap() + )); + assert!(is_unimplemented( + EthApiClient::get_proof(client, address, vec![], None).await.err().unwrap() + )); } - + async fn test_basic_debug_calls(client: &C) -where C: ClientT + SubscriptionClientT + Sync { +where + C: ClientT + SubscriptionClientT + Sync, +{ let block_id = BlockId::Number(RpcBlockNumber::default()); assert!(is_unimplemented(DebugApiClient::raw_header(client, block_id).await.err().unwrap())); assert!(is_unimplemented(DebugApiClient::raw_block(client, block_id).await.err().unwrap())); - assert!(is_unimplemented(DebugApiClient::raw_transaction(client, H256::default()).await.err().unwrap())); + assert!(is_unimplemented( + DebugApiClient::raw_transaction(client, H256::default()).await.err().unwrap() + )); assert!(is_unimplemented(DebugApiClient::raw_receipts(client, block_id).await.err().unwrap())); assert!(is_unimplemented(DebugApiClient::bad_blocks(client).await.err().unwrap())); } async fn test_basic_net_calls(client: &C) -where C: ClientT + SubscriptionClientT + Sync { +where + C: ClientT + SubscriptionClientT + Sync, +{ NetApiClient::version(client).await.unwrap(); NetApiClient::peer_count(client).await.unwrap(); NetApiClient::is_listening(client).await.unwrap(); } async fn test_basic_trace_calls(client: &C) -where C: ClientT + SubscriptionClientT + Sync { +where + C: ClientT + SubscriptionClientT + Sync, +{ let block_id = BlockId::Number(RpcBlockNumber::default()); let trace_filter = TraceFilter { from_block: None, @@ -123,24 +197,49 @@ where C: ClientT + SubscriptionClientT + Sync { count: None, }; - assert!(is_unimplemented(TraceApiClient::call(client, CallRequest::default(), HashSet::default(), None).await.err().unwrap())); + assert!(is_unimplemented( + TraceApiClient::call(client, CallRequest::default(), HashSet::default(), None) + .await + .err() + .unwrap() + )); assert!(is_unimplemented(TraceApiClient::call_many(client, vec![], None).await.err().unwrap())); - assert!(is_unimplemented(TraceApiClient::raw_transaction(client, Bytes::default(), HashSet::default(), None).await.err().unwrap())); - assert!(is_unimplemented(TraceApiClient::replay_block_transactions(client, block_id, HashSet::default()).await.err().unwrap())); - assert!(is_unimplemented(TraceApiClient::replay_transaction(client, H256::default(), HashSet::default()).await.err().unwrap())); + assert!(is_unimplemented( + TraceApiClient::raw_transaction(client, Bytes::default(), HashSet::default(), None) + .await + .err() + .unwrap() + )); + assert!(is_unimplemented( + TraceApiClient::replay_block_transactions(client, block_id, HashSet::default()) + .await + .err() + .unwrap() + )); + assert!(is_unimplemented( + TraceApiClient::replay_transaction(client, H256::default(), HashSet::default()) + .await + .err() + .unwrap() + )); assert!(is_unimplemented(TraceApiClient::block(client, block_id).await.err().unwrap())); assert!(is_unimplemented(TraceApiClient::filter(client, trace_filter).await.err().unwrap())); - assert!(is_unimplemented(TraceApiClient::trace(client, H256::default(), vec![]).await.err().unwrap())); - assert!(is_unimplemented(TraceApiClient::transaction_traces(client, H256::default()).await.err().unwrap())); + assert!(is_unimplemented( + TraceApiClient::trace(client, H256::default(), vec![]).await.err().unwrap() + )); + assert!(is_unimplemented( + TraceApiClient::transaction_traces(client, H256::default()).await.err().unwrap() + )); } async fn test_basic_web3_calls(client: &C) -where C: ClientT + SubscriptionClientT + Sync { +where + C: ClientT + SubscriptionClientT + Sync, +{ Web3ApiClient::client_version(client).await.unwrap(); Web3ApiClient::sha3(client, Bytes::default()).await.unwrap(); } - #[tokio::test(flavor = "multi_thread")] async fn test_call_admin_functions_http() { reth_tracing::init_test_tracing(); From c84d67be96a9c152ff02836d8a7af9472f7f0b0f Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Sat, 11 Feb 2023 17:09:21 -0800 Subject: [PATCH 8/9] fix: add missing reth-types dep --- Cargo.lock | 1 + crates/rpc/rpc-builder/Cargo.toml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 05a2e8cfd9c2..786f000488f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4644,6 +4644,7 @@ dependencies = [ "reth-provider", "reth-rpc", "reth-rpc-api", + "reth-rpc-types", "reth-tracing", "reth-transaction-pool", "serde", diff --git a/crates/rpc/rpc-builder/Cargo.toml b/crates/rpc/rpc-builder/Cargo.toml index 5c7a3f39ba5a..e46bac036dbe 100644 --- a/crates/rpc/rpc-builder/Cargo.toml +++ b/crates/rpc/rpc-builder/Cargo.toml @@ -13,6 +13,7 @@ reth-network-api = { path = "../../net/network-api" } reth-provider = { path = "../../storage/provider" } reth-rpc = { path = "../rpc" } reth-rpc-api = { path = "../rpc-api" } +reth-rpc-types = { path = "../rpc-types" } reth-transaction-pool = { path = "../../transaction-pool" } jsonrpsee = { version = "0.16", features = ["server"] } @@ -28,4 +29,4 @@ reth-transaction-pool = { path = "../../transaction-pool", features = ["test-uti reth-provider = { path = "../../storage/provider", features = ["test-utils"] } reth-network-api = { path = "../../net/network-api", features = ["test-utils"] } -tokio = { version = "1", features = ["rt", "rt-multi-thread"] } \ No newline at end of file +tokio = { version = "1", features = ["rt", "rt-multi-thread"] } From 490712ad7419f602ad42fbecefd613abe90b1899 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Sat, 11 Feb 2023 17:09:36 -0800 Subject: [PATCH 9/9] chore: fmt --- crates/rpc/rpc-builder/tests/it/http.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index 96ee2b9e6d6f..c90def7742bc 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -3,24 +3,30 @@ use std::collections::HashSet; use crate::utils::{launch_http, launch_http_ws, launch_ws}; -use jsonrpsee::core::client::{ClientT, SubscriptionClientT}; -use jsonrpsee::core::error::Error; -use jsonrpsee::types::error::{CallError, ErrorCode}; +use jsonrpsee::{ + core::{ + client::{ClientT, SubscriptionClientT}, + error::Error, + }, + types::error::{CallError, ErrorCode}, +}; use reth_primitives::{ hex_literal::hex, rpc::{BlockId, BlockNumber as RpcBlockNumber}, Address, BlockNumber, Bytes, NodeRecord, H256, H64, U256, }; -use reth_rpc_api::clients::{AdminApiClient, EthApiClient}; -use reth_rpc_api::{DebugApiClient, NetApiClient, TraceApiClient, Web3ApiClient}; +use reth_rpc_api::{ + clients::{AdminApiClient, EthApiClient}, + DebugApiClient, NetApiClient, TraceApiClient, Web3ApiClient, +}; use reth_rpc_builder::RethRpcModule; use reth_rpc_types::{trace::filter::TraceFilter, CallRequest, Index, TransactionRequest}; fn is_unimplemented(err: Error) -> bool { match err { Error::Call(CallError::Custom(error_obj)) => { - error_obj.code() == ErrorCode::InternalError.code() - && error_obj.message() == "unimplemented" + error_obj.code() == ErrorCode::InternalError.code() && + error_obj.message() == "unimplemented" } _ => return false, }