mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-12 14:00:06 +00:00
Fix failing SOS tests, add new failing tests
This commit is contained in:
parent
3f9430ddff
commit
9943e70cb9
@ -43,6 +43,8 @@ impl<T: Decodable> Decodable for Vec<T> {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
|
||||
// The list is non-empty.
|
||||
|
||||
if T::is_ssz_fixed_len() {
|
||||
Ok(bytes
|
||||
.chunks(T::ssz_fixed_len())
|
||||
@ -65,19 +67,16 @@ impl<T: Decodable> Decodable for Vec<T> {
|
||||
for i in 1..=num_elems {
|
||||
let chunk = &bytes[(i - 1) * BYTES_PER_LENGTH_OFFSET..i * BYTES_PER_LENGTH_OFFSET];
|
||||
|
||||
dbg!(offset);
|
||||
let slice = if i == num_elems {
|
||||
&variable[offset..]
|
||||
} else {
|
||||
let start = offset;
|
||||
offset = decode_length(chunk)? - fixed.len();
|
||||
|
||||
let end = offset + decode_length(chunk)?;
|
||||
let slice = &variable[offset..end];
|
||||
offset += end;
|
||||
&variable[start..offset]
|
||||
};
|
||||
|
||||
values.push(T::from_ssz_bytes(slice)?);
|
||||
|
||||
if i == num_elems {
|
||||
let slice = &variable[offset..];
|
||||
dbg!(slice);
|
||||
values.push(T::from_ssz_bytes(slice)?)
|
||||
}
|
||||
}
|
||||
|
||||
Ok(values)
|
||||
|
@ -157,6 +157,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn vec_of_vec_of_u8() {
|
||||
let vec: Vec<Vec<u8>> = vec![];
|
||||
assert_eq!(vec.as_ssz_bytes(), vec![]);
|
||||
|
||||
let vec: Vec<Vec<u8>> = vec![vec![]];
|
||||
assert_eq!(vec.as_ssz_bytes(), vec![4, 0, 0, 0]);
|
||||
|
||||
|
@ -16,7 +16,9 @@ fn vec_u16_round_trip() {
|
||||
|
||||
#[test]
|
||||
fn vec_of_vec_u16_round_trip() {
|
||||
// round_trip::<Vec<Vec<u16>>>(vec![]);
|
||||
round_trip::<Vec<Vec<u16>>>(vec![]);
|
||||
round_trip::<Vec<Vec<u16>>>(vec![vec![]]);
|
||||
// round_trip::<Vec<Vec<u16>>>(vec![vec![], vec![]]);
|
||||
round_trip::<Vec<Vec<u16>>>(vec![vec![], vec![]]);
|
||||
round_trip::<Vec<Vec<u16>>>(vec![vec![], vec![1, 2, 3]]);
|
||||
round_trip::<Vec<Vec<u16>>>(vec![vec![1, 2, 3], vec![1, 2, 3]]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user