Merge pull request #454 from status-im/justification-finalization-unit-tests
Fix and activate the justification and finalization unit tests.
This commit is contained in:
commit
6d7af234c7
|
@ -23,7 +23,8 @@ import # Refactor state transition unit tests
|
|||
./spec_block_processing/test_genesis,
|
||||
./spec_block_processing/test_process_deposits,
|
||||
./spec_block_processing/test_process_attestation,
|
||||
./spec_epoch_processing/test_process_crosslinks
|
||||
./spec_epoch_processing/test_process_crosslinks,
|
||||
./spec_epoch_processing/test_process_justification_and_finalization
|
||||
|
||||
import # Official fixtures that don't require SSZ parsing of invalid BLS signatures
|
||||
# https://github.com/status-im/nim-beacon-chain/issues/374
|
||||
|
|
|
@ -29,18 +29,19 @@ iterator getShardsForSlot(state: BeaconState, slot: Slot): Shard =
|
|||
yield shard + Shard(i)
|
||||
|
||||
proc addMockAttestations*(
|
||||
state: BeaconState, epoch: Epoch,
|
||||
state: var BeaconState, epoch: Epoch,
|
||||
source, target: Checkpoint,
|
||||
sufficient_support = false
|
||||
) =
|
||||
# We must be at the end of the epoch
|
||||
doAssert (state.slot + 1) mod SLOTS_PER_EPOCH == 0
|
||||
|
||||
var attestations: seq[PendingAttestation]
|
||||
# Alias the attestations container
|
||||
var attestations: ptr seq[PendingAttestation]
|
||||
if state.get_current_epoch() == epoch:
|
||||
attestations = state.current_epoch_attestations
|
||||
attestations = state.current_epoch_attestations.addr
|
||||
elif state.get_previous_epoch() == epoch:
|
||||
attestations = state.previous_epoch_attestations
|
||||
attestations = state.previous_epoch_attestations.addr
|
||||
else:
|
||||
raise newException(ValueError, &"Cannot include attestations from epoch {state.get_current_epoch()} in epoch {epoch}")
|
||||
|
||||
|
@ -79,7 +80,7 @@ proc addMockAttestations*(
|
|||
if idx != -1:
|
||||
aggregation_bits[idx] = false
|
||||
|
||||
attestations.add PendingAttestation(
|
||||
attestations[].add PendingAttestation(
|
||||
aggregation_bits: aggregation_bits,
|
||||
data: AttestationData(
|
||||
beacon_block_root: [byte 0xFF] * 32, # Irrelevant for testing
|
||||
|
|
|
@ -51,7 +51,7 @@ proc finalizeOn234(state: var BeaconState, epoch: Epoch, sufficient_support: boo
|
|||
# mock the 2nd latest epoch as justifiable, with 4th as the source
|
||||
addMockAttestations(
|
||||
state,
|
||||
epoch = epoch - 1,
|
||||
epoch = epoch - 2,
|
||||
source = c4,
|
||||
target = c2,
|
||||
sufficient_support = sufficient_support
|
||||
|
|
Loading…
Reference in New Issue