public async Task Add_Block_Success() { var block = new Block { Height = 2, Header = new BlockHeader(), Body = new BlockBody() }; for (var i = 0; i < 3; i++) { block.Body.AddTransaction(_kernelTestHelper.GenerateTransaction()); } var existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.ShouldBeNull(); await _fullBlockchainService.AddBlockAsync(block); existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.GetHash().ShouldBe(block.GetHash()); existBlock.Body.TransactionsCount.ShouldBe(3); foreach (var tx in block.Body.TransactionList) { var existTransaction = await _transactionManager.GetTransaction(tx.GetHash()); existTransaction.ShouldBe(tx); } }
public async Task Add_Block_Success() { var transactions = new List <Transaction>(); for (var i = 0; i < 3; i++) { var transaction = _kernelTestHelper.GenerateTransaction(); transactions.Add(transaction); } var block = _kernelTestHelper.GenerateBlock(0, Hash.Empty, transactions); var existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.ShouldBeNull(); await _fullBlockchainService.AddBlockAsync(block); await _fullBlockchainService.AddTransactionsAsync(transactions); existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.GetHash().ShouldBe(block.GetHash()); existBlock.Body.TransactionsCount.ShouldBe(3); foreach (var tx in transactions) { var existTransaction = await _transactionManager.GetTransactionAsync(tx.GetHash()); existTransaction.ShouldBe(tx); } }
public async Task Add_Block_Success() { var transactions = new List <Transaction>(); for (var i = 0; i < 3; i++) { var transaction = _kernelTestHelper.GenerateTransaction(); transactions.Add(transaction); } var block = _kernelTestHelper.GenerateBlock(0, Hash.Empty, transactions); var existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.ShouldBeNull(); await _fullBlockchainService.AddBlockAsync(block); existBlock = await _fullBlockchainService.GetBlockByHashAsync(block.GetHash()); existBlock.ShouldBe(block); var blockHeader = await _fullBlockchainService.GetBlockHeaderByHashAsync(block.GetHash()); blockHeader.ShouldBe(block.Header); }