mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-05 22:04:29 +00:00
Add version to the response of beacon API client side (#8326)
Co-Authored-By: Tan Chee Keong <tanck@sigmaprime.io>
This commit is contained in:
@@ -1316,12 +1316,14 @@ impl ApiTester {
|
|||||||
.ok()
|
.ok()
|
||||||
.map(|(state, _execution_optimistic, _finalized)| state);
|
.map(|(state, _execution_optimistic, _finalized)| state);
|
||||||
|
|
||||||
let result = self
|
let result = match self
|
||||||
.client
|
.client
|
||||||
.get_beacon_states_pending_deposits(state_id.0)
|
.get_beacon_states_pending_deposits(state_id.0)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
{
|
||||||
.map(|res| res.data);
|
Ok(response) => response,
|
||||||
|
Err(e) => panic!("query failed incorrectly: {e:?}"),
|
||||||
|
};
|
||||||
|
|
||||||
if result.is_none() && state_opt.is_none() {
|
if result.is_none() && state_opt.is_none() {
|
||||||
continue;
|
continue;
|
||||||
@@ -1330,7 +1332,12 @@ impl ApiTester {
|
|||||||
let state = state_opt.as_mut().expect("result should be none");
|
let state = state_opt.as_mut().expect("result should be none");
|
||||||
let expected = state.pending_deposits().unwrap();
|
let expected = state.pending_deposits().unwrap();
|
||||||
|
|
||||||
assert_eq!(result.unwrap(), expected.to_vec());
|
let response = result.unwrap();
|
||||||
|
assert_eq!(response.data(), &expected.to_vec());
|
||||||
|
|
||||||
|
// Check that the version header is returned in the response
|
||||||
|
let fork_name = state.fork_name(&self.chain.spec).unwrap();
|
||||||
|
assert_eq!(response.version(), Some(fork_name),);
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
@@ -1343,12 +1350,14 @@ impl ApiTester {
|
|||||||
.ok()
|
.ok()
|
||||||
.map(|(state, _execution_optimistic, _finalized)| state);
|
.map(|(state, _execution_optimistic, _finalized)| state);
|
||||||
|
|
||||||
let result = self
|
let result = match self
|
||||||
.client
|
.client
|
||||||
.get_beacon_states_pending_partial_withdrawals(state_id.0)
|
.get_beacon_states_pending_partial_withdrawals(state_id.0)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
{
|
||||||
.map(|res| res.data);
|
Ok(response) => response,
|
||||||
|
Err(e) => panic!("query failed incorrectly: {e:?}"),
|
||||||
|
};
|
||||||
|
|
||||||
if result.is_none() && state_opt.is_none() {
|
if result.is_none() && state_opt.is_none() {
|
||||||
continue;
|
continue;
|
||||||
@@ -1357,7 +1366,12 @@ impl ApiTester {
|
|||||||
let state = state_opt.as_mut().expect("result should be none");
|
let state = state_opt.as_mut().expect("result should be none");
|
||||||
let expected = state.pending_partial_withdrawals().unwrap();
|
let expected = state.pending_partial_withdrawals().unwrap();
|
||||||
|
|
||||||
assert_eq!(result.unwrap(), expected.to_vec());
|
let response = result.unwrap();
|
||||||
|
assert_eq!(response.data(), &expected.to_vec());
|
||||||
|
|
||||||
|
// Check that the version header is returned in the response
|
||||||
|
let fork_name = state.fork_name(&self.chain.spec).unwrap();
|
||||||
|
assert_eq!(response.version(), Some(fork_name),);
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
|
|||||||
@@ -827,7 +827,8 @@ impl BeaconNodeHttpClient {
|
|||||||
pub async fn get_beacon_states_pending_deposits(
|
pub async fn get_beacon_states_pending_deposits(
|
||||||
&self,
|
&self,
|
||||||
state_id: StateId,
|
state_id: StateId,
|
||||||
) -> Result<Option<ExecutionOptimisticFinalizedResponse<Vec<PendingDeposit>>>, Error> {
|
) -> Result<Option<ExecutionOptimisticFinalizedBeaconResponse<Vec<PendingDeposit>>>, Error>
|
||||||
|
{
|
||||||
let mut path = self.eth_path(V1)?;
|
let mut path = self.eth_path(V1)?;
|
||||||
|
|
||||||
path.path_segments_mut()
|
path.path_segments_mut()
|
||||||
@@ -837,7 +838,9 @@ impl BeaconNodeHttpClient {
|
|||||||
.push(&state_id.to_string())
|
.push(&state_id.to_string())
|
||||||
.push("pending_deposits");
|
.push("pending_deposits");
|
||||||
|
|
||||||
self.get_opt(path).await
|
self.get_fork_contextual(path, |fork| fork)
|
||||||
|
.await
|
||||||
|
.map(|opt| opt.map(BeaconResponse::ForkVersioned))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `GET beacon/states/{state_id}/pending_partial_withdrawals`
|
/// `GET beacon/states/{state_id}/pending_partial_withdrawals`
|
||||||
@@ -846,8 +849,10 @@ impl BeaconNodeHttpClient {
|
|||||||
pub async fn get_beacon_states_pending_partial_withdrawals(
|
pub async fn get_beacon_states_pending_partial_withdrawals(
|
||||||
&self,
|
&self,
|
||||||
state_id: StateId,
|
state_id: StateId,
|
||||||
) -> Result<Option<ExecutionOptimisticFinalizedResponse<Vec<PendingPartialWithdrawal>>>, Error>
|
) -> Result<
|
||||||
{
|
Option<ExecutionOptimisticFinalizedBeaconResponse<Vec<PendingPartialWithdrawal>>>,
|
||||||
|
Error,
|
||||||
|
> {
|
||||||
let mut path = self.eth_path(V1)?;
|
let mut path = self.eth_path(V1)?;
|
||||||
|
|
||||||
path.path_segments_mut()
|
path.path_segments_mut()
|
||||||
@@ -857,7 +862,9 @@ impl BeaconNodeHttpClient {
|
|||||||
.push(&state_id.to_string())
|
.push(&state_id.to_string())
|
||||||
.push("pending_partial_withdrawals");
|
.push("pending_partial_withdrawals");
|
||||||
|
|
||||||
self.get_opt(path).await
|
self.get_fork_contextual(path, |fork| fork)
|
||||||
|
.await
|
||||||
|
.map(|opt| opt.map(BeaconResponse::ForkVersioned))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `GET beacon/states/{state_id}/pending_consolidations`
|
/// `GET beacon/states/{state_id}/pending_consolidations`
|
||||||
|
|||||||
Reference in New Issue
Block a user