Add partial progress on sos

This commit is contained in:
Paul Hauner
2019-05-03 11:05:51 +10:00
parent c5acbd978f
commit 3f9430ddff
6 changed files with 658 additions and 330 deletions

View File

@@ -0,0 +1,22 @@
use ssz2::{Decodable, Encodable};
fn round_trip<T: Encodable + Decodable + std::fmt::Debug + PartialEq>(item: T) {
let encoded = &item.as_ssz_bytes();
dbg!(encoded);
assert_eq!(T::from_ssz_bytes(&encoded), Ok(item));
}
#[test]
fn vec_u16_round_trip() {
round_trip::<Vec<u16>>(vec![]);
round_trip::<Vec<u16>>(vec![255]);
round_trip::<Vec<u16>>(vec![0, 1, 2]);
round_trip::<Vec<u16>>(vec![100; 64]);
}
#[test]
fn vec_of_vec_u16_round_trip() {
// round_trip::<Vec<Vec<u16>>>(vec![]);
round_trip::<Vec<Vec<u16>>>(vec![vec![]]);
// round_trip::<Vec<Vec<u16>>>(vec![vec![], vec![]]);
}