-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(l1): support multiple rpc requests in a single request #2006
Conversation
now serde can deserialize both into an intermediate enum then match if the value is a single rpcRequest or a vec of requests
|
} | ||
.unwrap() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in add unit test for RpcRequestWrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 after adding unit test
crates/networking/rpc/rpc.rs
Outdated
@@ -576,4 +594,64 @@ mod tests { | |||
let expected_response = to_rpc_response_success_value(&expected_response_string); | |||
assert_eq!(response.to_string(), expected_response.to_string()); | |||
} | |||
|
|||
#[test] | |||
fn map_http_requests_single_item_then_array_json_test() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're not calling handle_http_request
, which is the function you want to test. Let's better remove this test and merge without a test. Seems we need to create some test utils to easily test endpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in remove useless test
**Motivation** The hive tests from `engine-withdrawals` were failing with a panic because we were asuming only a single RLPRequest could be received but the test sent an array of requets **Description** Introduce a wrapper struct that contains a `Single` type for single `RPCRequest` and `Multiple` for an array of requests, so serde can deserialize into the correct one. If we have an array of request we execute them sequentially. Then return a json encoded array of responses. The function `rpc_response` was also changed to return `serde_json::Value` because it was returning an incorrect value when using it to create the array of responses. This PR fixes the following tests from `engine-withdrawals`: - "Withdrawals Fork on Block 1 - 1 Block Re-Org" - "Withdrawals Fork on Block 1 - 8 Block Re-Org NewPayload" - "Withdrawals Fork on Block 8 - 10 Block Re-Org NewPayload" - "Withdrawals Fork on Canonical Block 8 / Side Block 7 - 10 Block Re-Org" - "Withdrawals Fork on Canonical Block 8 / Side Block 9 - 10 Block Re-Org" Advances #1586
**Motivation** The hive tests from `engine-withdrawals` were failing with a panic because we were asuming only a single RLPRequest could be received but the test sent an array of requets **Description** Introduce a wrapper struct that contains a `Single` type for single `RPCRequest` and `Multiple` for an array of requests, so serde can deserialize into the correct one. If we have an array of request we execute them sequentially. Then return a json encoded array of responses. The function `rpc_response` was also changed to return `serde_json::Value` because it was returning an incorrect value when using it to create the array of responses. This PR fixes the following tests from `engine-withdrawals`: - "Withdrawals Fork on Block 1 - 1 Block Re-Org" - "Withdrawals Fork on Block 1 - 8 Block Re-Org NewPayload" - "Withdrawals Fork on Block 8 - 10 Block Re-Org NewPayload" - "Withdrawals Fork on Canonical Block 8 / Side Block 7 - 10 Block Re-Org" - "Withdrawals Fork on Canonical Block 8 / Side Block 9 - 10 Block Re-Org" Advances #1586
**Motivation** The hive tests from `engine-withdrawals` were failing with a panic because we were asuming only a single RLPRequest could be received but the test sent an array of requets **Description** Introduce a wrapper struct that contains a `Single` type for single `RPCRequest` and `Multiple` for an array of requests, so serde can deserialize into the correct one. If we have an array of request we execute them sequentially. Then return a json encoded array of responses. The function `rpc_response` was also changed to return `serde_json::Value` because it was returning an incorrect value when using it to create the array of responses. This PR fixes the following tests from `engine-withdrawals`: - "Withdrawals Fork on Block 1 - 1 Block Re-Org" - "Withdrawals Fork on Block 1 - 8 Block Re-Org NewPayload" - "Withdrawals Fork on Block 8 - 10 Block Re-Org NewPayload" - "Withdrawals Fork on Canonical Block 8 / Side Block 7 - 10 Block Re-Org" - "Withdrawals Fork on Canonical Block 8 / Side Block 9 - 10 Block Re-Org" Advances #1586
Motivation
The hive tests from
engine-withdrawals
were failing with a panic because we were asuming only a single RLPRequest could be received but the test sent an array of requetsDescription
Introduce a wrapper struct that contains a
Single
type for singleRPCRequest
andMultiple
for an array of requests, so serde can deserialize into the correct one.If we have an array of request we execute them sequentially. Then return a json encoded array of responses.
The function
rpc_response
was also changed to returnserde_json::Value
because it was returning an incorrect value when using it to create the array of responses.This PR fixes the following tests from
engine-withdrawals
:Advances #1586