make full_attestation reward test better
This commit is contained in:
parent
cf1323b79e
commit
1aa12034e5
|
@ -55,14 +55,20 @@ def test_genesis_epoch_full_attestations_no_rewards(spec, state):
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_attestations(spec, state):
|
def test_full_attestations(spec, state):
|
||||||
attestations = []
|
attestations = []
|
||||||
for slot in range(spec.SLOTS_PER_EPOCH - spec.MIN_ATTESTATION_INCLUSION_DELAY):
|
for slot in range(spec.SLOTS_PER_EPOCH + spec.MIN_ATTESTATION_INCLUSION_DELAY):
|
||||||
attestation = get_valid_attestation(spec, state)
|
# create an attestation for each slot in epoch
|
||||||
fill_aggregate_attestation(spec, state, attestation, signed=True)
|
if slot < spec.SLOTS_PER_EPOCH:
|
||||||
attestations.append(attestation)
|
attestation = get_valid_attestation(spec, state)
|
||||||
|
fill_aggregate_attestation(spec, state, attestation, signed=True)
|
||||||
|
attestations.append(attestation)
|
||||||
|
# fill each created slot in state after inclusion delay
|
||||||
|
if slot - spec.MIN_ATTESTATION_INCLUSION_DELAY >= 0:
|
||||||
|
include_att = attestations[slot - spec.MIN_ATTESTATION_INCLUSION_DELAY]
|
||||||
|
add_attestations_to_state(spec, state, [include_att], state.slot)
|
||||||
next_slot(spec, state)
|
next_slot(spec, state)
|
||||||
add_attestations_to_state(spec, state, attestations, state.slot + spec.MIN_ATTESTATION_INCLUSION_DELAY)
|
|
||||||
|
|
||||||
assert spec.compute_epoch_of_slot(state.slot) == spec.GENESIS_EPOCH + 1
|
assert spec.compute_epoch_of_slot(state.slot) == spec.GENESIS_EPOCH + 1
|
||||||
|
assert len(state.previous_epoch_attestations) == spec.SLOTS_PER_EPOCH
|
||||||
|
|
||||||
pre_state = deepcopy(state)
|
pre_state = deepcopy(state)
|
||||||
|
|
||||||
|
@ -70,8 +76,11 @@ def test_full_attestations(spec, state):
|
||||||
|
|
||||||
attesting_indices = spec.get_unslashed_attesting_indices(state, attestations)
|
attesting_indices = spec.get_unslashed_attesting_indices(state, attestations)
|
||||||
assert len(attesting_indices) > 0
|
assert len(attesting_indices) > 0
|
||||||
for index in attesting_indices:
|
for index in range(len(pre_state.validators)):
|
||||||
assert state.balances[index] > pre_state.balances[index]
|
if index in attesting_indices:
|
||||||
|
assert state.balances[index] > pre_state.balances[index]
|
||||||
|
else:
|
||||||
|
assert state.balances[index] < pre_state.balances[index]
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
|
|
Loading…
Reference in New Issue