Finish up tests
ADD
WalletWasabi.Tests/UnitTests/Clients/CrashReportTests.cs
+using System;
+using WalletWasabi.Gui.CrashReport;
+using Xunit;
+
+namespace WalletWasabi.Tests.UnitTests.Clients
+{
+ public class CrashReportTests
+ {
+ [Fact]
+ public void CrashReporterCliArgTest()
+ {
+ CrashReporter crashing = new();
+
+ Exception innerEx = new IndexOutOfRangeException("InnerMessage");
+ Exception ex;
+ try
+ {
+ // Throw it to have a stack-trace.
+ throw new InvalidOperationException("Message", innerEx);
+ }
+ catch (Exception exc)
+ {
+ ex = exc;
+ }
+
+ crashing.SetException(ex);
+ Assert.True(crashing.HadException);
+
+ var args = crashing.ToCliArguments();
+
+ CrashReporter reporting = new();
+
+ // Args are split by space and passed to Main IRL.
+ Assert.True(reporting.TryProcessCliArgs(args.Split(' ')));
+ Assert.True(reporting.IsReport);
+ Assert.Equal(reporting.SerializedException, ex.ToSerializableException());
+ }
+ }
+}

MODIFY
WalletWasabi.Tests/UnitTests/SerializableExceptionTests.cs
WalletWasabi.Tests/UnitTests/SerializableExceptionTests.cs
@@ -7,14 +7,14 @@ namespace WalletWasabi.Tests.UnitTests
public class SerializableExceptionTests
{
[Fact]
- public void UtxoRefereeSerialization()
+ public void SerializableExceptionTest()
{
var message = "Foo Bar Buzz";
var innerMessage = "Inner Foo Bar Buzz";
var innerStackTrace = "";
Exception ex;
- string stackTrace;
+ string? stackTrace;
try
{
try
@@ -41,9 +41,12 @@ namespace WalletWasabi.Tests.UnitTests
Assert.Equal(stackTrace, result.StackTrace);
Assert.Equal(typeof(InvalidOperationException).FullName, result.ExceptionType);
- Assert.Equal(innerMessage, result.InnerException.Message);
- Assert.Equal(innerStackTrace, result.InnerException.StackTrace);
- Assert.Equal(typeof(OperationCanceledException).FullName, result.InnerException.ExceptionType);
+ Assert.Equal(innerMessage, result.InnerException?.Message);
+ Assert.Equal(innerStackTrace, result.InnerException?.StackTrace);
+ Assert.Equal(typeof(OperationCanceledException).FullName, result.InnerException?.ExceptionType);
+
+ var serializableException2 = ex.ToSerializableException();
+ Assert.Equal(serializableException, serializableException2);
}
}
}

MODIFY
WalletWasabi/Models/SerializableException.cs
WalletWasabi/Models/SerializableException.cs
@@ -70,9 +70,10 @@ namespace WalletWasabi.Models
return false;
}
- public override int GetHashCode()
- {
- return (ExceptionType, Message, StackTrace, InnerException).GetHashCode();
- }
+ public override int GetHashCode() => HashCode.Combine(ExceptionType, Message, StackTrace, InnerException);
+
+ public static bool operator ==(SerializableException? se1, SerializableException? se2) => se1 is null || se2 is null ? Equals(se1, se2) : se1.Equals(se2);
+
+ public static bool operator !=(SerializableException? se1, SerializableException? se2) => se1 is null || se2 is null ? !Equals(se1, se2) : !(se1.Equals(se2));
}
}

Finish up tests