mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 21:04:41 +00:00
More testing for api
This commit is contained in:
@@ -15,10 +15,10 @@ use std::sync::Arc;
|
||||
use store::{iter::AncestorIter, Store};
|
||||
use tokio::sync::mpsc;
|
||||
use types::{
|
||||
Attestation, BeaconBlock, BeaconState, EthSpec, Hash256, RelativeEpoch, Signature, Slot,
|
||||
Attestation, BeaconBlock, BeaconState, Epoch, EthSpec, Hash256, RelativeEpoch, Signature, Slot,
|
||||
};
|
||||
|
||||
/// Parse a slot from a `0x` preixed string.
|
||||
/// Parse a slot.
|
||||
///
|
||||
/// E.g., `"1234"`
|
||||
pub fn parse_slot(string: &str) -> Result<Slot, ApiError> {
|
||||
@@ -28,6 +28,16 @@ pub fn parse_slot(string: &str) -> Result<Slot, ApiError> {
|
||||
.map_err(|e| ApiError::BadRequest(format!("Unable to parse slot: {:?}", e)))
|
||||
}
|
||||
|
||||
/// Parse an epoch.
|
||||
///
|
||||
/// E.g., `"13"`
|
||||
pub fn parse_epoch(string: &str) -> Result<Epoch, ApiError> {
|
||||
string
|
||||
.parse::<u64>()
|
||||
.map(Epoch::from)
|
||||
.map_err(|e| ApiError::BadRequest(format!("Unable to parse epoch: {:?}", e)))
|
||||
}
|
||||
|
||||
/// Checks the provided request to ensure that the `content-type` header.
|
||||
///
|
||||
/// The content-type header should either be omitted, in which case JSON is assumed, or it should
|
||||
|
||||
Reference in New Issue
Block a user