Skip to content

Commit de0570f

Browse files
committed
PR feedback
1 parent c96a781 commit de0570f

File tree

4 files changed

+39
-38
lines changed

4 files changed

+39
-38
lines changed

eth/beacon/types/shard_and_committees.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import (
2-
Iterable,
2+
Sequence,
33
)
44

55
import rlp
@@ -26,7 +26,7 @@ class ShardAndCommittee(rlp.Serializable):
2626

2727
def __init__(self,
2828
shard: int,
29-
committee: Iterable[int])-> None:
29+
committee: Sequence[int])-> None:
3030
if committee is None:
3131
committee = ()
3232

tests/beacon/types/test_block.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
import rlp
23

34
from eth.beacon.types.blocks import (
@@ -13,7 +14,7 @@
1314

1415
def test_defaults(sample_beacon_block_params):
1516
block = BaseBeaconBlock(**sample_beacon_block_params)
16-
block.slot == sample_beacon_block_params['slot']
17+
assert block.slot == sample_beacon_block_params['slot']
1718

1819

1920
def test_update_attestations(sample_attestation_record_params, sample_beacon_block_params):
@@ -32,15 +33,16 @@ def test_hash(sample_beacon_block_params):
3233
assert block.hash == blake(rlp.encode(block))
3334

3435

35-
def test_parent_hash(sample_beacon_block_params):
36-
block = BaseBeaconBlock(**sample_beacon_block_params)
37-
block = block.copy(
38-
ancestor_hashes=(),
39-
)
40-
assert block.parent_hash is None
41-
42-
sample_parent_hash = b'\x01' * 32
43-
block = block.copy(
44-
ancestor_hashes=(sample_parent_hash,),
36+
@pytest.mark.parametrize(
37+
'ancestor_hashes, parent_hash',
38+
[
39+
((), None),
40+
((b'\x01' * 32,), b'\x01' * 32),
41+
((b'\x01' * 32, b'\x02' * 32), b'\x01' * 32)
42+
]
43+
)
44+
def test_parent_hash(sample_beacon_block_params, ancestor_hashes, parent_hash):
45+
block = BaseBeaconBlock(**sample_beacon_block_params).copy(
46+
ancestor_hashes=ancestor_hashes,
4547
)
46-
assert block.parent_hash == sample_parent_hash
48+
assert block.parent_hash == parent_hash

tests/beacon/types/test_candidate_pow_receipt_root_record.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@ def test_defaults(sample_candidate_pow_receipt_root_record_params):
77
candidate_pow_receipt_roots = CandidatePoWReceiptRootRecord(
88
**sample_candidate_pow_receipt_root_record_params
99
)
10-
assert candidate_pow_receipt_roots.candidate_pow_receipt_root == \
11-
sample_candidate_pow_receipt_root_record_params['candidate_pow_receipt_root']
12-
assert candidate_pow_receipt_roots.votes == \
13-
sample_candidate_pow_receipt_root_record_params['votes']
10+
assert candidate_pow_receipt_roots.candidate_pow_receipt_root == sample_candidate_pow_receipt_root_record_params['candidate_pow_receipt_root'] # noqa: E501
11+
assert candidate_pow_receipt_roots.votes == sample_candidate_pow_receipt_root_record_params['votes'] # noqa: E501

tests/beacon/types/test_states.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,28 @@ def test_defaults(sample_beacon_state_params):
5656
assert state.validators == sample_beacon_state_params['validators']
5757

5858

59-
# @pytest.mark.parametrize(
60-
# 'expected', [(0), (1), (5)]
61-
# )
62-
# def test_num_validators(expected,
63-
# deposit_size,
64-
# default_end_dynasty,
65-
# empty_crystallized_state):
66-
# validators = [
67-
# mock_validator_record(
68-
# pubkey,
69-
# deposit_size,
70-
# default_end_dynasty,
71-
# start_dynasty=0,
72-
# )
73-
# for pubkey in range(expected)
74-
# ]
75-
# crystallized_state = empty_crystallized_state.copy(
76-
# validators=validators,
77-
# )
59+
@pytest.mark.xfail(reason="Need to be fixed when helper function is updated")
60+
@pytest.mark.parametrize(
61+
'expected', [(0), (1), (5)]
62+
)
63+
def test_num_validators(expected,
64+
deposit_size,
65+
default_end_dynasty,
66+
empty_crystallized_state):
67+
validators = [
68+
mock_validator_record(
69+
pubkey,
70+
deposit_size,
71+
default_end_dynasty,
72+
start_dynasty=0,
73+
)
74+
for pubkey in range(expected)
75+
]
76+
crystallized_state = empty_crystallized_state.copy(
77+
validators=validators,
78+
)
7879

79-
# assert crystallized_state.num_validators == expected
80+
assert crystallized_state.num_validators == expected
8081

8182

8283
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)