Merge ssz little endian branch

This commit is contained in:
Kirk Baird
2019-03-26 15:44:01 +11:00
45 changed files with 14240 additions and 266 deletions

View File

@@ -130,4 +130,15 @@ mod epoch_tests {
assert_eq!(Slot::from(i), slots[i as usize])
}
}
#[test]
fn max_epoch_ssz() {
let max_epoch = Epoch::max_value();
let mut ssz = SszStream::new();
ssz.append(&max_epoch);
let encoded = ssz.drain();
assert_eq!(&encoded, &[255, 255, 255, 255, 255, 255, 255, 255]);
let (decoded, _i): (Epoch, usize) = <_>::ssz_decode(&encoded, 0).unwrap();
assert_eq!(max_epoch, decoded);
}
}

View File

@@ -5,13 +5,13 @@ macro_rules! ssz_tests {
#[test]
pub fn test_ssz_round_trip() {
use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use ssz::{ssz_encode, Decodable};
use ssz::{decode, ssz_encode};
let mut rng = XorShiftRng::from_seed([42; 16]);
let original = $type::random_for_test(&mut rng);
let bytes = ssz_encode(&original);
let (decoded, _) = $type::ssz_decode(&bytes, 0).unwrap();
let decoded: $type = decode(&bytes).unwrap();
assert_eq!(original, decoded);
}