Skip to content

Commit d29578a

Browse files
committed
PR feedback
1 parent 7262b86 commit d29578a

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

eth/beacon/helpers.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,22 @@ def _get_block_root(
7474
Return the block root at a recent ``slot``.
7575
"""
7676
if state_slot > slot + latest_block_roots_length:
77-
raise ValueError(
78-
"state.slot (%s) should be less than or equal to "
79-
"(slot + latest_block_roots_length) (%s), "
80-
"where slot=%s, latest_block_roots_length=%s" %
81-
(
77+
raise ValidationError(
78+
"state.slot ({}) should be less than or equal to "
79+
"(slot + latest_block_roots_length) ({}), "
80+
"where slot={}, latest_block_roots_length={}".format(
8281
state_slot,
8382
slot + latest_block_roots_length,
8483
slot,
8584
latest_block_roots_length,
8685
)
8786
)
8887
if slot >= state_slot:
89-
raise ValueError(
90-
"slot (%s) should be less than state.slot (%s)" %
91-
(slot, state_slot)
88+
raise ValidationError(
89+
"slot ({}) should be less than state.slot ({})".format(
90+
slot,
91+
state_slot,
92+
)
9293
)
9394
return latest_block_roots[slot % latest_block_roots_length]
9495

@@ -121,16 +122,17 @@ def _get_shard_committees_at_slot(
121122
earliest_slot_in_array = state_slot - (state_slot % epoch_length) - epoch_length
122123

123124
if earliest_slot_in_array > slot:
124-
raise ValueError(
125-
"earliest_slot_in_array (%s) should be less than or equal to slot (%s)" %
126-
(earliest_slot_in_array, slot)
125+
raise ValidationError(
126+
"earliest_slot_in_array ({}) should be less than or equal to slot ({})".format(
127+
earliest_slot_in_array,
128+
slot,
129+
)
127130
)
128131
if slot >= earliest_slot_in_array + epoch_length * 2:
129-
raise ValueError(
130-
"slot (%s) should be less than "
131-
"(earliest_slot_in_array + epoch_length * 2) (%s), "
132-
"where earliest_slot_in_array=%s, epoch_length=%s" %
133-
(
132+
raise ValidationError(
133+
"slot ({}) should be less than "
134+
"(earliest_slot_in_array + epoch_length * 2) ({}), "
135+
"where earliest_slot_in_array={}, epoch_length={}".format(
134136
slot,
135137
earliest_slot_in_array + epoch_length * 2,
136138
earliest_slot_in_array,

tests/beacon/test_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_get_block_root(current_slot,
142142
)
143143
assert block_root == blocks[target_slot].root
144144
else:
145-
with pytest.raises(ValueError):
145+
with pytest.raises(ValidationError):
146146
_get_block_root(
147147
latest_block_roots,
148148
current_slot,
@@ -240,7 +240,7 @@ def test_get_shard_committees_at_slot(
240240
assert len(shard_committees) > 0
241241
assert len(shard_committees[0].committee) > 0
242242
else:
243-
with pytest.raises(ValueError):
243+
with pytest.raises(ValidationError):
244244
_get_shard_committees_at_slot(
245245
state_slot=state_slot,
246246
shard_committees_at_slots=shard_committees_at_slots,

0 commit comments

Comments
 (0)