Fixes bug in epoch processing.

- Was using the wrong slot to determine relative epoch.
- Added a non-related test I build during the search
This commit is contained in:
Paul Hauner 2019-03-31 15:30:09 +11:00
parent b26f1f8e1c
commit bd860eb3e1
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
2 changed files with 11 additions and 1 deletions

View File

@ -227,7 +227,7 @@ impl ValidatorStatuses {
status.is_previous_epoch_attester = true; status.is_previous_epoch_attester = true;
// The inclusion slot and distance are only required for previous epoch attesters. // The inclusion slot and distance are only required for previous epoch attesters.
let relative_epoch = RelativeEpoch::from_slot(state.slot, a.data.slot, spec)?; let relative_epoch = RelativeEpoch::from_slot(state.slot, a.inclusion_slot, spec)?;
status.inclusion_info = Some(InclusionInfo { status.inclusion_info = Some(InclusionInfo {
slot: a.inclusion_slot, slot: a.inclusion_slot,
distance: inclusion_distance(a), distance: inclusion_distance(a),

View File

@ -113,6 +113,16 @@ mod epoch_tests {
all_tests!(Epoch); all_tests!(Epoch);
#[test]
fn epoch_start_end() {
let slots_per_epoch = 8;
let epoch = Epoch::new(0);
assert_eq!(epoch.start_slot(slots_per_epoch), Slot::new(0));
assert_eq!(epoch.end_slot(slots_per_epoch), Slot::new(7));
}
#[test] #[test]
fn slot_iter() { fn slot_iter() {
let slots_per_epoch = 8; let slots_per_epoch = 8;