Skip to content

Commit

Permalink
Some bonus byte-sequence length validity tests
Browse files Browse the repository at this point in the history
Inspired by reviewing 180f6d0 in #117
  • Loading branch information
carver committed Aug 18, 2022
1 parent 5a17b4e commit 2d3ab10
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/sedes/test_composite_sedes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from ssz.sedes import (
Bitlist,
Bitvector,
ByteList,
ByteVector,
Container,
List,
UInt,
Expand Down Expand Up @@ -195,6 +197,25 @@ def test_homogeneous_sequence_length_boundary(
sedes_type(element_type, length)


@pytest.mark.parametrize(
("sedes_type", "length", "is_valid"),
(
(ByteList, 0, True),
(ByteList, -1, False),
(ByteVector, 1, True),
(ByteVector, 0, False),
),
)
def test_byte_sequence_length_boundary(
sedes_type, length, is_valid
):
if is_valid:
sedes_type(length)
else:
with pytest.raises(ValueError):
sedes_type(length)


@pytest.mark.parametrize(
("sedes_type", "length", "is_valid"),
(
Expand Down

0 comments on commit 2d3ab10

Please sign in to comment.