Skip to content

Commit

Permalink
test scale codec for List
Browse files Browse the repository at this point in the history
  • Loading branch information
gshep committed Aug 22, 2024
1 parent 568374c commit 9fceb6a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ethereum-common/src/base_types/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,19 @@ impl<T: TreeHash, const N: usize> TreeHash for List<T, N> {
tree_hash::mix_in_length(&root, self.len())
}
}

#[test]
fn scale_codec_list() {
const N: usize = 100;

let mut list = List::<_, N>::default();

for i in 0..N {
list.push(i as u32);
}

let encoded = Encode::encode(&list);
let decoded = List::decode(&mut &encoded[..]).unwrap();

assert_eq!(list, decoded);
}

0 comments on commit 9fceb6a

Please sign in to comment.