mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Arbitrary trait for eth2/types (#1040)
* Add the arbitrary type to eth2/types and their deps Signed-off-by: Kirk Baird <baird.k@outlook.com> * Wrap arbitrary in a feature flag Signed-off-by: Kirk Baird <baird.k@outlook.com> * Fix feature for types Signed-off-by: Kirk Baird <baird.k@outlook.com> * Fix comment Signed-off-by: Kirk Baird <baird.k@outlook.com> * Patch versioning Signed-off-by: Kirk Baird <baird.k@outlook.com> * Allow expanded crate reference for arbitrary 0.4.3 Signed-off-by: Kirk Baird <baird.k@outlook.com> * Add arbitrary to remaining types Signed-off-by: Kirk Baird <baird.k@outlook.com> * use cmp::min Signed-off-by: Kirk Baird <baird.k@outlook.com> * Derive Arbitrary trait for ValidatorStatus, TotalBalances and InclusionInfo * Add CI check for state processing arbitrary faetures Signed-off-by: Kirk Baird <baird.k@outlook.com> * Fix indentation Signed-off-by: Kirk Baird <baird.k@outlook.com> Co-authored-by: Mehdi Zerouali <mehdi@sigmaprime.io>
This commit is contained in:
@@ -252,5 +252,14 @@ macro_rules! bytes_struct {
|
||||
Ok(signature)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
impl $crate::arbitrary::Arbitrary for $name {
|
||||
fn arbitrary(u: &mut $crate::arbitrary::Unstructured<'_>) -> $crate::arbitrary::Result<Self> {
|
||||
let mut bytes = [0u8; $byte_size];
|
||||
u.fill_buffer(&mut bytes)?;
|
||||
Self::from_bytes(&bytes).map_err(|_| $crate::arbitrary::Error::IncorrectFormat)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user