Skip to content

Commit 9fceb6a

Browse files
committed
test scale codec for List
1 parent 568374c commit 9fceb6a

File tree

1 file changed

+16
-0
lines changed
  • ethereum-common/src/base_types

1 file changed

+16
-0
lines changed

ethereum-common/src/base_types/list.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,19 @@ impl<T: TreeHash, const N: usize> TreeHash for List<T, N> {
245245
tree_hash::mix_in_length(&root, self.len())
246246
}
247247
}
248+
249+
#[test]
250+
fn scale_codec_list() {
251+
const N: usize = 100;
252+
253+
let mut list = List::<_, N>::default();
254+
255+
for i in 0..N {
256+
list.push(i as u32);
257+
}
258+
259+
let encoded = Encode::encode(&list);
260+
let decoded = List::decode(&mut &encoded[..]).unwrap();
261+
262+
assert_eq!(list, decoded);
263+
}

0 commit comments

Comments
 (0)