public void UpdateHeaders_UsingChainAndNetwork_PreparesStakeBlockHeaders() { this.ExecuteWithConsensusOptions(new PosConsensusOptions(), () => { this.dateTimeProvider.Setup(d => d.GetTimeOffset()) .Returns(new DateTimeOffset(new DateTime(2017, 1, 7, 0, 0, 0, DateTimeKind.Utc))); var chain = GenerateChainWithHeight(5, this.network, new Key()); var assemblerOptions = new AssemblerOptions() { IsProofOfStake = true }; this.stakeValidator.Setup(s => s.GetNextTargetRequired(this.stakeChain.Object, chain.Tip, this.network.Consensus, true)) .Returns(new Target(new uint256(1123123123))) .Verifiable(); var posBlockAssembler = new PosTestBlockAssembler(this.consensusLoop.Object, this.network, new MempoolSchedulerLock(), this.txMempool.Object, this.dateTimeProvider.Object, this.stakeChain.Object, this.stakeValidator.Object, chain.Tip, this.LoggerFactory.Object, assemblerOptions); var result = posBlockAssembler.UpdateHeaders(chain.Tip); Assert.Equal(chain.Tip.HashBlock, result.Header.HashPrevBlock); Assert.Equal((uint)1483747200, result.Header.Time); Assert.Equal(2.400408204198463E+58, result.Header.Bits.Difficulty); Assert.Equal((uint)0, result.Header.Nonce); this.stakeValidator.Verify(); }); }
public void UpdateHeaders_UsingChainAndNetwork_PreparesStakeBlockHeaders() { this.ExecuteWithConsensusOptions(new PosConsensusOptions(), () => { this.dateTimeProvider.Setup(d => d.GetTimeOffset()).Returns(new DateTimeOffset(new DateTime(2017, 1, 7, 0, 0, 0, DateTimeKind.Utc))); ChainIndexer chainIndexer = GenerateChainWithHeight(5, this.stratisTest, new Key()); this.stakeValidator.Setup(s => s.GetNextTargetRequired(this.stakeChain.Object, chainIndexer.Tip, this.stratisTest.Consensus, true)) .Returns(new Target(new uint256(1123123123))) .Verifiable(); var posBlockAssembler = new PosTestBlockAssembler(this.consensusManager.Object, this.stratisTest, new MempoolSchedulerLock(), this.mempool.Object, this.minerSettings, this.dateTimeProvider.Object, this.stakeChain.Object, this.stakeValidator.Object, this.LoggerFactory.Object, new NodeDeployments(this.Network, chainIndexer)); Block block = posBlockAssembler.UpdateHeaders(chainIndexer.Tip); Assert.Equal(chainIndexer.Tip.HashBlock, block.Header.HashPrevBlock); Assert.Equal((uint)1483747200, block.Header.Time); Assert.Equal(2.400408204198463E+58, block.Header.Bits.Difficulty); Assert.Equal((uint)0, block.Header.Nonce); this.stakeValidator.Verify(); }); }