Assert GetVersionAsync throws OperationCanceledException.
MODIFY
WalletWasabi.Tests/HwiTests/HwiClientTests.cs
WalletWasabi.Tests/HwiTests/HwiClientTests.cs
@@ -41,7 +41,7 @@ namespace WalletWasabi.Tests.HwiTests
[Theory]
[MemberData(nameof(GetDifferentNetworkValues))]
- public async Task CanGetVersionAsync(Network network)
+ public async Task GetVersionTestsAsync(Network network)
{
var client = new HwiClient(network);
@@ -50,6 +50,11 @@ namespace WalletWasabi.Tests.HwiTests
Version version = await client.GetVersionAsync(cts.Token);
Assert.Equal(new Version("1.0.1"), version);
}
+
+ using (var cts = new CancellationTokenSource(1))
+ {
+ await Assert.ThrowsAsync<OperationCanceledException>(async () => await client.GetVersionAsync(cts.Token));
+ }
}
}
}

MODIFY
WalletWasabi/Hwi2/HwiClient.cs
WalletWasabi/Hwi2/HwiClient.cs
@@ -25,6 +25,8 @@ namespace WalletWasabi.Hwi2
var hwiPath = Path.Combine(fullBaseDirectory, "Hwi2", "Binaries", "hwi-win64", "hwi.exe");
string arguments = "--version";
+ try
+ {
using (var process = Process.Start(
new ProcessStartInfo
{
@@ -61,6 +63,11 @@ namespace WalletWasabi.Hwi2
throw new FormatException($"Cannot parse version from HWI's response. Response: {responseString}.");
}
}
+ catch (Exception ex) when (ex is OperationCanceledException || ex is TaskCanceledException || ex is TimeoutException)
+ {
+ throw new OperationCanceledException($"'hwi {arguments}' operation is canceled.", ex);
+ }
+ }
public static bool TryParseVersion(string hwiResponse, string substringFrom, out Version version)
{

Assert GetVersionAsync throws OperationCanceledException.