Re-add ValidatorRecord::status_is() fn

It was accidentally removed.
This commit is contained in:
Paul Hauner 2018-12-29 14:34:22 +11:00
parent 9efc7a0def
commit b365bb8773
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
3 changed files with 16 additions and 7 deletions

View File

@ -41,6 +41,12 @@ pub struct ValidatorRecord {
pub exit_slot: u64,
}
impl ValidatorRecord {
pub fn status_is(&self, status: ValidatorStatus) -> bool {
self.status == status
}
}
impl Encodable for ValidatorStatus {
fn ssz_append(&self, s: &mut SszStream) {
let byte: u8 = match self {

View File

@ -110,8 +110,8 @@ impl ValidatorInductor {
mod tests {
use super::*;
use bls::{create_proof_of_possession, Keypair, Signature};
use hashing::canonical_hash;
use bls::{create_proof_of_possession, Keypair};
use types::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use types::{Address, Hash256};
fn registration_equals_record(reg: &ValidatorRegistration, rec: &ValidatorRecord) -> bool {
@ -167,9 +167,10 @@ mod tests {
#[test]
fn test_validator_inductor_valid_all_active_validators() {
let mut rng = XorShiftRng::from_seed([42; 16]);
let mut validators = vec![];
for _ in 0..5 {
let (mut v, _) = ValidatorRecord::zero_with_thread_rand_keypair();
let mut v = ValidatorRecord::random_for_test(&mut rng);
v.status = ValidatorStatus::Active;
validators.push(v);
}
@ -187,12 +188,13 @@ mod tests {
#[test]
fn test_validator_inductor_valid_all_second_validator_withdrawn() {
let mut rng = XorShiftRng::from_seed([42; 16]);
let mut validators = vec![];
let (mut v, _) = ValidatorRecord::zero_with_thread_rand_keypair();
let mut v = ValidatorRecord::random_for_test(&mut rng);
v.status = ValidatorStatus::Active;
validators.push(v);
for _ in 0..4 {
let (mut v, _) = ValidatorRecord::zero_with_thread_rand_keypair();
let mut v = ValidatorRecord::random_for_test(&mut rng);
v.status = ValidatorStatus::Withdrawn;
validators.push(v);
}
@ -210,9 +212,10 @@ mod tests {
#[test]
fn test_validator_inductor_valid_all_withdrawn_validators() {
let mut rng = XorShiftRng::from_seed([42; 16]);
let mut validators = vec![];
for _ in 0..5 {
let (mut v, _) = ValidatorRecord::zero_with_thread_rand_keypair();
let mut v = ValidatorRecord::random_for_test(&mut rng);
v.status = ValidatorStatus::Withdrawn;
validators.push(v);
}

View File

@ -95,7 +95,7 @@ fn generate_cycle(
.honey_badger_split(committees_per_slot)
.enumerate()
.map(|(j, shard_indices)| ShardCommittee {
shard: ((shard_start + j) % shard_count) as u16,
shard: ((shard_start + j) % shard_count) as u64,
committee: shard_indices.to_vec(),
})
.collect()