Skip to content

Add hypothesis based tests to test Clique RLP types #1869

Open
@cburgdorf

Description

@cburgdorf

What is wrong?

The following test would benefit from some hypothesis based tests to catch more edge cases such as empty data etc.

@pytest.mark.parametrize(
'val, meant_to_be, encode_fn, decode_fn',
(
(ADDRESS_TALLY_PAIRS[0], tuple, encode_address_tally_pair, decode_address_tally_pair),
(DUMMY_VOTE_1, Vote, encode_vote, decode_vote),
(DUMMY_VOTE_2, Vote, encode_vote, decode_vote),
(SNAPSHOT_1, Snapshot, encode_snapshot, decode_snapshot),
(TRUMP_TALLY, Tally, encode_tally, decode_tally),
(YANG_TALLY, Tally, encode_tally, decode_tally)
)
)
def test_encoding_decoding(val, meant_to_be, encode_fn, decode_fn):
assert type(val) is meant_to_be
binary = encode_fn(val)
assert type(binary) is bytes
revived = decode_fn(binary)
assert revived == val

How can it be fixed

Add some hypothesis based test cases

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions