public async Task Get_BestChain_ReturnBlockHeader()
        {
            var chain = await _fullBlockchainService.GetChainAsync();

            var newBlock = new Block
            {
                Header = new BlockHeader
                {
                    Height            = chain.BestChainHeight + 1,
                    PreviousBlockHash = Hash.FromString("New Branch")
                },
                Body = new BlockBody()
            };

            await _fullBlockchainService.AddBlockAsync(newBlock);

            chain = await _fullBlockchainService.GetChainAsync();

            await _fullBlockchainService.AttachBlockToChainAsync(chain, newBlock);

            var result = await _fullBlockchainService.GetBestChainLastBlockHeaderAsync();

            result.Height.ShouldBe(_kernelTestHelper.BestBranchBlockList.Last().Height);
            result.GetHash().ShouldBe(_kernelTestHelper.BestBranchBlockList.Last().GetHash());
        }
Example #2
0
        public async Task Get_BestChain_ReturnBlockHeader()
        {
            var chain = await _fullBlockchainService.GetChainAsync();

            var newBlock = _kernelTestHelper.GenerateBlock(chain.BestChainHeight, Hash.FromString("New Branch"));

            await _fullBlockchainService.AddBlockAsync(newBlock);

            chain = await _fullBlockchainService.GetChainAsync();

            await _fullBlockchainService.AttachBlockToChainAsync(chain, newBlock);

            var result = await _fullBlockchainService.GetBestChainLastBlockHeaderAsync();

            result.Height.ShouldBe(_kernelTestHelper.BestBranchBlockList.Last().Height);
            result.GetHash().ShouldBe(_kernelTestHelper.BestBranchBlockList.Last().GetHash());
        }