Remove `HttpClientWrapper`
DELETE
WalletWasabi.Tests/Helpers/HttpClientWrapper.cs
-using System.Net.Http;
-using System.Threading;
-using System.Threading.Tasks;
-using WalletWasabi.Tor.Http;
-
-namespace WalletWasabi.Tests.Helpers;
-
-public class HttpClientWrapper : IHttpClient
-{
- public HttpClientWrapper(HttpClient httpClient)
- {
- HttpClient = httpClient;
- }
-
- private HttpClient HttpClient { get; }
-
- public Func<Uri>? BaseUriGetter => () => HttpClient.BaseAddress;
-
- public virtual Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken token = default)
- {
- // HttpCompletionOption is required here because of a bug in dotnet.
- // without it the test fails randomly with ObjectDisposedException
- // see: https://github.com/dotnet/runtime/issues/23870
- return HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token);
- }
-}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/StuttererHttpClient.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/StuttererHttpClient.cs
@@ -4,11 +4,12 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Tests.Helpers;
+using WalletWasabi.Tor.Http;
using Xunit;
namespace WalletWasabi.Tests.UnitTests.WabiSabi.Integration;
-public class StuttererHttpClient : HttpClientWrapper
+public class StuttererHttpClient : ClearnetHttpClient
{
public StuttererHttpClient(HttpClient httpClient) : base(httpClient)
{

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/WabiSabiApiApplicationFactory.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/WabiSabiApiApplicationFactory.cs
@@ -86,5 +86,5 @@ public class WabiSabiApiApplicationFactory<TStartup> : WebApplicationFactory<TSt
}
public WabiSabiHttpApiClient CreateWabiSabiHttpApiClient(HttpClient httpClient) =>
- new(new HttpClientWrapper(httpClient));
+ new(new ClearnetHttpClient(httpClient));
}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/WabiSabiHttpApiIntegrationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/WabiSabiHttpApiIntegrationTests.cs
@@ -148,7 +148,7 @@ public class WabiSabiHttpApiIntegrationTests : IClassFixture<WabiSabiApiApplicat
// Create the coinjoin client
using PersonCircuit personCircuit = new();
- IHttpClient httpClientWrapper = new HttpClientWrapper(httpClient);
+ IHttpClient httpClientWrapper = new ClearnetHttpClient(httpClient);
var apiClient = _apiApplicationFactory.CreateWabiSabiHttpApiClient(httpClient);
var mockHttpClientFactory = new Mock<IWasabiHttpClientFactory>(MockBehavior.Strict);
@@ -229,7 +229,7 @@ public class WabiSabiHttpApiIntegrationTests : IClassFixture<WabiSabiApiApplicat
// Create the coinjoin client
using PersonCircuit personCircuit = new();
- IHttpClient httpClientWrapper = new HttpClientWrapper(httpClient);
+ IHttpClient httpClientWrapper = new ClearnetHttpClient(httpClient);
var apiClient = _apiApplicationFactory.CreateWabiSabiHttpApiClient(httpClient);
var mockHttpClientFactory = new Mock<IWasabiHttpClientFactory>(MockBehavior.Strict);
@@ -350,7 +350,7 @@ public class WabiSabiHttpApiIntegrationTests : IClassFixture<WabiSabiApiApplicat
// Create the coinjoin client
using PersonCircuit personCircuit = new();
- IHttpClient httpClientWrapper = new HttpClientWrapper(httpClient);
+ IHttpClient httpClientWrapper = new ClearnetHttpClient(httpClient);
var apiClient = _apiApplicationFactory.CreateWabiSabiHttpApiClient(httpClient);
var mockHttpClientFactory = new Mock<IWasabiHttpClientFactory>(MockBehavior.Strict);
@@ -374,7 +374,7 @@ public class WabiSabiHttpApiIntegrationTests : IClassFixture<WabiSabiApiApplicat
// Creates a IBackendHttpClientFactory that creates an HttpClient that says everything is okay
// when a signature is sent but it doesn't really send it.
- var nonSigningHttpClientMock = new Mock<HttpClientWrapper>(MockBehavior.Strict, httpClient);
+ var nonSigningHttpClientMock = new Mock<ClearnetHttpClient>(MockBehavior.Strict, httpClient);
nonSigningHttpClientMock
.Setup(httpClient => httpClient.SendAsync(It.IsAny<HttpRequestMessage>(), It.IsAny<CancellationToken>()))
.CallBase();
@@ -461,7 +461,7 @@ public class WabiSabiHttpApiIntegrationTests : IClassFixture<WabiSabiApiApplicat
using PersonCircuit personCircuit = new();
IHttpClient httpClientWrapper = new MonkeyHttpClient(
- new HttpClientWrapper(app.CreateClient()),
+ new ClearnetHttpClient(app.CreateClient()),
() => // This monkey injects `HttpRequestException` randomly to simulate errors in the communication.
{
if (Random.Shared.NextDouble() < faultInjectorMonkeyAggressiveness)

MODIFY
WalletWasabi/Tor/Http/ClearnetHttpClient.cs
WalletWasabi/Tor/Http/ClearnetHttpClient.cs
@@ -11,6 +11,12 @@ namespace WalletWasabi.Tor.Http;
/// <remarks>Inner <see cref="HttpClient"/> instance is thread-safe.</remarks>
public class ClearnetHttpClient : IHttpClient
{
+ public ClearnetHttpClient(HttpClient httpClient)
+ {
+ BaseUriGetter = () => httpClient.BaseAddress ?? throw new NotSupportedException("No base address was set.");
+ HttpClient = httpClient;
+ }
+
public ClearnetHttpClient(HttpClient httpClient, Func<Uri>? baseUriGetter)
{
BaseUriGetter = baseUriGetter;
@@ -23,7 +29,7 @@ public class ClearnetHttpClient : IHttpClient
private HttpClient HttpClient { get; }
/// <inheritdoc cref="HttpClient.SendAsync(HttpRequestMessage, CancellationToken)"/>
- public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken token = default)
+ public virtual Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken token = default)
{
return HttpClient.SendAsync(request, token);
}

Remove `HttpClientWrapper`