add epoch processing new tests

This commit is contained in:
realbigsean
2024-05-12 06:53:52 -04:00
parent 8d4a921612
commit 89ef043491
2 changed files with 49 additions and 0 deletions

View File

@@ -10,6 +10,9 @@ use state_processing::per_epoch_processing::capella::process_historical_summarie
use state_processing::per_epoch_processing::effective_balance_updates::{
process_effective_balance_updates, process_effective_balance_updates_slow,
};
use state_processing::per_epoch_processing::single_pass::{
process_epoch_single_pass, SinglePassConfig,
};
use state_processing::per_epoch_processing::{
altair, base,
historical_roots_update::process_historical_roots_update,
@@ -53,6 +56,10 @@ pub struct Slashings;
#[derive(Debug)]
pub struct Eth1DataReset;
#[derive(Debug)]
pub struct PendingBalanceDeposits;
#[derive(Debug)]
pub struct PendingConsolidations;
#[derive(Debug)]
pub struct EffectiveBalanceUpdates;
#[derive(Debug)]
pub struct SlashingsReset;
@@ -79,6 +86,8 @@ type_name!(RewardsAndPenalties, "rewards_and_penalties");
type_name!(RegistryUpdates, "registry_updates");
type_name!(Slashings, "slashings");
type_name!(Eth1DataReset, "eth1_data_reset");
type_name!(PendingBalanceDeposits, "pending_balance_deposits");
type_name!(PendingConsolidations, "pending_consolidations");
type_name!(EffectiveBalanceUpdates, "effective_balance_updates");
type_name!(SlashingsReset, "slashings_reset");
type_name!(RandaoMixesReset, "randao_mixes_reset");
@@ -178,6 +187,34 @@ impl<E: EthSpec> EpochTransition<E> for Eth1DataReset {
}
}
impl<E: EthSpec> EpochTransition<E> for PendingBalanceDeposits {
fn run(state: &mut BeaconState<E>, spec: &ChainSpec) -> Result<(), EpochProcessingError> {
process_epoch_single_pass(
state,
spec,
SinglePassConfig {
pending_balance_deposits: true,
..SinglePassConfig::disable_all()
},
)
.map(|_| ())
}
}
impl<E: EthSpec> EpochTransition<E> for PendingConsolidations {
fn run(state: &mut BeaconState<E>, spec: &ChainSpec) -> Result<(), EpochProcessingError> {
process_epoch_single_pass(
state,
spec,
SinglePassConfig {
pending_consolidations: true,
..SinglePassConfig::disable_all()
},
)
.map(|_| ())
}
}
impl<E: EthSpec> EpochTransition<E> for EffectiveBalanceUpdates {
fn run(state: &mut BeaconState<E>, spec: &ChainSpec) -> Result<(), EpochProcessingError> {
if let BeaconState::Base(_) = state {

View File

@@ -664,6 +664,18 @@ fn epoch_processing_eth1_data_reset() {
EpochProcessingHandler::<MainnetEthSpec, Eth1DataReset>::default().run();
}
#[test]
fn epoch_processing_pending_balance_deposits() {
EpochProcessingHandler::<MinimalEthSpec, PendingBalanceDeposits>::default().run();
EpochProcessingHandler::<MainnetEthSpec, PendingBalanceDeposits>::default().run();
}
#[test]
fn epoch_processing_pending_consolidations() {
EpochProcessingHandler::<MinimalEthSpec, PendingConsolidations>::default().run();
EpochProcessingHandler::<MainnetEthSpec, PendingConsolidations>::default().run();
}
#[test]
fn epoch_processing_effective_balance_updates() {
EpochProcessingHandler::<MinimalEthSpec, EffectiveBalanceUpdates>::default().run();