One class, one file
MODIFY
WalletWasabi.Gui/Rpc/JsonRpcRequestHandler.cs
WalletWasabi.Gui/Rpc/JsonRpcRequestHandler.cs
@@ -40,7 +40,7 @@ namespace WalletWasabi.Gui.Rpc
/// <summary>
/// Perses the request and dispatch it to the correct service's method.
- /// <summary>
+ /// </summary>
/// <param name="body">The raw rpc request.</param>
/// <param name="cancellationToken">The cancellation token that will be past to the service handler in case it expects/accept one.</param>
/// <returns>The response that, after serialization, is returned as response.</returns>
@@ -88,7 +88,7 @@ namespace WalletWasabi.Gui.Rpc
// then pass the cancellationToken we have. This will allow us to cancel async requests when the server is stopped.
if (parameters.Count == methodParameters.Count -1)
{
- var position = methodParameters.FindIndex(x=>x.type == typeof(CancellationTokenSource));
+ var position = methodParameters.FindIndex(x=>x.type == typeof(CancellationToken));
if(position > -1)
{
parameters.Insert(position, cancellationToken);

MODIFY
WalletWasabi.Tests/RpcTests.cs
WalletWasabi.Tests/RpcTests.cs
-using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -9,31 +8,6 @@ using Xunit;
namespace WalletWasabi.Tests
{
- class TesteableRpcService
- {
- public void UnpublishedProcedure() { }
-
- [JsonRpcMethod("say")]
- public string Echo(string text) => text;
-
- [JsonRpcMethod("substract")]
- public int Substract(int minuend, int subtrahend) => minuend - subtrahend;
-
- [JsonRpcMethod("substractasync")]
- public async Task<int> SubstractAsync(int minuend, int subtrahend) => await Task.FromResult(minuend - subtrahend);
-
- [JsonRpcMethod("writelog")]
- public void Log(string logEntry) { }
-
- [JsonRpcMethod("fail")]
- public void Failure() => throw new InvalidOperationException("the error");
-
- [JsonRpcMethod("format")]
- public async Task FormatHardDriveAsync(string unit, CancellationTokenSource cts)
- {
- await Task.FromResult((JsonRpcResponse)null);
- }
- }
public class RpcTests
{
@@ -41,13 +15,12 @@ namespace WalletWasabi.Tests
[MemberData(nameof(RequestResponse))]
public async Task ParsingRequestTestsAsync(string request, string expectedResponse)
{
- var handler = new JsonRpcRequestHandler(new TesteableRpcService());
+ var handler = new JsonRpcRequestHandler<TesteableRpcService>(new TesteableRpcService());
- var response = await handler.HandleAsync(request, new CancellationTokenSource());
+ var response = await handler.HandleAsync(request, CancellationToken.None);
Assert.Equal(expectedResponse, response);
}
-
public static IEnumerable<object[]> RequestResponse =>
new[]
{
@@ -101,7 +74,6 @@ namespace WalletWasabi.Tests
Ok("7", 19)}
}.Select(x => x.Skip(1).ToArray());
-
private static string Request(string id, string methodName, params object[] parameters)
{
return ToJson(new

ADD
WalletWasabi.Tests/TesteableRpcService.cs
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using WalletWasabi.Gui.Rpc;
+
+namespace WalletWasabi.Tests
+{
+ class TesteableRpcService
+ {
+ public void UnpublishedProcedure() { }
+
+ [JsonRpcMethod("say")]
+ public string Echo(string text) => text;
+
+ [JsonRpcMethod("substract")]
+ public int Substract(int minuend, int subtrahend) => minuend - subtrahend;
+
+ [JsonRpcMethod("substractasync")]
+ public async Task<int> SubstractAsync(int minuend, int subtrahend) => await Task.FromResult(minuend - subtrahend);
+
+ [JsonRpcMethod("writelog")]
+ public void Log(string logEntry) { }
+
+ [JsonRpcMethod("fail")]
+ public void Failure() => throw new InvalidOperationException("the error");
+
+ [JsonRpcMethod("format")]
+ public async Task FormatHardDriveAsync(string unit, CancellationToken ct)
+ {
+ await Task.FromResult((JsonRpcResponse)null);
+ }
+ }
+}
\ No newline at end of file

One class, one file