public async Task Transaction_Test() { var transaction1 = _kernelTestHelper.GenerateTransaction(); var transaction2 = _kernelTestHelper.GenerateTransaction(); var hasTransaction = await _fullBlockchainService.HasTransactionAsync(transaction1.GetHash()); hasTransaction.ShouldBeFalse(); hasTransaction = await _fullBlockchainService.HasTransactionAsync(transaction2.GetHash()); hasTransaction.ShouldBeFalse(); await _fullBlockchainService.AddTransactionsAsync(new List <Transaction> { transaction1, transaction2 }); var transactions = await _fullBlockchainService.GetTransactionsAsync(new List <Hash> { transaction1.GetHash(), transaction2.GetHash() }); transactions[0].ShouldBe(transaction1); transactions[1].ShouldBe(transaction2); hasTransaction = await _fullBlockchainService.HasTransactionAsync(transaction1.GetHash()); hasTransaction.ShouldBeTrue(); hasTransaction = await _fullBlockchainService.HasTransactionAsync(transaction2.GetHash()); hasTransaction.ShouldBeTrue(); }
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]); }