Add another attestation processing test

This commit is contained in:
Paul Hauner
2019-08-07 16:02:30 +10:00
parent 436c87abcd
commit fe2402b361
4 changed files with 70 additions and 8 deletions

View File

@@ -268,6 +268,28 @@ where
head_block_root: Hash256,
head_block_slot: Slot,
) {
self.get_free_attestations(
attestation_strategy,
state,
head_block_root,
head_block_slot,
)
.into_iter()
.for_each(|attestation| {
self.chain
.process_attestation(attestation)
.expect("should process attestation");
});
}
/// Generates a `Vec<Attestation>` for some attestation strategy and head_block.
pub fn get_free_attestations(
&self,
attestation_strategy: &AttestationStrategy,
state: &BeaconState<E>,
head_block_root: Hash256,
head_block_slot: Slot,
) -> Vec<Attestation<E>> {
let spec = &self.spec;
let fork = &state.fork;
@@ -276,6 +298,8 @@ where
AttestationStrategy::SomeValidators(vec) => vec.clone(),
};
let mut vec = vec![];
state
.get_crosslink_committees_at_slot(state.slot)
.expect("should get committees")
@@ -328,12 +352,12 @@ where
signature,
};
self.chain
.process_attestation(attestation)
.expect("should process attestation");
vec.push(attestation)
}
}
});
vec
}
/// Creates two forks: