Пример #1
0
        public void FinalizeOn234(ulong epochValue, bool sufficientSupport)
        {
            // Arrange
            var epoch = new Epoch(epochValue);
            var testServiceProvider = TestSystem.BuildTestServiceProvider();
            var state = TestState.PrepareTestState(testServiceProvider);

            epoch.ShouldBeGreaterThan(new Epoch(4));

            var chainConstants     = testServiceProvider.GetService <ChainConstants>();
            var timeParameters     = testServiceProvider.GetService <IOptions <TimeParameters> >().Value;
            var beaconChainUtility = testServiceProvider.GetService <BeaconChainUtility>();

            // Skip ahead to just before epoch
            var slot = new Slot((ulong)timeParameters.SlotsPerEpoch * (ulong)epoch - 1);

            state.SetSlot(slot);

            // 43210 -- epochs ago
            // 3210x -- justification bitfield indices
            // 11*0. -- justification bitfield contents, . = this epoch, * is being justified now
            // checkpoints for the epochs ago:
            var checkpoints = TestCheckpoint.GetCheckpoints(epoch).ToArray();

            PutCheckpointsInBlockRoots(beaconChainUtility, timeParameters, state, checkpoints[0..3]);
Пример #2
0
        public void TestCheckpointAcceptor()
        {
            var testCheckpoint = new TestCheckpoint();
            var acceptor       = new CheckpointAcceptor(testCheckpoint);

            acceptor.Pending("1");
            acceptor.Pending("2");

            acceptor.Accept("2");

            Assert.IsFalse(testCheckpoint.IsValid());

            acceptor.Accept("1");

            Assert.IsTrue(testCheckpoint.IsValid());
            Assert.AreEqual("2", testCheckpoint.GetValue());
        }