Remove redundant nesting.
MODIFY
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
@@ -21,16 +21,11 @@ namespace WalletWasabi.Tests.NodeBuilding
{
public static class NodeBuilder
{
- private static int Last { get; set; }
-
public static async Task<CoreNode> CreateNodeAsync([CallerMemberName]string caller = null)
{
- var root = Path.Combine(Global.Instance.DataDir, caller);
- var child = Path.Combine(root, Last.ToString());
- Last++;
- try
- {
- var cfgPath = Path.Combine(child, "data", "bitcoin.conf");
+ var dataDir = Path.Combine(Global.Instance.DataDir, caller);
+
+ var cfgPath = Path.Combine(dataDir, "bitcoin.conf");
if (File.Exists(cfgPath))
{
var config = await NodeConfigParameters.LoadAsync(cfgPath);
@@ -44,7 +39,7 @@ namespace WalletWasabi.Tests.NodeBuilding
var rpc = new RPCClient(credentials, new Uri("http://127.0.0.1:" + rpcPort + "/"), Network.RegTest);
await rpc.StopAsync();
- var pidFile = Path.Combine(child, "data", "regtest", pidFileName);
+ var pidFile = Path.Combine(dataDir, "regtest", pidFileName);
if (File.Exists(pidFile))
{
var pid = await File.ReadAllTextAsync(pidFile);
@@ -66,14 +61,9 @@ namespace WalletWasabi.Tests.NodeBuilding
{
}
}
- await IoHelpers.DeleteRecursivelyWithMagicDustAsync(child);
- await IoHelpers.DeleteRecursivelyWithMagicDustAsync(root);
- IoHelpers.EnsureDirectoryExists(root);
- }
- catch (DirectoryNotFoundException)
- {
- }
- var node = new CoreNode(child);
+
+ await IoHelpers.DeleteRecursivelyWithMagicDustAsync(dataDir);
+ var node = new CoreNode(dataDir);
await node.StartAsync();
return node;
}

Remove redundant nesting.