mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Fix CanUseTorClient test flakyness
This commit is contained in:
@@ -1357,15 +1357,25 @@ namespace BTCPayServer.Tests
|
|||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
AssertConnectionDropped();
|
AssertConnectionDropped();
|
||||||
|
|
||||||
Logs.Tester.LogInformation("Querying an onin address which can't be found should send http 500");
|
Logs.Tester.LogInformation("Querying an onion address which can't be found should send http 500");
|
||||||
response = await client.GetAsync("http://dwoduwoi.onion/");
|
response = await client.GetAsync("http://dwoduwoi.onion/");
|
||||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||||
AssertConnectionDropped();
|
AssertConnectionDropped();
|
||||||
|
|
||||||
Logs.Tester.LogInformation("Querying valid onion but unreachable should send error 502");
|
Logs.Tester.LogInformation("Querying valid onion but unreachable should send error 502");
|
||||||
response = await client.GetAsync("http://fastrcl5totos3vekjbqcmgpnias5qytxnaj7gpxtxhubdcnfrkapqad.onion/");
|
using (CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(20)))
|
||||||
Assert.Equal(HttpStatusCode.BadGateway, response.StatusCode);
|
{
|
||||||
AssertConnectionDropped();
|
try
|
||||||
|
{
|
||||||
|
response = await client.GetAsync("http://nzwsosflsoquxirwb2zikz6uxr3u5n5u73l33umtdx4hq5mzm5dycuqd.onion/", cts.Token);
|
||||||
|
Assert.Equal(HttpStatusCode.BadGateway, response.StatusCode);
|
||||||
|
AssertConnectionDropped();
|
||||||
|
}
|
||||||
|
catch when (cts.Token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
Logs.Tester.LogInformation("Skipping this test, it timed out");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ handshake:
|
|||||||
}
|
}
|
||||||
_ = Relay(socksSocket, clientSocket, cancellationToken);
|
_ = Relay(socksSocket, clientSocket, cancellationToken);
|
||||||
}
|
}
|
||||||
catch (SocksException e) when (e.SocksErrorCode == SocksErrorCode.HostUnreachable || e.SocksErrorCode == SocksErrorCode.HostUnreachable)
|
catch (SocksException e) when (e.SocksErrorCode == SocksErrorCode.NetworkUnreachable || e.SocksErrorCode == SocksErrorCode.HostUnreachable)
|
||||||
{
|
{
|
||||||
await SendAsync(clientSocket, $"{httpVersion} 502 Bad Gateway\r\nContent-Length: 0\r\n\r\n", cancellationToken);
|
await SendAsync(clientSocket, $"{httpVersion} 502 Bad Gateway\r\nContent-Length: 0\r\n\r\n", cancellationToken);
|
||||||
goto done;
|
goto done;
|
||||||
|
|||||||
Reference in New Issue
Block a user