public void Eth1VoteReset() { // Arrange IServiceProvider testServiceProvider = TestSystem.BuildTestServiceProvider(); BeaconState state = TestState.PrepareTestState(testServiceProvider); TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; // skip ahead to the end of the voting period state.SetSlot((Slot)(timeParameters.SlotsPerEth1VotingPeriod - 1UL)); // add a vote for each skipped slot. for (Slot index = Slot.Zero; index < state.Slot + new Slot(1); index += new Slot(1)) { ulong eth1DepositIndex = state.Eth1DepositIndex; Root depositRoot = new Root(Enumerable.Repeat((byte)0xaa, 32).ToArray()); Bytes32 blockHash = new Bytes32(Enumerable.Repeat((byte)0xbb, 32).ToArray()); Eth1Data eth1Data = new Eth1Data(depositRoot, eth1DepositIndex, blockHash); state.AddEth1DataVote(eth1Data); } // Act RunProcessFinalUpdates(testServiceProvider, state); // Assert state.Eth1DataVotes.Count.ShouldBe(0); }
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 HistoricalRootAccumulator() { // Arrange IServiceProvider testServiceProvider = TestSystem.BuildTestServiceProvider(); BeaconState state = TestState.PrepareTestState(testServiceProvider); TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; // skip ahead to near the end of the historical roots period (excl block before epoch processing) state.SetSlot((Slot)(timeParameters.SlotsPerHistoricalRoot - 1UL)); int historyLength = state.HistoricalRoots.Count; // Act RunProcessFinalUpdates(testServiceProvider, state); // Assert state.HistoricalRoots.Count.ShouldBe(historyLength + 1); }