Fix nullability warnings in HwiClient
MODIFY
WalletWasabi.Tests/UnitTests/Hwi/DefaultResponseTests.cs
WalletWasabi.Tests/UnitTests/Hwi/DefaultResponseTests.cs
@@ -85,17 +85,17 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
[MemberData(nameof(GetHwiClientConfigurationCombinationValues))]
public async Task ThrowArgumentExceptionsForWrongDevicePathAsync(HwiClient client)
{
- var wrongDeviePaths = new[] { "", " " };
+ var wrongDeviePaths = new[] { null, "", " " };
using var cts = new CancellationTokenSource(ReasonableRequestTimeout);
foreach (HardwareWalletModels deviceType in Enum.GetValues(typeof(HardwareWalletModels)).Cast<HardwareWalletModels>())
{
foreach (var wrongDevicePath in wrongDeviePaths)
{
- await Assert.ThrowsAsync<ArgumentException>(async () => await client.WipeAsync(deviceType, wrongDevicePath, cts.Token));
- await Assert.ThrowsAsync<ArgumentException>(async () => await client.SetupAsync(deviceType, wrongDevicePath, false, cts.Token));
+ await Assert.ThrowsAnyAsync<ArgumentException>(async () => await client.WipeAsync(deviceType, wrongDevicePath, cts.Token));
+ await Assert.ThrowsAnyAsync<ArgumentException>(async () => await client.SetupAsync(deviceType, wrongDevicePath, false, cts.Token));
}
- await Assert.ThrowsAsync<ArgumentNullException>(async () => await client.WipeAsync(deviceType, null!, cts.Token));
- await Assert.ThrowsAsync<ArgumentNullException>(async () => await client.SetupAsync(deviceType, null!, false, cts.Token));
+ await Assert.ThrowsAnyAsync<ArgumentException>(async () => await client.WipeAsync(deviceType, null!, cts.Token));
+ await Assert.ThrowsAnyAsync<ArgumentException>(async () => await client.SetupAsync(deviceType, null!, false, cts.Token));
}
}

MODIFY
WalletWasabi/Hwi/HwiClient.cs
WalletWasabi/Hwi/HwiClient.cs
@@ -294,21 +294,10 @@ namespace WalletWasabi.Hwi
var hasFingerprint = fingerprint.HasValue;
// Fingerprint and devicetype-devicepath pair cannot happen the same time.
- var notSupportedExceptionMessage = $"Provide either {nameof(fingerprint)} or {nameof(devicePath)}-{nameof(deviceType)} pair, not both.";
- if (hasDeviceType)
- {
- Guard.NotNull(nameof(devicePath), devicePath);
- if (hasFingerprint)
+ if (!(hasDeviceType && hasDevicePath ^ hasFingerprint))
{
- throw new NotSupportedException(notSupportedExceptionMessage);
- }
- }
- if (hasFingerprint)
- {
- if (hasDevicePath || hasDeviceType)
- {
- throw new NotSupportedException(notSupportedExceptionMessage);
- }
+ var argumentExceptionMessage = $"Provide either {nameof(fingerprint)} or {nameof(devicePath)}-{nameof(deviceType)} pair, not both.";
+ throw new ArgumentException(argumentExceptionMessage);
}
if (hasDevicePath)

Fix nullability warnings in HwiClient