Skip to content

Commit 2de1a68

Browse files
committed
version
1 parent 4b522d7 commit 2de1a68

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

beacon_node/http_api/tests/tests.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,12 +1316,14 @@ impl ApiTester {
13161316
.ok()
13171317
.map(|(state, _execution_optimistic, _finalized)| state);
13181318

1319-
let result = self
1319+
let result = match self
13201320
.client
13211321
.get_beacon_states_pending_deposits(state_id.0)
13221322
.await
1323-
.unwrap()
1324-
.map(|res| res.data);
1323+
{
1324+
Ok(response) => response,
1325+
Err(e) => panic!("query failed incorrectly: {e:?}"),
1326+
};
13251327

13261328
if result.is_none() && state_opt.is_none() {
13271329
continue;
@@ -1330,7 +1332,12 @@ impl ApiTester {
13301332
let state = state_opt.as_mut().expect("result should be none");
13311333
let expected = state.pending_deposits().unwrap();
13321334

1333-
assert_eq!(result.unwrap(), expected.to_vec());
1335+
let response = result.unwrap();
1336+
assert_eq!(response.data(), &expected.to_vec());
1337+
1338+
// Check that the version header is returned in the response
1339+
let fork_name = state.fork_name(&self.chain.spec).unwrap();
1340+
assert_eq!(response.version(), Some(fork_name),);
13341341
}
13351342

13361343
self
@@ -1343,12 +1350,14 @@ impl ApiTester {
13431350
.ok()
13441351
.map(|(state, _execution_optimistic, _finalized)| state);
13451352

1346-
let result = self
1353+
let result = match self
13471354
.client
13481355
.get_beacon_states_pending_partial_withdrawals(state_id.0)
13491356
.await
1350-
.unwrap()
1351-
.map(|res| res.data);
1357+
{
1358+
Ok(response) => response,
1359+
Err(e) => panic!("query failed incorrectly: {e:?}"),
1360+
};
13521361

13531362
if result.is_none() && state_opt.is_none() {
13541363
continue;
@@ -1357,7 +1366,12 @@ impl ApiTester {
13571366
let state = state_opt.as_mut().expect("result should be none");
13581367
let expected = state.pending_partial_withdrawals().unwrap();
13591368

1360-
assert_eq!(result.unwrap(), expected.to_vec());
1369+
let response = result.unwrap();
1370+
assert_eq!(response.data(), &expected.to_vec());
1371+
1372+
// Check that the version header is returned in the response
1373+
let fork_name = state.fork_name(&self.chain.spec).unwrap();
1374+
assert_eq!(response.version(), Some(fork_name),);
13611375
}
13621376

13631377
self

common/eth2/src/lib.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,8 @@ impl BeaconNodeHttpClient {
904904
pub async fn get_beacon_states_pending_deposits(
905905
&self,
906906
state_id: StateId,
907-
) -> Result<Option<ExecutionOptimisticFinalizedResponse<Vec<PendingDeposit>>>, Error> {
907+
) -> Result<Option<ExecutionOptimisticFinalizedBeaconResponse<Vec<PendingDeposit>>>, Error>
908+
{
908909
let mut path = self.eth_path(V1)?;
909910

910911
path.path_segments_mut()
@@ -914,7 +915,9 @@ impl BeaconNodeHttpClient {
914915
.push(&state_id.to_string())
915916
.push("pending_deposits");
916917

917-
self.get_opt(path).await
918+
self.get_fork_contextual(path, |fork| fork)
919+
.await
920+
.map(|opt| opt.map(BeaconResponse::ForkVersioned))
918921
}
919922

920923
/// `GET beacon/states/{state_id}/pending_partial_withdrawals`
@@ -923,8 +926,10 @@ impl BeaconNodeHttpClient {
923926
pub async fn get_beacon_states_pending_partial_withdrawals(
924927
&self,
925928
state_id: StateId,
926-
) -> Result<Option<ExecutionOptimisticFinalizedResponse<Vec<PendingPartialWithdrawal>>>, Error>
927-
{
929+
) -> Result<
930+
Option<ExecutionOptimisticFinalizedBeaconResponse<Vec<PendingPartialWithdrawal>>>,
931+
Error,
932+
> {
928933
let mut path = self.eth_path(V1)?;
929934

930935
path.path_segments_mut()
@@ -934,7 +939,9 @@ impl BeaconNodeHttpClient {
934939
.push(&state_id.to_string())
935940
.push("pending_partial_withdrawals");
936941

937-
self.get_opt(path).await
942+
self.get_fork_contextual(path, |fork| fork)
943+
.await
944+
.map(|opt| opt.map(BeaconResponse::ForkVersioned))
938945
}
939946

940947
/// `GET beacon/states/{state_id}/pending_consolidations`

0 commit comments

Comments
 (0)