mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
Add beacon state test builder, tidy errors
This commit is contained in:
@@ -3,7 +3,7 @@ use hashing::hash;
|
||||
use log::debug;
|
||||
use ssz::{ssz_encode, TreeHash};
|
||||
use types::{
|
||||
beacon_state::{AttestationValidationError, CommitteesError},
|
||||
beacon_state::{AttestationParticipantsError, BeaconStateError},
|
||||
AggregatePublicKey, Attestation, BeaconBlock, BeaconState, ChainSpec, Crosslink, Epoch, Exit,
|
||||
Fork, Hash256, PendingAttestation, PublicKey, Signature,
|
||||
};
|
||||
@@ -41,10 +41,23 @@ pub enum Error {
|
||||
BadCustodyReseeds,
|
||||
BadCustodyChallenges,
|
||||
BadCustodyResponses,
|
||||
CommitteesError(CommitteesError),
|
||||
BeaconStateError(BeaconStateError),
|
||||
SlotProcessingError(SlotProcessingError),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum AttestationValidationError {
|
||||
IncludedTooEarly,
|
||||
IncludedTooLate,
|
||||
WrongJustifiedSlot,
|
||||
WrongJustifiedRoot,
|
||||
BadLatestCrosslinkRoot,
|
||||
BadSignature,
|
||||
ShardBlockRootNotZero,
|
||||
NoBlockRoot,
|
||||
AttestationParticipantsError(AttestationParticipantsError),
|
||||
}
|
||||
|
||||
macro_rules! ensure {
|
||||
($condition: expr, $result: expr) => {
|
||||
if !$condition {
|
||||
@@ -390,9 +403,9 @@ impl From<AttestationValidationError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CommitteesError> for Error {
|
||||
fn from(e: CommitteesError) -> Error {
|
||||
Error::CommitteesError(e)
|
||||
impl From<BeaconStateError> for Error {
|
||||
fn from(e: BeaconStateError) -> Error {
|
||||
Error::BeaconStateError(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,3 +414,9 @@ impl From<SlotProcessingError> for Error {
|
||||
Error::SlotProcessingError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AttestationParticipantsError> for AttestationValidationError {
|
||||
fn from(e: AttestationParticipantsError) -> AttestationValidationError {
|
||||
AttestationValidationError::AttestationParticipantsError(e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user