mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
404's on API requests for slots that have been skipped or orphaned (#2272)
## Issue Addressed Resolves #2186 ## Proposed Changes 404 for any block-related information on a slot that was skipped or orphaned Affected endpoints: - `/eth/v1/beacon/blocks/{block_id}` - `/eth/v1/beacon/blocks/{block_id}/root` - `/eth/v1/beacon/blocks/{block_id}/attestations` - `/eth/v1/beacon/headers/{block_id}` ## Additional Info Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
@@ -880,6 +880,14 @@ impl ApiTester {
|
||||
|
||||
let block_root_opt = self.get_block_root(block_id);
|
||||
|
||||
if let BlockId::Slot(slot) = block_id {
|
||||
if block_root_opt.is_none() {
|
||||
assert!(SKIPPED_SLOTS.contains(&slot.as_u64()));
|
||||
} else {
|
||||
assert!(!SKIPPED_SLOTS.contains(&slot.as_u64()));
|
||||
}
|
||||
}
|
||||
|
||||
let block_opt = block_root_opt.and_then(|root| self.chain.get_block(&root).unwrap());
|
||||
|
||||
if block_opt.is_none() && result.is_none() {
|
||||
@@ -924,7 +932,13 @@ impl ApiTester {
|
||||
.map(|res| res.data.root);
|
||||
|
||||
let expected = self.get_block_root(block_id);
|
||||
|
||||
if let BlockId::Slot(slot) = block_id {
|
||||
if expected.is_none() {
|
||||
assert!(SKIPPED_SLOTS.contains(&slot.as_u64()));
|
||||
} else {
|
||||
assert!(!SKIPPED_SLOTS.contains(&slot.as_u64()));
|
||||
}
|
||||
}
|
||||
assert_eq!(result, expected, "{:?}", block_id);
|
||||
}
|
||||
|
||||
@@ -962,6 +976,14 @@ impl ApiTester {
|
||||
for block_id in self.interesting_block_ids() {
|
||||
let expected = self.get_block(block_id);
|
||||
|
||||
if let BlockId::Slot(slot) = block_id {
|
||||
if expected.is_none() {
|
||||
assert!(SKIPPED_SLOTS.contains(&slot.as_u64()));
|
||||
} else {
|
||||
assert!(!SKIPPED_SLOTS.contains(&slot.as_u64()));
|
||||
}
|
||||
}
|
||||
|
||||
let json_result = self
|
||||
.client
|
||||
.get_beacon_blocks(block_id)
|
||||
@@ -990,6 +1012,14 @@ impl ApiTester {
|
||||
.get_block(block_id)
|
||||
.map(|block| block.message.body.attestations.into());
|
||||
|
||||
if let BlockId::Slot(slot) = block_id {
|
||||
if expected.is_none() {
|
||||
assert!(SKIPPED_SLOTS.contains(&slot.as_u64()));
|
||||
} else {
|
||||
assert!(!SKIPPED_SLOTS.contains(&slot.as_u64()));
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(result, expected, "{:?}", block_id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user