Search in sources :

Example 1 with ValidatorStatusFactory

use of tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory in project teku by ConsenSys.

the class RewardsTestExecutorAltair method runTest.

@Override
public void runTest(final TestDefinition testDefinition) throws Throwable {
    final BeaconState preState = loadStateFromSsz(testDefinition, "pre.ssz_snappy");
    final ValidatorStatusFactory statusFactory = testDefinition.getSpec().getGenesisSpec().getValidatorStatusFactory();
    final ValidatorStatuses validatorStatuses = statusFactory.createValidatorStatuses(preState);
    final SpecVersion spec = testDefinition.getSpec().getGenesisSpec();
    final RewardsAndPenaltiesCalculatorAltair calculator = createRewardsAndPenaltiesCalculator(preState, validatorStatuses, spec);
    runTest(testDefinition, calculator, validatorStatuses);
}
Also used : ValidatorStatuses(tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatuses) SpecVersion(tech.pegasys.teku.spec.SpecVersion) ValidatorStatusFactory(tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory) RewardsAndPenaltiesCalculatorAltair(tech.pegasys.teku.spec.logic.versions.altair.statetransition.epoch.RewardsAndPenaltiesCalculatorAltair) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)

Example 2 with ValidatorStatusFactory

use of tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory in project teku by ConsenSys.

the class EpochProcessingTestExecutor method runTest.

@Override
public void runTest(final TestDefinition testDefinition) throws Exception {
    final BeaconState preState = loadStateFromSsz(testDefinition, "pre.ssz_snappy");
    final BeaconState expectedPostState = loadStateFromSsz(testDefinition, "post.ssz_snappy");
    final SpecVersion genesisSpec = testDefinition.getSpec().getGenesisSpec();
    final EpochProcessor epochProcessor = genesisSpec.getEpochProcessor();
    final ValidatorStatusFactory validatorStatusFactory = genesisSpec.getValidatorStatusFactory();
    final EpochProcessingExecutor processor = new EpochProcessingExecutor(epochProcessor, validatorStatusFactory);
    final BeaconState result = preState.updated(state -> processor.executeOperation(operation, state));
    assertThat(result).isEqualTo(expectedPostState);
}
Also used : EpochProcessor(tech.pegasys.teku.spec.logic.common.statetransition.epoch.EpochProcessor) SpecVersion(tech.pegasys.teku.spec.SpecVersion) ValidatorStatusFactory(tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)

Example 3 with ValidatorStatusFactory

use of tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory in project teku by ConsenSys.

the class RewardsTestExecutorPhase0 method runTest.

@Override
public void runTest(final TestDefinition testDefinition) throws Throwable {
    final BeaconState preState = loadStateFromSsz(testDefinition, "pre.ssz_snappy");
    final ValidatorStatusFactory statusFactory = testDefinition.getSpec().getGenesisSpec().getValidatorStatusFactory();
    final ValidatorStatuses validatorStatuses = statusFactory.createValidatorStatuses(preState);
    final SpecVersion spec = testDefinition.getSpec().getGenesisSpec();
    final RewardsAndPenaltiesCalculatorPhase0 calculator = new RewardsAndPenaltiesCalculatorPhase0(spec.getConfig(), preState, validatorStatuses, spec.miscHelpers(), spec.beaconStateAccessors());
    runTest(testDefinition, calculator);
}
Also used : ValidatorStatuses(tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatuses) SpecVersion(tech.pegasys.teku.spec.SpecVersion) RewardsAndPenaltiesCalculatorPhase0(tech.pegasys.teku.spec.logic.versions.phase0.statetransition.epoch.RewardsAndPenaltiesCalculatorPhase0) ValidatorStatusFactory(tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)

Aggregations

SpecVersion (tech.pegasys.teku.spec.SpecVersion)3 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)3 ValidatorStatusFactory (tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory)3 ValidatorStatuses (tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatuses)2 EpochProcessor (tech.pegasys.teku.spec.logic.common.statetransition.epoch.EpochProcessor)1 RewardsAndPenaltiesCalculatorAltair (tech.pegasys.teku.spec.logic.versions.altair.statetransition.epoch.RewardsAndPenaltiesCalculatorAltair)1 RewardsAndPenaltiesCalculatorPhase0 (tech.pegasys.teku.spec.logic.versions.phase0.statetransition.epoch.RewardsAndPenaltiesCalculatorPhase0)1