public async Task Clean_ChainBranch_Test() { var chain = await _fullBlockchainService.GetChainAsync(); var bestChainKey = chain.BestChainHash.ToStorageKey(); var longestChainKey = chain.LongestChainHash.ToStorageKey(); var discardedBranch = new DiscardedBranch { BranchKeys = new List <string> { bestChainKey, longestChainKey, _kernelTestHelper.ForkBranchBlockList.Last().GetHash().ToStorageKey(), "Not Exist Branch" }, NotLinkedKeys = new List <string> { _kernelTestHelper.NotLinkedBlockList[0].Header.PreviousBlockHash.ToStorageKey(), _kernelTestHelper.NotLinkedBlockList[1].Header.PreviousBlockHash.ToStorageKey(), "Not Exist Block" } }; await _fullBlockchainService.CleanChainBranchAsync(discardedBranch); var currentChain = await _fullBlockchainService.GetChainAsync(); currentChain.LongestChainHash.ShouldBe(currentChain.BestChainHash); currentChain.Branches.Count.ShouldBe(chain.Branches.Count - 2); currentChain.Branches.ShouldNotContainKey(longestChainKey); currentChain.Branches.ShouldNotContainKey(_kernelTestHelper.ForkBranchBlockList.Last().GetHash() .ToStorageKey()); currentChain.NotLinkedBlocks.Count.ShouldBe(3); currentChain.NotLinkedBlocks.ShouldNotContainKey(discardedBranch.NotLinkedKeys[0]); currentChain.NotLinkedBlocks.ShouldNotContainKey(discardedBranch.NotLinkedKeys[1]); }