public async Task Create_Chain_Success() { var transactions = new List <Transaction> { _kernelTestHelper.GenerateTransaction(), _kernelTestHelper.GenerateTransaction() }; var block = _kernelTestHelper.GenerateBlock(0, Hash.Empty, transactions); var chain = await _fullBlockchainService.GetChainAsync(); chain.ShouldBeNull(); var existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.ShouldBeNull(); var createChainResult = await _fullBlockchainService.CreateChainAsync(block, transactions); chain = await _fullBlockchainService.GetChainAsync(); chain.ShouldNotBeNull(); chain.ShouldBe(createChainResult); existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.GetHash().ShouldBe(block.GetHash()); var existTransactions = await _fullBlockchainService.GetTransactionsAsync(transactions.Select(t => t.GetHash())); existTransactions.ShouldContain(transactions[0]); existTransactions.ShouldContain(transactions[1]); }
public async Task Create_Chain_Success() { var block = new Block { Header = new BlockHeader { Height = KernelConstants.GenesisBlockHeight, PreviousBlockHash = Hash.Empty, Time = Timestamp.FromDateTime(DateTime.UtcNow) }, Body = new BlockBody() }; var chain = await _fullBlockchainService.GetChainAsync(); chain.ShouldBeNull(); var existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.ShouldBeNull(); var createChainResult = await _fullBlockchainService.CreateChainAsync(block); chain = await _fullBlockchainService.GetChainAsync(); chain.ShouldNotBeNull(); chain.ShouldBe(createChainResult); existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.GetHash().ShouldBe(block.GetHash()); }
public async Task Create_Chain_Success() { var block = _kernelTestHelper.GenerateBlock(0, Hash.Empty, new List <Transaction>()); var chain = await _fullBlockchainService.GetChainAsync(); chain.ShouldBeNull(); var existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.ShouldBeNull(); var createChainResult = await _fullBlockchainService.CreateChainAsync(block, new List <Transaction>()); chain = await _fullBlockchainService.GetChainAsync(); chain.ShouldNotBeNull(); chain.ShouldBe(createChainResult); existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.GetHash().ShouldBe(block.GetHash()); }