Finish removing ProcessBridge.
MODIFY
WalletWasabi.Tests/UnitTests/Hwi/DefaultResponseTests.cs
WalletWasabi.Tests/UnitTests/Hwi/DefaultResponseTests.cs
@@ -118,6 +118,18 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
await Task.WhenAny(tasks);
}
+ [Fact]
+ public async void HwiProcessHelpTestAsync()
+ {
+ using var cts = new CancellationTokenSource();
+
+ var processBridge = new HwiProcessBridge(MicroserviceHelpers.GetBinaryPath("hwi"), new ProcessInvoker());
+ (string response, int exitCode) p = await processBridge.SendCommandAsync("--help", openConsole: false, cts.Token);
+
+ Assert.Equal(0, p.exitCode);
+ Assert.Equal("{\"error\": \"Help text requested\", \"code\": -17}" + Environment.NewLine, p.response);
+ }
+
[Fact]
public async Task HwiProcessBridgeTestAsync()
{

DELETE
WalletWasabi.Tests/UnitTests/Microservices/ProcessBridgeTest.cs
-using System;
-using System.Threading;
-using WalletWasabi.Microservices;
-using Xunit;
-
-namespace WalletWasabi.Tests.UnitTests.Microservices
-{
- public class ProcessBridgeTest
- {
- [Fact]
- public async void SendCommandSuccessAsync()
- {
- using var cts = new CancellationTokenSource();
-
- var processBridge = new ProcessBridge(MicroserviceHelpers.GetBinaryPath("hwi"));
- (string response, int exitCode) p = await processBridge.SendCommandAsync("--help", openConsole: false, cts.Token);
-
- Assert.Equal(0, p.exitCode);
- Assert.Equal("{\"error\": \"Help text requested\", \"code\": -17}" + Environment.NewLine, p.response);
- }
- }
-}

MODIFY
WalletWasabi/BitcoinCore/Processes/BitcoindRpcProcessBridge.cs
WalletWasabi/BitcoinCore/Processes/BitcoindRpcProcessBridge.cs
@@ -14,11 +14,11 @@ using WalletWasabi.Microservices;
namespace WalletWasabi.BitcoinCore.Processes
{
- public class BitcoindRpcProcessBridge : ProcessBridge
+ public class BitcoindRpcProcessBridge
{
public const string PidFileName = "bitcoin.pid";
- public BitcoindRpcProcessBridge(IRPCClient rpc, string dataDir, bool printToConsole) : base(MicroserviceHelpers.GetBinaryPath("bitcoind"))
+ public BitcoindRpcProcessBridge(IRPCClient rpc, string dataDir, bool printToConsole)
{
RpcClient = Guard.NotNull(nameof(rpc), rpc);
Network = RpcClient.Network;

DELETE
WalletWasabi/Microservices/IProcessBridge.cs
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace WalletWasabi.Microservices
-{
- public interface IProcessBridge
- {
- Task<(string response, int exitCode)> SendCommandAsync(string arguments, bool openConsole, CancellationToken cancel);
- }
-}

DELETE
WalletWasabi/Microservices/ProcessBridge.cs
-using System;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-using WalletWasabi.Helpers;
-
-namespace WalletWasabi.Microservices
-{
- public class ProcessBridge : IProcessBridge
- {
- public ProcessBridge(string processPath)
- {
- ProcessPath = Guard.NotNullOrEmptyOrWhitespace(nameof(processPath), processPath);
-
- if (!File.Exists(ProcessPath))
- {
- throw new FileNotFoundException($"{Path.GetFileNameWithoutExtension(ProcessPath)} is not found.", ProcessPath);
- }
- }
-
- public string ProcessPath { get; }
-
- public async Task<(string response, int exitCode)> SendCommandAsync(string arguments, bool openConsole, CancellationToken cancel)
- {
- // "using" makes sure the process exits at the end of this method.
- using var process = new ProcessAsync(ProcessBuilder.BuildProcessInstance(ProcessPath, arguments, openConsole));
-
- process.Start();
-
- await process.WaitForExitAsync(cancel);
-
- string responseString = openConsole ? string.Empty : await process.StandardOutput.ReadToEndAsync().ConfigureAwait(false);
- return (responseString, exitCode: process.ExitCode);
- }
- }
-}

Finish removing ProcessBridge.