Skip to content

Commit

Permalink
Add compute_subnet_for_attestation unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
lsankar4033 committed Jun 16, 2020
1 parent ffeecfb commit 55e17fb
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,22 @@ def test_get_attestation_signature(spec, state):
)


@with_all_phases
@spec_state_test
def test_compute_subnet_for_attestation(spec, state):
for committee_idx in range(spec.MAX_COMMITTEES_PER_SLOT):
for slot in range(state.slot, state.slot + spec.SLOTS_PER_EPOCH):
actual_subnet_id = spec.compute_subnet_for_attestation(state, slot, committee_idx)

slots_since_epoch_start = slot % spec.SLOTS_PER_EPOCH
committees_since_epoch_start = spec.get_committee_count_at_slot(
state, slot) * slots_since_epoch_start
expected_subnet_id = (committees_since_epoch_start +
committee_idx) % spec.ATTESTATION_SUBNET_COUNT

assert actual_subnet_id == expected_subnet_id


# Attestation aggregation


Expand Down

0 comments on commit 55e17fb

Please sign in to comment.