public void CanUseBatchedRequests()
        {
            using (NodeBuilder builder = NodeBuilder.Create(this))
            {
                CoreNode node = builder.CreateBitcoinCoreNode(version: BitcoinCoreVersion15);
                builder.StartAll();

                RPCClient rpcClient = node.CreateRPCClient();

                uint256[] blocks = rpcClient.Generate(10);
                Assert.Throws <InvalidOperationException>(() => rpcClient.SendBatch());
                rpcClient = rpcClient.PrepareBatch();
                var requests = new List <Task <uint256> >();
                for (int i = 1; i < 11; i++)
                {
                    requests.Add(rpcClient.GetBlockHashAsync(i));
                }
                Thread.Sleep(1000);
                foreach (Task <uint256> req in requests)
                {
                    Assert.Equal(TaskStatus.WaitingForActivation, req.Status);
                }
                rpcClient.SendBatch();
                rpcClient = rpcClient.PrepareBatch();
                int blockIndex = 0;
                foreach (Task <uint256> req in requests)
                {
                    Assert.Equal(blocks[blockIndex], req.Result);
                    Assert.Equal(TaskStatus.RanToCompletion, req.Status);
                    blockIndex++;
                }
                requests.Clear();

                requests.Add(rpcClient.GetBlockHashAsync(10));
                requests.Add(rpcClient.GetBlockHashAsync(11));
                requests.Add(rpcClient.GetBlockHashAsync(9));
                requests.Add(rpcClient.GetBlockHashAsync(8));
                rpcClient.SendBatch();
                rpcClient = rpcClient.PrepareBatch();
                Assert.Equal(TaskStatus.RanToCompletion, requests[0].Status);
                Assert.Equal(TaskStatus.Faulted, requests[1].Status);
                Assert.Equal(TaskStatus.RanToCompletion, requests[2].Status);
                Assert.Equal(TaskStatus.RanToCompletion, requests[3].Status);
                requests.Clear();

                requests.Add(rpcClient.GetBlockHashAsync(10));
                requests.Add(rpcClient.GetBlockHashAsync(11));
                rpcClient.CancelBatch();
                rpcClient = rpcClient.PrepareBatch();
                Thread.Sleep(100);
                Assert.Equal(TaskStatus.Canceled, requests[0].Status);
                Assert.Equal(TaskStatus.Canceled, requests[1].Status);
            }
        }