diff --git a/ssz/src/bitfield.rs b/ssz/src/bitfield.rs index ff34299..321c18b 100644 --- a/ssz/src/bitfield.rs +++ b/ssz/src/bitfield.rs @@ -135,7 +135,7 @@ impl Bitfield> { }) } else { Err(Error::OutOfBounds { - i: Self::max_len(), + i: num_bits, len: Self::max_len(), }) } @@ -1429,4 +1429,10 @@ mod bitlist { // Can't extend a BitList to a smaller BitList resized_bit_list.resize::().unwrap_err(); } + + #[test] + fn over_capacity_err() { + let e = BitList8::with_capacity(9).expect_err("over-sized bit list"); + assert_eq!(e, Error::OutOfBounds{ i: 9, len: 8 }); + } }