21
21
22
22
@pytest .mark .parametrize (
23
23
(
24
- 'attestation_slot,current_slot,epoch_length,'
25
- 'min_attestation_inclusion_delay,is_valid'
24
+ 'attestation_slot,'
25
+ 'current_slot,'
26
+ 'epoch_length,'
27
+ 'min_attestation_inclusion_delay,'
28
+ 'is_valid,'
26
29
),
27
30
[
28
31
(0 , 5 , 5 , 1 , True ),
29
32
(0 , 5 , 5 , 5 , True ),
30
- (0 , 5 , 5 , 6 , False ), # not past min inclusion delay
31
- (7 , 5 , 10 , 1 , False ), # attestation slot in future
33
+ (0 , 5 , 5 , 6 , False ), # attestation_slot + in_attestation_inclusion_delay > current_slot
34
+ (7 , 5 , 10 , 1 , False ), # attestation_slot > current_slot
32
35
(10 , 20 , 10 , 2 , True ),
33
- (9 , 20 , 10 , 2 , False ), # more than epoch_length slots have past
36
+ (9 , 20 , 10 , 2 , False ), # attestation_slot + EPOCH_LENGTH < current_slot
34
37
]
35
38
)
36
39
def test_validate_attestation_slot (sample_attestation_data_params ,
@@ -39,8 +42,9 @@ def test_validate_attestation_slot(sample_attestation_data_params,
39
42
epoch_length ,
40
43
min_attestation_inclusion_delay ,
41
44
is_valid ):
42
- sample_attestation_data_params ['slot' ] = attestation_slot
43
- attestation_data = AttestationData (** sample_attestation_data_params )
45
+ attestation_data = AttestationData (** sample_attestation_data_params ).copy (
46
+ slot = attestation_slot ,
47
+ )
44
48
45
49
if is_valid :
46
50
validate_attestation_slot (
@@ -67,15 +71,15 @@ def test_validate_attestation_slot(sample_attestation_data_params,
67
71
'previous_justified_slot,'
68
72
'justified_slot,'
69
73
'epoch_length,'
70
- 'is_valid'
74
+ 'is_valid, '
71
75
),
72
76
[
73
77
(13 , 5 , 14 , 0 , 5 , 5 , True ),
74
- (13 , 0 , 14 , 0 , 5 , 5 , False ), # targeting previous but should be targeting current
75
- (13 , 20 , 14 , 0 , 5 , 5 , False ), # targeting future slot but should be targeting current
78
+ (13 , 0 , 14 , 0 , 5 , 5 , False ), # targeting previous_justified_slot, should be targeting justified_slot # noqa: E501
79
+ (13 , 20 , 14 , 0 , 5 , 5 , False ), # targeting future slot, should be targeting justified_slot
76
80
(29 , 10 , 30 , 10 , 20 , 10 , True ),
77
- (29 , 20 , 30 , 10 , 20 , 10 , False ), # targeting current but should be targeting previous
78
- (29 , 36 , 30 , 10 , 20 , 10 , False ), # targeting future slot but should be targeting previous
81
+ (29 , 20 , 30 , 10 , 20 , 10 , False ), # targeting justified_slot, should be targeting previous_justified_slot # noqa: E501
82
+ (29 , 36 , 30 , 10 , 20 , 10 , False ), # targeting future slot, should be targeting previous_justified_slot # noqa: E501
79
83
(10 , 10 , 10 , 10 , 10 , 10 , True ),
80
84
]
81
85
)
@@ -87,9 +91,10 @@ def test_validate_attestation_justified_slot(sample_attestation_data_params,
87
91
justified_slot ,
88
92
epoch_length ,
89
93
is_valid ):
90
- sample_attestation_data_params ['slot' ] = attestation_slot
91
- sample_attestation_data_params ['justified_slot' ] = attestation_justified_slot
92
- attestation_data = AttestationData (** sample_attestation_data_params )
94
+ attestation_data = AttestationData (** sample_attestation_data_params ).copy (
95
+ slot = attestation_slot ,
96
+ justified_slot = attestation_justified_slot ,
97
+ )
93
98
94
99
if is_valid :
95
100
validate_attestation_justified_slot (
@@ -114,19 +119,20 @@ def test_validate_attestation_justified_slot(sample_attestation_data_params,
114
119
(
115
120
'attestation_justified_block_root,'
116
121
'justified_block_root,'
117
- 'is_valid'
122
+ 'is_valid, '
118
123
),
119
124
[
120
- (b'\x42 ' * 32 , b'\x35 ' * 32 , False ),
125
+ (b'\x42 ' * 32 , b'\x35 ' * 32 , False ), # attestation.justified_block_root != justified_block_root # noqa: E501
121
126
(b'\x42 ' * 32 , b'\x42 ' * 32 , True ),
122
127
]
123
128
)
124
129
def test_validate_attestation_justified_block_root (sample_attestation_data_params ,
125
130
attestation_justified_block_root ,
126
131
justified_block_root ,
127
132
is_valid ):
128
- sample_attestation_data_params ['justified_block_hash' ] = attestation_justified_block_root
129
- attestation_data = AttestationData (** sample_attestation_data_params )
133
+ attestation_data = AttestationData (** sample_attestation_data_params ).copy (
134
+ justified_block_root = attestation_justified_block_root ,
135
+ )
130
136
131
137
if is_valid :
132
138
validate_attestation_justified_block_root (
@@ -143,10 +149,10 @@ def test_validate_attestation_justified_block_root(sample_attestation_data_param
143
149
144
150
@pytest .mark .parametrize (
145
151
(
146
- 'attestation_latest_crosslink_hash ,'
147
- 'attestation_shard_block_hash ,'
152
+ 'attestation_latest_crosslink_root ,'
153
+ 'attestation_shard_block_root ,'
148
154
'latest_crosslink_shard_block_root,'
149
- 'is_valid'
155
+ 'is_valid, '
150
156
),
151
157
[
152
158
(b'\x66 ' * 32 , b'\x42 ' * 32 , b'\x35 ' * 32 , False ),
@@ -157,13 +163,16 @@ def test_validate_attestation_justified_block_root(sample_attestation_data_param
157
163
]
158
164
)
159
165
def test_validate_attestation_latest_crosslink_root (sample_attestation_data_params ,
160
- attestation_latest_crosslink_hash ,
161
- attestation_shard_block_hash ,
166
+ attestation_latest_crosslink_root ,
167
+ attestation_shard_block_root ,
162
168
latest_crosslink_shard_block_root ,
163
169
is_valid ):
164
- sample_attestation_data_params ['latest_crosslink_hash' ] = attestation_latest_crosslink_hash
165
- sample_attestation_data_params ['shard_block_hash' ] = attestation_shard_block_hash
166
- attestation_data = AttestationData (** sample_attestation_data_params )
170
+ sample_attestation_data_params ['latest_crosslink_root' ] = attestation_latest_crosslink_root
171
+ sample_attestation_data_params ['shard_block_root' ] = attestation_shard_block_root
172
+ attestation_data = AttestationData (** sample_attestation_data_params ).copy (
173
+ latest_crosslink_root = attestation_latest_crosslink_root ,
174
+ shard_block_root = attestation_shard_block_root ,
175
+ )
167
176
168
177
if is_valid :
169
178
validate_attestation_latest_crosslink_root (
@@ -180,7 +189,8 @@ def test_validate_attestation_latest_crosslink_root(sample_attestation_data_para
180
189
181
190
@pytest .mark .parametrize (
182
191
(
183
- 'attestation_shard_block_hash,is_valid'
192
+ 'attestation_shard_block_root,'
193
+ 'is_valid,'
184
194
),
185
195
[
186
196
(ZERO_HASH32 , True ),
@@ -189,10 +199,11 @@ def test_validate_attestation_latest_crosslink_root(sample_attestation_data_para
189
199
]
190
200
)
191
201
def test_validate_attestation_shard_block_root (sample_attestation_data_params ,
192
- attestation_shard_block_hash ,
202
+ attestation_shard_block_root ,
193
203
is_valid ):
194
- sample_attestation_data_params ['shard_block_hash' ] = attestation_shard_block_hash
195
- attestation_data = AttestationData (** sample_attestation_data_params )
204
+ attestation_data = AttestationData (** sample_attestation_data_params ).copy (
205
+ shard_block_root = attestation_shard_block_root ,
206
+ )
196
207
197
208
if is_valid :
198
209
validate_attestation_shard_block_root (
@@ -206,4 +217,4 @@ def test_validate_attestation_shard_block_root(sample_attestation_data_params,
206
217
207
218
208
219
def test_validate_attestation_aggregate_signature ():
209
- pass
220
+ pass
0 commit comments