@@ -760,20 +760,40 @@ def test_is_double_vote(sample_attestation_data_params):
760
760
assert not is_double_vote (attestation_data_1 , attestation_data_3 )
761
761
762
762
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 ):
764
785
attestation_data_1_params = {
765
786
** sample_attestation_data_params ,
766
- 'slot' : 4 ,
767
- 'justified_slot' : 0 ,
768
-
787
+ 'slot' : attestation_1_slot ,
788
+ 'justified_slot' : attestation_1_justified_slot ,
769
789
}
770
790
attestation_data_1 = AttestationData (** attestation_data_1_params )
771
791
772
792
attestation_data_2_params = {
773
793
** sample_attestation_data_params ,
774
- 'slot' : 3 ,
775
- 'justified_slot' : 2 ,
794
+ 'slot' : attestation_2_slot ,
795
+ 'justified_slot' : attestation_2_justified_slot ,
776
796
}
777
797
attestation_data_2 = AttestationData (** attestation_data_2_params )
778
798
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