public void InvalidSignature() { // Arrange IServiceProvider testServiceProvider = TestSystem.BuildTestServiceProvider(); BeaconState state = TestState.PrepareTestState(testServiceProvider); TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); // move state forward PERSISTENT_COMMITTEE_PERIOD epochs to allow for exit ulong move = timeParameters.SlotsPerEpoch * (ulong)timeParameters.PersistentCommitteePeriod; ulong newSlot = state.Slot + move; state.SetSlot((Slot)newSlot); Epoch currentEpoch = beaconStateAccessor.GetCurrentEpoch(state); ValidatorIndex validatorIndex = beaconStateAccessor.GetActiveValidatorIndices(state, currentEpoch)[0]; Validator validator = state.Validators[(int)(ulong)validatorIndex]; byte[] privateKey = TestKeys.PublicKeyToPrivateKey(validator.PublicKey, timeParameters); VoluntaryExit voluntaryExit = TestVoluntaryExit.BuildVoluntaryExit(testServiceProvider, currentEpoch, validatorIndex); SignedVoluntaryExit signedVoluntaryExit = new SignedVoluntaryExit(voluntaryExit, BlsSignature.Zero); RunVoluntaryExitProcessing(testServiceProvider, state, signedVoluntaryExit, expectValid: false); }
public void SuccessTest() { // Arrange var testServiceProvider = TestSystem.BuildTestServiceProvider(); var state = TestState.PrepareTestState(testServiceProvider); var timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; var beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>(); // move state forward PERSISTENT_COMMITTEE_PERIOD epochs to allow for exit var move = timeParameters.SlotsPerEpoch * (ulong)timeParameters.PersistentCommitteePeriod; var newSlot = state.Slot + move; state.SetSlot(newSlot); var currentEpoch = beaconStateAccessor.GetCurrentEpoch(state); var validatorIndex = beaconStateAccessor.GetActiveValidatorIndices(state, currentEpoch)[0]; var validator = state.Validators[(int)(ulong)validatorIndex]; var privateKey = TestKeys.PublicKeyToPrivateKey(validator.PublicKey, timeParameters); var voluntaryExit = TestVoluntaryExit.BuildVoluntaryExit(testServiceProvider, state, currentEpoch, validatorIndex, privateKey, signed: true); RunVoluntaryExitProcessing(testServiceProvider, state, voluntaryExit, expectValid: true); }