Exemple #1
0
        public async Task Get_BlocksInLongestChainBranchAsync_ReturnHashes()
        {
            var result =
                await _fullBlockchainService.GetBlocksInLongestChainBranchAsync(
                    _kernelTestHelper.LongestBranchBlockList[0].GetHash(), 2);

            result.Count.ShouldBe(2);
            result[0].GetHash().ShouldBe(_kernelTestHelper.LongestBranchBlockList[1].GetHash());
            result[1].GetHash().ShouldBe(_kernelTestHelper.LongestBranchBlockList[2].GetHash());

            result = await _fullBlockchainService.GetBlocksInLongestChainBranchAsync(
                _kernelTestHelper.LongestBranchBlockList[0].GetHash(), 10);

            result.Count.ShouldBe(4);
            result[0].GetHash().ShouldBe(_kernelTestHelper.LongestBranchBlockList[1].GetHash());
            result[1].GetHash().ShouldBe(_kernelTestHelper.LongestBranchBlockList[2].GetHash());
            result[2].GetHash().ShouldBe(_kernelTestHelper.LongestBranchBlockList[3].GetHash());
            result[3].GetHash().ShouldBe(_kernelTestHelper.LongestBranchBlockList[4].GetHash());
        }
        public async Task Get_BlocksInLongestChainBranchAsync_ReturnHashes()
        {
            var result =
                await _fullBlockchainService.GetBlocksInLongestChainBranchAsync(
                    _kernelTestHelper.LongestBranchBlockList[0].GetHash(), 2);

            result.Count.ShouldBe(2);
            result[0].GetHash().ShouldBe(_kernelTestHelper.LongestBranchBlockList[1].GetHash());
            result[1].GetHash().ShouldBe(_kernelTestHelper.LongestBranchBlockList[2].GetHash());

            result = await _fullBlockchainService.GetBlocksInLongestChainBranchAsync(
                _kernelTestHelper.LongestBranchBlockList[0].GetHash(), 20);

            int count = 10;

            result.Count.ShouldBe(count);
            for (int i = 0; i < count; i++)
            {
                result[i].GetHash().ShouldBe(_kernelTestHelper.LongestBranchBlockList[i + 1].GetHash());
            }
        }