public async Task eth_blockNumber() { var resp = await Api.BlockNumberAsync(CancellationToken.None) .ConfigureAwait(false); Console.WriteLine(resp.Result); TestPropetries(resp); }
public async Task TestFailedNode(string url) { var sw = new Stopwatch(); Console.WriteLine(url); sw.Start(); var token = CancellationToken.None; var httpClient = new RepeatHttpClient(); var httpManager = new HttpManager(httpClient); var api = new OperationManager(httpManager); httpManager.UrlToConnect = url; sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); sw.Restart(); var resp1 = await api.ProtocolVersionAsync(token) .ConfigureAwait(false); Assert.IsFalse(resp1.IsError); Console.WriteLine($"{resp1.Result}"); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); sw.Restart(); var resp2 = await api.NetVersionAsync(CancellationToken.None) .ConfigureAwait(false); Assert.IsFalse(resp2.IsError); Console.WriteLine($"{resp2.Result}"); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); sw.Restart(); var resp3 = await api.BlockNumberAsync(CancellationToken.None) .ConfigureAwait(false); Assert.IsFalse(resp3.IsError); Console.WriteLine($"{resp3.Result}"); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); sw.Restart(); var resp4 = await api.GetBlockByNumberAsync(resp3.Result.Value, true, CancellationToken.None) .ConfigureAwait(false); Assert.IsFalse(resp4.IsError); Console.WriteLine($"{resp4.Result}"); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); sw.Restart(); var resp5 = await api.GetTransactionReceiptAsync(new HexValue("0x9959ddd050dbcd23f9732e5c3870813eaf8155d081d10785694420160dc7e747"), CancellationToken.None) .ConfigureAwait(false); Assert.IsFalse(resp5.IsError); Assert.IsFalse(resp5.Result == null); Console.WriteLine($"{resp5.Result}"); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); sw.Restart(); var resp6 = await api.GetBlockByNumberAsync(4837041, true, CancellationToken.None) .ConfigureAwait(false); Assert.IsFalse(resp6.IsError); Assert.IsFalse(resp6.Result == null); Assert.IsTrue(resp6.Result.Transactions.Length == 221); Console.WriteLine($"{resp6.Result}"); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); }