Skip to content

Commit 122872d

Browse files
Bhargavasomuhwwhww
authored andcommitted
Add tests capturing bad signature in validate_proposer_signature
1 parent 19b8f25 commit 122872d

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

eth/beacon/types/blocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def num_attestations(self) -> int:
117117
@classmethod
118118
def get_block_without_signature_root(
119119
cls,
120-
block: 'BaseBeaconBlock') -> 'BaseBeaconBlock':
120+
block: 'BaseBeaconBlock') -> Hash32:
121121
return cls(
122122
slot=block.slot,
123123
parent_root=block.parent_root,

tests/beacon/state_machines/test_validation.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import pytest
2+
3+
from eth_utils import (
4+
ValidationError,
5+
)
6+
17
from eth.beacon.state_machines.validation import (
28
validate_proposer_signature,
39
)
@@ -39,3 +45,34 @@ def test_validate_proposer_signature(
3945
beacon_chain_shard_number,
4046
epoch_length,
4147
)
48+
49+
50+
def test_validate_proposer_bad_signature(
51+
beacon_chain_shard_number,
52+
epoch_length,
53+
sample_beacon_block_params,
54+
sample_beacon_state_params,
55+
sample_shard_committee_params):
56+
block = BaseBeaconBlock(**sample_beacon_block_params)
57+
state = BeaconState(**sample_beacon_state_params).copy(
58+
validator_registry=[
59+
mock_validator_record(
60+
pubkey=123,
61+
max_deposit=0,
62+
)
63+
for _ in range(10)
64+
],
65+
shard_committees_at_slots=get_sample_shard_committees_at_slots(
66+
num_slot=128,
67+
num_shard_committee_per_slot=10,
68+
sample_shard_committee_params=sample_shard_committee_params,
69+
),
70+
)
71+
72+
with pytest.raises(ValidationError):
73+
validate_proposer_signature(
74+
state,
75+
block,
76+
beacon_chain_shard_number,
77+
epoch_length,
78+
)

0 commit comments

Comments
 (0)