4
4
ValidatorStatusCode ,
5
5
)
6
6
from eth .beacon .types .attestation_records import AttestationRecord
7
+ from eth .beacon .types .blocks import BaseBeaconBlock
7
8
from eth .beacon .types .shard_committees import ShardCommittee
8
9
from eth .beacon .types .validator_records import ValidatorRecord
9
10
from eth .beacon .helpers import (
10
11
_get_element_from_recent_list ,
11
12
get_active_validator_indices ,
12
13
get_attestation_indices ,
13
14
get_block_hash ,
14
- get_hashes_from_recent_block_hashes ,
15
+ get_hashes_from_latest_block_hashes ,
15
16
get_hashes_to_sign ,
16
17
get_new_shuffling ,
17
18
_get_shard_committees_at_slot ,
@@ -39,18 +40,18 @@ def get_sample_shard_committees_at_slots(num_slot,
39
40
)
40
41
41
42
42
- def generate_mock_recent_block_hashes (
43
+ def generate_mock_latest_block_hashes (
43
44
genesis_block ,
44
45
current_block_number ,
45
46
epoch_length ):
46
47
chain_length = (current_block_number // epoch_length + 1 ) * epoch_length
47
48
blocks = get_pseudo_chain (chain_length , genesis_block )
48
- recent_block_hashes = [
49
+ latest_block_hashes = [
49
50
b'\x00 ' * 32
50
51
for i
51
52
in range (epoch_length * 2 - current_block_number )
52
53
] + [block .hash for block in blocks [:current_block_number ]]
53
- return blocks , recent_block_hashes
54
+ return blocks , latest_block_hashes
54
55
55
56
56
57
@pytest .mark .parametrize (
@@ -88,7 +89,6 @@ def test_get_element_from_recent_list(target_list,
88
89
#
89
90
# Get block hashes
90
91
#
91
- @pytest .mark .xfail (reason = "Need to be fixed" )
92
92
@pytest .mark .parametrize (
93
93
(
94
94
'current_block_number,target_slot,success'
@@ -103,22 +103,22 @@ def test_get_element_from_recent_list(target_list,
103
103
],
104
104
)
105
105
def test_get_block_hash (
106
- genesis_block ,
107
106
current_block_number ,
108
107
target_slot ,
109
108
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 )
112
112
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 ,
115
115
current_block_number ,
116
116
epoch_length ,
117
117
)
118
118
119
119
if success :
120
120
block_hash = get_block_hash (
121
- recent_block_hashes ,
121
+ latest_block_hashes ,
122
122
current_block_number ,
123
123
target_slot ,
124
124
epoch_length ,
@@ -127,7 +127,7 @@ def test_get_block_hash(
127
127
else :
128
128
with pytest .raises (ValueError ):
129
129
get_block_hash (
130
- recent_block_hashes ,
130
+ latest_block_hashes ,
131
131
current_block_number ,
132
132
target_slot ,
133
133
epoch_length ,
@@ -137,28 +137,28 @@ def test_get_block_hash(
137
137
@pytest .mark .xfail (reason = "Need to be fixed" )
138
138
@pytest .mark .parametrize (
139
139
(
140
- 'epoch_length,current_block_slot_number ,from_slot,to_slot'
140
+ 'epoch_length,current_block_slot ,from_slot,to_slot'
141
141
),
142
142
[
143
143
(20 , 10 , 2 , 7 ),
144
144
(20 , 30 , 10 , 20 ),
145
145
],
146
146
)
147
- def test_get_hashes_from_recent_block_hashes (
147
+ def test_get_hashes_from_latest_block_hashes (
148
148
genesis_block ,
149
- current_block_slot_number ,
149
+ current_block_slot ,
150
150
from_slot ,
151
151
to_slot ,
152
152
epoch_length ):
153
- _ , recent_block_hashes = generate_mock_recent_block_hashes (
153
+ _ , latest_block_hashes = generate_mock_latest_block_hashes (
154
154
genesis_block ,
155
- current_block_slot_number ,
155
+ current_block_slot ,
156
156
epoch_length ,
157
157
)
158
158
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 ,
162
162
from_slot ,
163
163
to_slot ,
164
164
epoch_length ,
@@ -169,16 +169,16 @@ def test_get_hashes_from_recent_block_hashes(
169
169
@pytest .mark .xfail (reason = "Need to be fixed" )
170
170
def test_get_hashes_to_sign (genesis_block , epoch_length ):
171
171
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 (
174
174
genesis_block ,
175
- current_block_slot_number ,
175
+ current_block_slot ,
176
176
epoch_length ,
177
177
)
178
178
179
- block = blocks [current_block_slot_number ]
179
+ block = blocks [current_block_slot ]
180
180
result = get_hashes_to_sign (
181
- recent_block_hashes ,
181
+ latest_block_hashes ,
182
182
block ,
183
183
epoch_length ,
184
184
)
@@ -187,25 +187,25 @@ def test_get_hashes_to_sign(genesis_block, epoch_length):
187
187
188
188
189
189
@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 ,
191
191
epoch_length ,
192
192
sample_attestation_record_params ):
193
193
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 (
196
196
genesis_block ,
197
- current_block_slot_number ,
197
+ current_block_slot ,
198
198
epoch_length ,
199
199
)
200
200
201
- block = blocks [current_block_slot_number ]
201
+ block = blocks [current_block_slot ]
202
202
oblique_parent_hashes = [b'\x77 ' * 32 ]
203
203
attestation = AttestationRecord (** sample_attestation_record_params ).copy (
204
204
slot = 10 ,
205
205
oblique_parent_hashes = oblique_parent_hashes ,
206
206
)
207
207
result = get_signed_parent_hashes (
208
- recent_block_hashes ,
208
+ latest_block_hashes ,
209
209
block ,
210
210
attestation ,
211
211
epoch_length ,
@@ -449,12 +449,12 @@ def mock_get_shard_committees_at_slot(parent_block,
449
449
monkeypatch .setattr (
450
450
helpers ,
451
451
'_get_shard_committees_at_slot' ,
452
- mock__get_shard_committees_at_slot
452
+ mock_get_shard_committees_at_slot
453
453
)
454
454
455
455
parent_block = genesis_block
456
456
parent_block = genesis_block .copy (
457
- slot_number = parent_block_number ,
457
+ slot = parent_block_number ,
458
458
)
459
459
460
460
if isinstance (result_proposer_index_in_committee , Exception ):
0 commit comments