Try to stop the daemon and kill it as last resource
MODIFY
WalletWasabi.Tests/NodeBuilding/CoreNode.cs
WalletWasabi.Tests/NodeBuilding/CoreNode.cs
@@ -146,10 +146,31 @@ namespace WalletWasabi.Tests.NodeBuilding
private readonly object _l = new object();
- public void Kill(bool cleanFolder = true)
+ public async Task KillAsync(bool cleanFolder = true)
{
lock (_l)
{
+ try
+ {
+ CreateRpcClient().SendCommand("stop");
+ }
+ catch(Exception)
+ {}
+
+ if(File.Exists(Config))
+ {
+ var config = NodeConfigParameters.Load(Config);
+ var pidFileName = config["regtest.pid"];
+
+ var pidFile = Path.Combine(DataDir, "regtest", pidFileName);
+ var pid = File.ReadAllText(pidFile);
+ var count = 20;
+ while(File.Exists(pidFile) && count-- > 0)
+ {
+ Task.Delay(50);
+ }
+ Task.Delay(3000);
+ }
if (_process != null && !_process.HasExited)
{
_process.Kill();

MODIFY
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
@@ -135,32 +135,19 @@ namespace WalletWasabi.Tests.NodeBuilding
var cfgPath = Path.Combine(child, "data", "bitcoin.conf");
if(File.Exists(cfgPath))
{
- string rpcPort = "";
- string rpcUser = "";
- string rpcPassword = "";
- foreach(var line in File.ReadAllLines(cfgPath))
- {
- var parts = line.Split('=');
- if(parts[0].StartsWith("regtest.rpcport"))
- {
- rpcPort = parts[1].Trim();
- }
- else if(parts[0].StartsWith("regtest.rpcuser"))
- {
- rpcUser = parts[1].Trim();
- }
- else if(parts[0].StartsWith("regtest.rpcpassword"))
- {
- rpcPassword = parts[1].Trim();
- }
- }
+ var config = NodeConfigParameters.Load(cfgPath);
+ var rpcPort = config["regtest.rpcport"];
+ var rpcUser = config["regtest.rpcuser"];
+ var rpcPassword = config["regtest.rpcpassword"];
+ var pidFileName = config["regtest.pid"];
+ var credentials = new NetworkCredential(rpcUser, rpcPassword);
+
try
{
- var credentials = new NetworkCredential(rpcUser, rpcPassword);
var rpc = new RPCClient(credentials, new Uri("http://127.0.0.1:" + rpcPort + "/"), Network.RegTest);
rpc.SendCommand("stop");
- var pidFile = Path.Combine(child, "data", "regtest", "bitcoind.pid");
+ var pidFile = Path.Combine(child, "data", "regtest", pidFileName);
var pid = File.ReadAllText(pidFile);
var count = 20;
while(File.Exists(pidFile) && count-- > 0)
@@ -179,7 +166,6 @@ namespace WalletWasabi.Tests.NodeBuilding
}
catch(Exception)
{
-
}
}
await IoHelpers.DeleteRecursivelyWithMagicDustAsync(child);
@@ -210,7 +196,7 @@ namespace WalletWasabi.Tests.NodeBuilding
{
foreach (CoreNode node in Nodes)
{
- node.Kill();
+ node.KillAsync().GetAwaiter().GetResult();
}
foreach (IDisposable disposable in _disposables)

MODIFY
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
@@ -54,7 +54,7 @@ namespace WalletWasabi.Tests.XunitConfiguration
BackendHost?.StopAsync();
BackendHost?.Dispose();
- BackendRegTestNode?.Kill(cleanFolder: true);
+ BackendRegTestNode?.KillAsync(cleanFolder: true).GetAwaiter().GetResult();
BackendNodeBuilder?.Dispose();
}
}

MODIFY
WalletWasabi/Services/WasabiSynchronizer.cs
WalletWasabi/Services/WasabiSynchronizer.cs
@@ -278,6 +278,8 @@ namespace WalletWasabi.Services
SynchronizeResponse response;
try
{
+ if (!IsRunning) return;
+
response = await WasabiClient.GetSynchronizeAsync(BestKnownFilter.BlockHash, maxFiltersToSyncAtInitialization, estimateMode, Cancel.Token).WithAwaitCancellationAsync(Cancel.Token, 300);
// NOT GenSocksServErr
BackendStatus = BackendStatus.Connected;

Try to stop the daemon and kill it as last resource