44 ValidatorStatusCode ,
55)
66from eth .beacon .types .attestation_records import AttestationRecord
7+ from eth .beacon .types .blocks import BaseBeaconBlock
78from eth .beacon .types .shard_committees import ShardCommittee
89from eth .beacon .types .validator_records import ValidatorRecord
910from eth .beacon .helpers import (
1011 _get_element_from_recent_list ,
1112 get_active_validator_indices ,
1213 get_attestation_indices ,
1314 get_block_hash ,
14- get_hashes_from_recent_block_hashes ,
15+ get_hashes_from_latest_block_hashes ,
1516 get_hashes_to_sign ,
1617 get_new_shuffling ,
1718 _get_shard_committees_at_slot ,
@@ -39,18 +40,18 @@ def get_sample_shard_committees_at_slots(num_slot,
3940 )
4041
4142
42- def generate_mock_recent_block_hashes (
43+ def generate_mock_latest_block_hashes (
4344 genesis_block ,
4445 current_block_number ,
4546 epoch_length ):
4647 chain_length = (current_block_number // epoch_length + 1 ) * epoch_length
4748 blocks = get_pseudo_chain (chain_length , genesis_block )
48- recent_block_hashes = [
49+ latest_block_hashes = [
4950 b'\x00 ' * 32
5051 for i
5152 in range (epoch_length * 2 - current_block_number )
5253 ] + [block .hash for block in blocks [:current_block_number ]]
53- return blocks , recent_block_hashes
54+ return blocks , latest_block_hashes
5455
5556
5657@pytest .mark .parametrize (
@@ -88,7 +89,6 @@ def test_get_element_from_recent_list(target_list,
8889#
8990# Get block hashes
9091#
91- @pytest .mark .xfail (reason = "Need to be fixed" )
9292@pytest .mark .parametrize (
9393 (
9494 'current_block_number,target_slot,success'
@@ -103,22 +103,22 @@ def test_get_element_from_recent_list(target_list,
103103 ],
104104)
105105def test_get_block_hash (
106- genesis_block ,
107106 current_block_number ,
108107 target_slot ,
109108 success ,
110- epoch_length ):
111- epoch_length = epoch_length
109+ epoch_length ,
110+ sample_beacon_block_params ):
111+ sample_block = BaseBeaconBlock (** sample_beacon_block_params )
112112
113- blocks , recent_block_hashes = generate_mock_recent_block_hashes (
114- genesis_block ,
113+ blocks , latest_block_hashes = generate_mock_latest_block_hashes (
114+ sample_block ,
115115 current_block_number ,
116116 epoch_length ,
117117 )
118118
119119 if success :
120120 block_hash = get_block_hash (
121- recent_block_hashes ,
121+ latest_block_hashes ,
122122 current_block_number ,
123123 target_slot ,
124124 epoch_length ,
@@ -127,7 +127,7 @@ def test_get_block_hash(
127127 else :
128128 with pytest .raises (ValueError ):
129129 get_block_hash (
130- recent_block_hashes ,
130+ latest_block_hashes ,
131131 current_block_number ,
132132 target_slot ,
133133 epoch_length ,
@@ -137,28 +137,28 @@ def test_get_block_hash(
137137@pytest .mark .xfail (reason = "Need to be fixed" )
138138@pytest .mark .parametrize (
139139 (
140- 'epoch_length,current_block_slot_number ,from_slot,to_slot'
140+ 'epoch_length,current_block_slot ,from_slot,to_slot'
141141 ),
142142 [
143143 (20 , 10 , 2 , 7 ),
144144 (20 , 30 , 10 , 20 ),
145145 ],
146146)
147- def test_get_hashes_from_recent_block_hashes (
147+ def test_get_hashes_from_latest_block_hashes (
148148 genesis_block ,
149- current_block_slot_number ,
149+ current_block_slot ,
150150 from_slot ,
151151 to_slot ,
152152 epoch_length ):
153- _ , recent_block_hashes = generate_mock_recent_block_hashes (
153+ _ , latest_block_hashes = generate_mock_latest_block_hashes (
154154 genesis_block ,
155- current_block_slot_number ,
155+ current_block_slot ,
156156 epoch_length ,
157157 )
158158
159- result = get_hashes_from_recent_block_hashes (
160- recent_block_hashes ,
161- current_block_slot_number ,
159+ result = get_hashes_from_latest_block_hashes (
160+ latest_block_hashes ,
161+ current_block_slot ,
162162 from_slot ,
163163 to_slot ,
164164 epoch_length ,
@@ -169,16 +169,16 @@ def test_get_hashes_from_recent_block_hashes(
169169@pytest .mark .xfail (reason = "Need to be fixed" )
170170def test_get_hashes_to_sign (genesis_block , epoch_length ):
171171 epoch_length = epoch_length
172- current_block_slot_number = 1
173- blocks , recent_block_hashes = generate_mock_recent_block_hashes (
172+ current_block_slot = 1
173+ blocks , latest_block_hashes = generate_mock_latest_block_hashes (
174174 genesis_block ,
175- current_block_slot_number ,
175+ current_block_slot ,
176176 epoch_length ,
177177 )
178178
179- block = blocks [current_block_slot_number ]
179+ block = blocks [current_block_slot ]
180180 result = get_hashes_to_sign (
181- recent_block_hashes ,
181+ latest_block_hashes ,
182182 block ,
183183 epoch_length ,
184184 )
@@ -187,25 +187,25 @@ def test_get_hashes_to_sign(genesis_block, epoch_length):
187187
188188
189189@pytest .mark .xfail (reason = "Need to be fixed" )
190- def test_get_new_recent_block_hashes (genesis_block ,
190+ def test_get_new_latest_block_hashes (genesis_block ,
191191 epoch_length ,
192192 sample_attestation_record_params ):
193193 epoch_length = epoch_length
194- current_block_slot_number = 15
195- blocks , recent_block_hashes = generate_mock_recent_block_hashes (
194+ current_block_slot = 15
195+ blocks , latest_block_hashes = generate_mock_latest_block_hashes (
196196 genesis_block ,
197- current_block_slot_number ,
197+ current_block_slot ,
198198 epoch_length ,
199199 )
200200
201- block = blocks [current_block_slot_number ]
201+ block = blocks [current_block_slot ]
202202 oblique_parent_hashes = [b'\x77 ' * 32 ]
203203 attestation = AttestationRecord (** sample_attestation_record_params ).copy (
204204 slot = 10 ,
205205 oblique_parent_hashes = oblique_parent_hashes ,
206206 )
207207 result = get_signed_parent_hashes (
208- recent_block_hashes ,
208+ latest_block_hashes ,
209209 block ,
210210 attestation ,
211211 epoch_length ,
@@ -449,12 +449,12 @@ def mock_get_shard_committees_at_slot(parent_block,
449449 monkeypatch .setattr (
450450 helpers ,
451451 '_get_shard_committees_at_slot' ,
452- mock__get_shard_committees_at_slot
452+ mock_get_shard_committees_at_slot
453453 )
454454
455455 parent_block = genesis_block
456456 parent_block = genesis_block .copy (
457- slot_number = parent_block_number ,
457+ slot = parent_block_number ,
458458 )
459459
460460 if isinstance (result_proposer_index_in_committee , Exception ):
0 commit comments