public void GetPreviousDifficultyUpdateInformationFull_ForHeight9_ThrowException()
        {
            var difficultyUpdateCycle = 10;
            var blockchainHeight      = 9;
            var sut        = new DifficultyCalculator();
            var blockchain = new Blockchain(_netId);

            var ex = Assert.ThrowsException <DifficultyCalculationException>(
                () => sut.GetPreviousDifficultyUpdateInformation(blockchainHeight, blockchain, difficultyUpdateCycle)
                );

            Assert.AreEqual("Unable to calculate the previous difficulty because the height is lower than the DifficultyUpdateCycle.", ex.Message);
        }
        public void GetPreviousDifficultyUpdateInformationFull_ForHeight62_ReturnsCorrectInformation()
        {
            var difficultyUpdateCycle = 10;
            var blockchainHeight      = 63; // = index and that starts at zero.
            var sut    = new DifficultyCalculator();
            var blocks = new List <Block>();

            // Add 64 blocks
            for (int i = 10; i < 641; i = i + 10)
            {
                blocks.Add(new Block(new BlockHeader(_netId, _protocol, "abc", i, ""), new List <AbstractTransaction>()));
            }
            var blockchain = new Blockchain(blocks, _netId);

            BlockDifficultyUpdate result = sut.GetPreviousDifficultyUpdateInformation(blockchainHeight, blockchain, difficultyUpdateCycle);

            Assert.AreEqual(blockchain, result.Blockchain);
            Assert.AreEqual(50, result.BeginHeight);
            Assert.AreEqual(59, result.EndHeight);
            Assert.AreEqual(90, result.TotalSecondsForBlocks); // It took 90 seconds to create 9 blocks
        }