Fix some IDisposables
MODIFY
WalletWasabi.Tests/Helpers/HttpClientWrapper.cs
WalletWasabi.Tests/Helpers/HttpClientWrapper.cs
@@ -7,21 +7,21 @@ namespace WalletWasabi.Tests.Helpers
{
public class HttpClientWrapper : IHttpClient
{
- private readonly HttpClient _httpClient;
-
public HttpClientWrapper(HttpClient httpClient)
{
- _httpClient = httpClient;
+ HttpClient = httpClient;
}
- public Func<Uri>? BaseUriGetter => () => _httpClient.BaseAddress;
+ 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);
+ return HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token);
}
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
@@ -124,13 +124,19 @@ namespace WalletWasabi.Tests.Helpers
=> CreateAlice(CreateCoin(key, amount), CreateOwnershipProof(key), round);
public static Alice CreateAlice(Money amount, Round round)
- => CreateAlice(new Key(), amount, round);
+ {
+ using var key = new Key();
+ return CreateAlice(key, amount, round);
+ }
- public static Alice CreateAlice(Key key, Round round)
- => CreateAlice(key, Money.Coins(1), round);
+ public static Alice CreateAlice(Key key, Round round) =>
+ CreateAlice(key, Money.Coins(1), round);
public static Alice CreateAlice(Round round)
- => CreateAlice(new Key(), Money.Coins(1), round);
+ {
+ using var key = new Key();
+ return CreateAlice(key, Money.Coins(1), round);
+ }
public static ArenaClient CreateArenaClient(Arena arena)
{
@@ -148,10 +154,11 @@ namespace WalletWasabi.Tests.Helpers
var (zeroAmountCredentialRequest, _) = amClient.CreateRequestForZeroAmount();
var (zeroVsizeCredentialRequest, _) = vsClient.CreateRequestForZeroAmount();
+ using var newkey = new Key();
return new(
round.Id,
prevout ?? BitcoinFactory.CreateOutPoint(),
- CreateOwnershipProof(key ?? new Key(), round.Id),
+ CreateOwnershipProof(key ?? newkey, round.Id),
zeroAmountCredentialRequest,
zeroVsizeCredentialRequest);
}

MODIFY
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
@@ -850,7 +850,10 @@ namespace WalletWasabi.Tests.RegressionTests
await aliceClient.PostSignaturesAsync(witnesses);
}
- ((CachedRpcClient)rpc)?.Cache.Remove("GetRawMempoolAsync");
+ if (rpc is CachedRpcClient cachedRpc)
+ {
+ cachedRpc.Cache.Remove("GetRawMempoolAsync");
+ }
uint256[] mempooltxs = await rpc.GetRawMempoolAsync();
Assert.Contains(transactionId, mempooltxs);

MODIFY
WalletWasabi.Tests/RegressionTests/Common.cs
WalletWasabi.Tests/RegressionTests/Common.cs
@@ -82,8 +82,8 @@ namespace WalletWasabi.Tests.RegressionTests
var serviceConfiguration = new ServiceConfiguration(MixUntilAnonymitySet.PrivacyLevelSome.ToString(), 2, 21, 50, regTestFixture.BackendRegTestNode.P2pEndPoint, Money.Coins(WalletWasabi.Helpers.Constants.DefaultDustThreshold));
var dir = Helpers.Common.GetWorkDir(callerFilePath, callerMemberName);
- var indexStore = new IndexStore(Path.Combine(dir, "indexStore"), network, new SmartHeaderChain());
- var transactionStore = new AllTransactionStore(Path.Combine(dir, "transactionStore"), network);
+ await using var indexStore = new IndexStore(Path.Combine(dir, "indexStore"), network, new SmartHeaderChain());
+ await using var transactionStore = new AllTransactionStore(Path.Combine(dir, "transactionStore"), network);
var mempoolService = new MempoolService();
var blocks = new FileSystemBlockRepository(Path.Combine(dir, "blocks"), network);
var bitcoinStore = new BitcoinStore(indexStore, transactionStore, mempoolService, blocks);

MODIFY
WalletWasabi.Tests/UnitTests/AllFeeEstimateTests.cs
WalletWasabi.Tests/UnitTests/AllFeeEstimateTests.cs
@@ -29,10 +29,11 @@ namespace WalletWasabi.Tests.UnitTests
var serialized = JsonConvert.SerializeObject(allFee);
var deserialized = JsonConvert.DeserializeObject<AllFeeEstimate>(serialized);
- Assert.Equal(estimations[2], deserialized.Estimations[2]);
- Assert.Equal(estimations[3], deserialized.Estimations[3]);
- Assert.Equal(estimations[19], deserialized.Estimations[36]);
- Assert.Equal(EstimateSmartFeeMode.Conservative, deserialized.Type);
+ Assert.NotNull(deserialized);
+ Assert.Equal(estimations[2], deserialized!.Estimations[2]);
+ Assert.Equal(estimations[3], deserialized!.Estimations[3]);
+ Assert.Equal(estimations[19], deserialized!.Estimations[36]);
+ Assert.Equal(EstimateSmartFeeMode.Conservative, deserialized!.Type);
}
[Fact]

MODIFY
WalletWasabi.Tests/UnitTests/Crypto/OwnershipProofTest.cs
WalletWasabi.Tests/UnitTests/Crypto/OwnershipProofTest.cs
@@ -59,7 +59,7 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
// Valid proof, invalid scriptPubKey
// [all all all all all all all all all all all all]/84'/0'/0'/1/1
- var invalidKey = new Key(Encoders.Hex.DecodeData("7b041dd735e7202d3c1b9592147894ed24da6355f0cd66573c273c0df1afa78a"));
+ using var invalidKey = new Key(Encoders.Hex.DecodeData("7b041dd735e7202d3c1b9592147894ed24da6355f0cd66573c273c0df1afa78a"));
var invalidScriptPubKey = PayToWitPubKeyHashTemplate.Instance.GenerateScriptPubKey(invalidKey.PubKey);
Assert.False(ownershipProof.VerifyOwnership(invalidScriptPubKey, commitmentData, false));

MODIFY
WalletWasabi.Tests/UnitTests/Crypto/StrobeTests.cs
WalletWasabi.Tests/UnitTests/Crypto/StrobeTests.cs
@@ -103,6 +103,7 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var testSet = JsonConvert.DeserializeObject<StrobeTestSet>(testVectorFile);
Assert.NotNull(testSet);
+
// return all test vectors except the one for streaming because it is not implemented.
foreach (var vector in testSet!.TestVectors.Where(x => !x.Name.Contains("streaming")))
{

MODIFY
WalletWasabi.Tests/UnitTests/InputsResponseTests.cs
WalletWasabi.Tests/UnitTests/InputsResponseTests.cs
@@ -17,7 +17,8 @@ namespace WalletWasabi.Tests.UnitTests
var serialized = JsonConvert.SerializeObject(resp);
var deserialized = JsonConvert.DeserializeObject<InputsResponse>(serialized);
- Assert.Equal(resp.RoundId, deserialized.RoundId);
+ Assert.NotNull(deserialized);
+ Assert.Equal(resp.RoundId, deserialized!.RoundId);
Assert.Equal(resp.UniqueId, deserialized.UniqueId);
}
}

Fix some IDisposables