public void BlockRepositoryPutBatch() { using (var blockRepository = new BlockRepository(this.network, TestBase.CreateDataFolder(this), DateTimeProvider.Default, this.loggerFactory)) { blockRepository.SetTxIndexAsync(true).Wait(); var blocks = new List <Block>(); for (int i = 0; i < 5; i++) { Block block = this.network.CreateBlock(); block.AddTransaction(this.network.CreateTransaction()); block.AddTransaction(this.network.CreateTransaction()); block.Transactions[0].AddInput(new TxIn(Script.Empty)); block.Transactions[0].AddOutput(Money.COIN + i * 2, Script.Empty); block.Transactions[1].AddInput(new TxIn(Script.Empty)); block.Transactions[1].AddOutput(Money.COIN + i * 2 + 1, Script.Empty); block.UpdateMerkleRoot(); block.Header.HashPrevBlock = blocks.Any() ? blocks.Last().GetHash() : this.network.GenesisHash; blocks.Add(block); } // put blockRepository.PutAsync(new HashHeightPair(blocks.Last().GetHash(), blocks.Count), blocks).GetAwaiter().GetResult(); // check the presence of each block in the repository foreach (Block block in blocks) { Block received = blockRepository.GetBlockAsync(block.GetHash()).GetAwaiter().GetResult(); Assert.True(block.ToBytes().SequenceEqual(received.ToBytes())); foreach (Transaction transaction in block.Transactions) { Transaction trx = blockRepository.GetTransactionByIdAsync(transaction.GetHash()).GetAwaiter().GetResult(); Assert.True(trx.ToBytes().SequenceEqual(transaction.ToBytes())); } } // delete blockRepository.DeleteAsync(new HashHeightPair(blocks.ElementAt(2).GetHash(), 2), new[] { blocks.ElementAt(2).GetHash() }.ToList()).GetAwaiter().GetResult(); Block deleted = blockRepository.GetBlockAsync(blocks.ElementAt(2).GetHash()).GetAwaiter().GetResult(); Assert.Null(deleted); } }