mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 14:54:45 +00:00
Reject octet-stream content type when we expect json (#5862)
* reject octet-stream content type when we expect json * added a test, fixed a bug with checking for 415's
This commit is contained in:
@@ -10,7 +10,9 @@ use eth2::{
|
||||
types::{
|
||||
BlockId as CoreBlockId, ForkChoiceNode, ProduceBlockV3Response, StateId as CoreStateId, *,
|
||||
},
|
||||
BeaconNodeHttpClient, Error, StatusCode, Timeouts,
|
||||
BeaconNodeHttpClient, Error,
|
||||
Error::ServerMessage,
|
||||
StatusCode, Timeouts,
|
||||
};
|
||||
use execution_layer::test_utils::{
|
||||
MockBuilder, Operation, DEFAULT_BUILDER_PAYLOAD_VALUE_WEI, DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI,
|
||||
@@ -807,6 +809,39 @@ impl ApiTester {
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn post_beacon_states_validator_balances_unsupported_media_failure(self) -> Self {
|
||||
for state_id in self.interesting_state_ids() {
|
||||
for validator_indices in self.interesting_validator_indices() {
|
||||
let validator_index_ids = validator_indices
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|i| ValidatorId::Index(i))
|
||||
.collect::<Vec<ValidatorId>>();
|
||||
|
||||
let unsupported_media_response = self
|
||||
.client
|
||||
.post_beacon_states_validator_balances_with_ssz_header(
|
||||
state_id.0,
|
||||
validator_index_ids,
|
||||
)
|
||||
.await;
|
||||
|
||||
if let Err(unsupported_media_response) = unsupported_media_response {
|
||||
match unsupported_media_response {
|
||||
ServerMessage(error) => {
|
||||
assert_eq!(error.code, 415)
|
||||
}
|
||||
_ => panic!("Should error with unsupported media response"),
|
||||
}
|
||||
} else {
|
||||
panic!("Should error with unsupported media response");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_beacon_states_validator_balances(self) -> Self {
|
||||
for state_id in self.interesting_state_ids() {
|
||||
for validator_indices in self.interesting_validator_indices() {
|
||||
@@ -5660,6 +5695,14 @@ async fn get_events_from_genesis() {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_unsupported_media_response() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.post_beacon_states_validator_balances_unsupported_media_failure()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn beacon_get() {
|
||||
ApiTester::new()
|
||||
|
||||
Reference in New Issue
Block a user