Skip to content

Commit eec09eb

Browse files
committed
Add more test cases to is_surround_vote with pytest parametrize
1 parent 11f2a56 commit eec09eb

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

tests/beacon/test_helpers.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -760,20 +760,40 @@ def test_is_double_vote(sample_attestation_data_params):
760760
assert not is_double_vote(attestation_data_1, attestation_data_3)
761761

762762

763-
def test_is_surround_vote(sample_attestation_data_params):
763+
@pytest.mark.parametrize(
764+
(
765+
'attestation_1_slot,'
766+
'attestation_1_justified_slot,'
767+
'attestation_2_slot,'
768+
'attestation_2_justified_slot,'
769+
'expected'
770+
),
771+
[
772+
(0, 0, 0, 0, False),
773+
(4, 3, 3, 2, False), # not (attestation_1_justified_slot < attestation_2_justified_slot
774+
(4, 0, 3, 1, False), # not (attestation_2_justified_slot + 1 == attestation_2_slot)
775+
(4, 0, 4, 3, False), # not (attestation_2_slot < attestation_1_slot)
776+
(4, 0, 3, 2, True),
777+
],
778+
)
779+
def test_is_surround_vote(sample_attestation_data_params,
780+
attestation_1_slot,
781+
attestation_1_justified_slot,
782+
attestation_2_slot,
783+
attestation_2_justified_slot,
784+
expected):
764785
attestation_data_1_params = {
765786
**sample_attestation_data_params,
766-
'slot': 4,
767-
'justified_slot': 0,
768-
787+
'slot': attestation_1_slot,
788+
'justified_slot': attestation_1_justified_slot,
769789
}
770790
attestation_data_1 = AttestationData(**attestation_data_1_params)
771791

772792
attestation_data_2_params = {
773793
**sample_attestation_data_params,
774-
'slot': 3,
775-
'justified_slot': 2,
794+
'slot': attestation_2_slot,
795+
'justified_slot': attestation_2_justified_slot,
776796
}
777797
attestation_data_2 = AttestationData(**attestation_data_2_params)
778798

779-
assert is_surround_vote(attestation_data_1, attestation_data_2)
799+
assert is_surround_vote(attestation_data_1, attestation_data_2) == expected

0 commit comments

Comments
 (0)