コード例 #1
0
ファイル: BlockSetTests.cs プロジェクト: wyk125/AElf
        public void NormalTest()
        {
            var blockSet = new BlockSet();

            var blocks = MockSeveralBlocks(5);

            foreach (var block in blocks)
            {
                blockSet.AddBlock(block);
            }

            Assert.True(blockSet.InvalidBlockCount == 5);

            blockSet.RemoveExecutedBlock(blocks[0].BlockHashToHex);

            Assert.True(blockSet.ExecutedBlockCount == 1);
            Assert.True(blockSet.InvalidBlockCount == 4);

            blockSet.RemoveExecutedBlock(blocks[0].BlockHashToHex);

            Assert.True(blockSet.ExecutedBlockCount == 1);
            Assert.True(blockSet.InvalidBlockCount == 4);

            blockSet.RemoveExecutedBlock(blocks[1].BlockHashToHex);

            Assert.True(blockSet.ExecutedBlockCount == 2);
            Assert.True(blockSet.InvalidBlockCount == 3);

            Assert.True(blockSet.IsBlockReceived(Hash.LoadHex(blocks[2].BlockHashToHex), blocks[2].Index));
            Assert.False(blockSet.IsBlockReceived(Hash.Generate(), blocks[2].Index));
        }
コード例 #2
0
ファイル: BlockSetTests.cs プロジェクト: wyk125/AElf
        public void FindFortHeightTest()
        {
            var blockSet = new BlockSet();

            // Generate block from 11 to 15
            var blocks = MockSeveralBlocks(5, 11);

            foreach (var block in blocks)
            {
                blockSet.AddBlock(block);
            }

            var forkHeight = blockSet.AnyLongerValidChain(14);

            Assert.True(forkHeight == 11);
        }