mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Implement /eth/v1/beacon/blobs endpoint (#8103)
* #8085 Co-Authored-By: Tan Chee Keong <tanck@sigmaprime.io> Co-Authored-By: chonghe <44791194+chong-he@users.noreply.github.com>
This commit is contained in:
@@ -25,6 +25,7 @@ pub struct ForkVersionedResponse<T, M = EmptyMetadata> {
|
||||
/// `Deserialize`.
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
pub struct UnversionedResponse<T, M = EmptyMetadata> {
|
||||
#[serde(flatten)]
|
||||
pub metadata: M,
|
||||
pub data: T,
|
||||
}
|
||||
@@ -195,9 +196,10 @@ impl<T, M> From<UnversionedResponse<T, M>> for BeaconResponse<T, M> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod fork_version_response_tests {
|
||||
use crate::beacon_response::ExecutionOptimisticFinalizedMetadata;
|
||||
use crate::{
|
||||
ExecutionPayload, ExecutionPayloadBellatrix, ForkName, ForkVersionedResponse,
|
||||
MainnetEthSpec,
|
||||
MainnetEthSpec, UnversionedResponse,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
||||
@@ -236,4 +238,24 @@ mod fork_version_response_tests {
|
||||
|
||||
assert!(result.is_err());
|
||||
}
|
||||
|
||||
// The following test should only pass by having the attribute #[serde(flatten)] on the metadata
|
||||
#[test]
|
||||
fn unversioned_response_serialize_dezerialize_round_trip_test() {
|
||||
// Create an UnversionedResponse with some data
|
||||
let data = UnversionedResponse {
|
||||
metadata: ExecutionOptimisticFinalizedMetadata {
|
||||
execution_optimistic: Some(false),
|
||||
finalized: Some(false),
|
||||
},
|
||||
data: "some_test_data".to_string(),
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&data);
|
||||
|
||||
let deserialized =
|
||||
serde_json::from_str(&serialized.unwrap()).expect("Failed to deserialize");
|
||||
|
||||
assert_eq!(data, deserialized);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user