Ejemplo n.º 1
0
        public void Time_passing_does_not_break_the_block()
        {
            ITimestamper      timestamper       = new IncrementalTimestamper();
            ProducerUnderTest producerUnderTest = new ProducerUnderTest(
                EmptyTxSource.Instance,
                Substitute.For <IBlockchainProcessor>(),
                NullSealEngine.Instance,
                Build.A.BlockTree().TestObject,
                Substitute.For <IBlockProcessingQueue>(),
                Substitute.For <IStateProvider>(),
                Substitute.For <IGasLimitCalculator>(),
                timestamper,
                LimboLogs.Instance);

            Block block = producerUnderTest.Prepare();

            block.Timestamp.Should().BeEquivalentTo(block.Difficulty);
        }
Ejemplo n.º 2
0
        public void Parent_timestamp_is_used_consistently()
        {
            ITimestamper      timestamper       = new IncrementalTimestamper(DateTime.UnixEpoch, TimeSpan.FromSeconds(1));
            ProducerUnderTest producerUnderTest = new ProducerUnderTest(
                EmptyTxSource.Instance,
                Substitute.For <IBlockchainProcessor>(),
                NullSealEngine.Instance,
                Build.A.BlockTree().TestObject,
                Substitute.For <IBlockProcessingQueue>(),
                Substitute.For <IStateProvider>(),
                Substitute.For <IGasLimitCalculator>(),
                timestamper,
                LimboLogs.Instance);

            ulong futureTime = UnixTime.FromSeconds(TimeSpan.FromDays(1).TotalSeconds).Seconds;
            Block block      = producerUnderTest.Prepare(Build.A.BlockHeader.WithTimestamp(futureTime).TestObject);

            block.Timestamp.Should().BeEquivalentTo(block.Difficulty);
        }