示例#1
0
        public async Task Set_BestChain_Success()
        {
            var chain = await _fullBlockchainService.GetChainAsync();

            chain.BestChainHeight.ShouldBe(_kernelTestHelper.BestBranchBlockList.Last().Height);
            chain.BestChainHash.ShouldBe(_kernelTestHelper.BestBranchBlockList.Last().GetHash());

            await _fullBlockchainService.SetBestChainAsync(chain, chain.LongestChainHeight, chain.LongestChainHash);

            chain = await _fullBlockchainService.GetChainAsync();

            chain.BestChainHeight.ShouldBe(_kernelTestHelper.LongestBranchBlockList.Last().Height);
            chain.BestChainHash.ShouldBe(_kernelTestHelper.LongestBranchBlockList.Last().GetHash());
        }
        public async Task Set_BestChain_Success()
        {
            BestChainFoundEventData eventData = null;

            _eventBus.Subscribe <BestChainFoundEventData>(d =>
            {
                eventData = d;
                return(Task.CompletedTask);
            });

            var chain = await _fullBlockchainService.GetChainAsync();

            chain.BestChainHeight.ShouldBe(_kernelTestHelper.BestBranchBlockList.Last().Height);
            chain.BestChainHash.ShouldBe(_kernelTestHelper.BestBranchBlockList.Last().GetHash());

            await _fullBlockchainService.SetBestChainAsync(chain, chain.LongestChainHeight, chain.LongestChainHash);

            chain = await _fullBlockchainService.GetChainAsync();

            chain.BestChainHeight.ShouldBe(_kernelTestHelper.LongestBranchBlockList.Last().Height);
            chain.BestChainHash.ShouldBe(_kernelTestHelper.LongestBranchBlockList.Last().GetHash());

            eventData.ShouldNotBeNull();
            eventData.BlockHash.ShouldBe(chain.BestChainHash);
            eventData.BlockHeight.ShouldBe(chain.BestChainHeight);
        }