Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
patch test to match new function implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Mar 12, 2019
1 parent 98d6901 commit 84b6913
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions tests/eth2/beacon/test_epoch_processing_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from eth2.beacon.exceptions import NoWinningRootError
from eth2.beacon.helpers import (
get_epoch_start_slot,
slot_to_epoch,
)
from eth2.beacon.types.attestations import (
Attestation,
Expand Down Expand Up @@ -332,18 +333,30 @@ def mock_get_crosslink_committees_at_slot(state,
assert winning_root == competing_block_roots[0]


@pytest.mark.parametrize(
(
'genesis_slot,'
),
[
0,
],
)
@settings(max_examples=1)
@given(random=st.randoms())
def test_get_epoch_boundary_attester_indices(monkeypatch,
random,
sample_attestation_params,
sample_attestation_data_params,
sample_state,
committee_config):
config):
target_committee_size = 16
committee = tuple([i for i in range(target_committee_size)])

block_root_1 = hash_eth2(b'block_root_1')
block_root_2 = hash_eth2(b'block_root_2')

from eth2.beacon import committee_helpers
from eth2.beacon import helpers

def mock_get_crosslink_committees_at_slot(state,
slot,
Expand All @@ -353,14 +366,23 @@ def mock_get_crosslink_committees_at_slot(state,
(committee, sample_attestation_data_params['shard'],),
)

def mock_get_block_root(state, epoch_start_slot, latest_block_roots_length):
if slot_to_epoch(epoch_start_slot, config.SLOTS_PER_EPOCH) == 1:
return block_root_1
else:
return block_root_2

monkeypatch.setattr(
committee_helpers,
'get_crosslink_committees_at_slot',
mock_get_crosslink_committees_at_slot
)

block_root_1 = hash_eth2(b'block_root_1')
block_root_2 = hash_eth2(b'block_root_2')
monkeypatch.setattr(
helpers,
'get_block_root',
mock_get_block_root
)

(
attestation_participants_1,
Expand Down Expand Up @@ -412,9 +434,9 @@ def mock_get_crosslink_committees_at_slot(state,
block_root_1_attesting_validator = get_epoch_boundary_attester_indices(
state=sample_state,
attestations=attestations,
epoch=1,
root=block_root_1,
committee_config=committee_config,
expected_justified_epoch=1,
epoch_for_root=1,
config=config,
)
# Check that result is the union of two participants set
# `attestation_participants_1` and `attestation_participants_2`
Expand All @@ -426,9 +448,9 @@ def mock_get_crosslink_committees_at_slot(state,
block_root_2_attesting_validator = get_epoch_boundary_attester_indices(
state=sample_state,
attestations=attestations,
epoch=2,
root=block_root_2,
committee_config=committee_config,
expected_justified_epoch=2,
epoch_for_root=2,
config=config,
)
# Check that result is the `not_attestation_participants_1` set
assert set(block_root_2_attesting_validator) == set(not_attestation_participants_1)
Expand Down

0 comments on commit 84b6913

Please sign in to comment.