// Run ``process_voluntary_exit``, yielding: // - pre-state('pre') // - voluntary_exit('voluntary_exit') // - post-state('post'). //If ``valid == False``, run expecting ``AssertionError`` private void RunVoluntaryExitProcessing(IServiceProvider testServiceProvider, BeaconState state, VoluntaryExit voluntaryExit, bool expectValid) { TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; MaxOperationsPerBlock maxOperationsPerBlock = testServiceProvider.GetService <IOptions <MaxOperationsPerBlock> >().Value; ChainConstants chainConstants = testServiceProvider.GetService <ChainConstants>(); BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); BeaconStateTransition beaconStateTransition = testServiceProvider.GetService <BeaconStateTransition>(); // Act if (!expectValid) { Should.Throw <Exception>(() => { beaconStateTransition.ProcessVoluntaryExit(state, voluntaryExit); }); return; } ValidatorIndex validatorIndex = voluntaryExit.ValidatorIndex; Epoch preExitEpoch = state.Validators[(int)(ulong)validatorIndex].ExitEpoch; beaconStateTransition.ProcessVoluntaryExit(state, voluntaryExit); // Assert preExitEpoch.ShouldBe(chainConstants.FarFutureEpoch); Epoch postExitEpoch = state.Validators[(int)(ulong)validatorIndex].ExitEpoch; postExitEpoch.ShouldBeLessThan(chainConstants.FarFutureEpoch); }