From fc75dca9a3118ee18ad78db8e088560f3491ebb1 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 9 Dec 2019 21:17:57 +1100 Subject: [PATCH] Add test for when skip slots kill all validators (#657) --- beacon_node/beacon_chain/tests/tests.rs | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/beacon_node/beacon_chain/tests/tests.rs b/beacon_node/beacon_chain/tests/tests.rs index a278d3f5b4..6c7cfb79c6 100644 --- a/beacon_node/beacon_chain/tests/tests.rs +++ b/beacon_node/beacon_chain/tests/tests.rs @@ -12,9 +12,14 @@ use beacon_chain::{ BlockProcessingOutcome, }; use rand::Rng; +use state_processing::{ + per_slot_processing, per_slot_processing::Error as SlotProcessingError, EpochProcessingError, +}; use store::Store; use types::test_utils::{SeedableRng, TestRandom, XorShiftRng}; -use types::{Deposit, EthSpec, Hash256, Keypair, MinimalEthSpec, RelativeEpoch, Slot}; +use types::{ + BeaconStateError, Deposit, EthSpec, Hash256, Keypair, MinimalEthSpec, RelativeEpoch, Slot, +}; // Should ideally be divisible by 3. pub const VALIDATOR_COUNT: usize = 24; @@ -32,6 +37,30 @@ fn get_harness(validator_count: usize) -> BeaconChainHarness continue, + Err(e) => break e, + } + }; + + assert!(state.slot > 1, "the state should skip at least one slot"); + assert_eq!( + error, + SlotProcessingError::EpochProcessingError(EpochProcessingError::BeaconStateError( + BeaconStateError::InsufficientValidators + )), + "should return error indicating that validators have been slashed out" + ) +} + #[test] fn iterators() { let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 2 - 1;