From a4e61541aa156ef8388b96552a98d9505745b997 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 20 Sep 2018 13:56:44 +1000 Subject: [PATCH] Add SszBlock test to check the canonical hash --- lighthouse/state/block/ssz_block.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lighthouse/state/block/ssz_block.rs b/lighthouse/state/block/ssz_block.rs index 79175b3c22..4d51c3a913 100644 --- a/lighthouse/state/block/ssz_block.rs +++ b/lighthouse/state/block/ssz_block.rs @@ -222,6 +222,15 @@ mod tests { 58, 145, 52, 47, 62, 158, 131, 46, 147 ]; assert_eq!(hash, expected_hash); + + /* + * Test if you give the SszBlock too many ssz bytes + */ + let mut too_long = serialized.clone(); + too_long.push(42); + let ssz_block = SszBlock::from_slice(&too_long).unwrap(); + let hash = ssz_block.block_hash(); + assert_eq!(hash, expected_hash); } #[test]