Adjust syntax
ADD
WalletWasabi.Tests/Helpers/TestNodeBuilder.cs
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using WalletWasabi.BitcoinCore;
+using WalletWasabi.Helpers;
+
+namespace WalletWasabi.Tests.Helpers
+{
+ public class TestNodeBuilder
+ {
+ public static async Task<CoreNode> CreateAsync([CallerFilePath]string callerFilePath = null, [CallerMemberName]string callerMemberName = null, string additionalFolder = null)
+ => await TestNodeBuilder.CreateAsync(Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.ExtractFileName(callerFilePath), callerMemberName, additionalFolder ?? ""));
+ }
+}

MODIFY
WalletWasabi.Tests/IntegrationTests/P2pTests.cs
WalletWasabi.Tests/IntegrationTests/P2pTests.cs
@@ -20,7 +20,6 @@ using WalletWasabi.Mempool;
using WalletWasabi.Models;
using WalletWasabi.Services;
using WalletWasabi.Stores;
-using WalletWasabi.Tests.NodeBuilding;
using WalletWasabi.Tests.XunitConfiguration;
using WalletWasabi.Transactions;
using Xunit;

MODIFY
WalletWasabi.Tests/UnitTests/BitcoinCore/NodeBuildingTests.cs
WalletWasabi.Tests/UnitTests/BitcoinCore/NodeBuildingTests.cs
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.BitcoinCore;
+using WalletWasabi.Tests.Helpers;
using Xunit;
namespace WalletWasabi.Tests.UnitTests.BitcoinCore
@@ -14,7 +15,7 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
[Fact]
public async Task CanBuildCoreNodeAsync()
{
- var coreNode = await CoreNode.CreateAsync();
+ var coreNode = await TestNodeBuilder.CreateAsync();
try
{
Assert.False(coreNode.Process.HasExited);
@@ -28,7 +29,7 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
[Fact]
public async Task NodesDifferAsync()
{
- var coreNodes = await Task.WhenAll(CoreNode.CreateAsync(additionalFolder: "0"), CoreNode.CreateAsync(additionalFolder: "1"));
+ var coreNodes = await Task.WhenAll(TestNodeBuilder.CreateAsync(additionalFolder: "0"), TestNodeBuilder.CreateAsync(additionalFolder: "1"));
CoreNode node1 = coreNodes[0];
CoreNode node2 = coreNodes[1];
try
@@ -47,7 +48,7 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
[Fact]
public async Task RpcWorksAsync()
{
- var coreNode = await CoreNode.CreateAsync();
+ var coreNode = await TestNodeBuilder.CreateAsync();
try
{
var blockCount = await coreNode.RpcClient.GetBlockCountAsync();
@@ -62,7 +63,7 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
[Fact]
public async Task P2pWorksAsync()
{
- var coreNode = await CoreNode.CreateAsync();
+ var coreNode = await TestNodeBuilder.CreateAsync();
using var node = await coreNode.CreateP2pNodeAsync();
try
{
@@ -82,7 +83,7 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
{
using var cts = new CancellationTokenSource(7000);
Version version = await CoreNode.GetVersionAsync(cts.Token);
- Assert.Equal(Helpers.Constants.BitcoinCoreVersion, version);
+ Assert.Equal(WalletWasabi.Helpers.Constants.BitcoinCoreVersion, version);
}
}
}

MODIFY
WalletWasabi.Tests/UnitTests/BitcoinCore/P2pBasedTests.cs
WalletWasabi.Tests/UnitTests/BitcoinCore/P2pBasedTests.cs
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using WalletWasabi.BitcoinCore;
using WalletWasabi.Helpers;
using WalletWasabi.Stores;
+using WalletWasabi.Tests.Helpers;
using WalletWasabi.Transactions;
using Xunit;
@@ -18,7 +19,7 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
[Fact]
public async Task MempoolNotifiesAsync()
{
- var coreNode = await CoreNode.CreateAsync();
+ var coreNode = await TestNodeBuilder.CreateAsync();
using var node = await coreNode.CreateP2pNodeAsync();
try
{

MODIFY
WalletWasabi.Tests/UnitTests/BitcoinCore/RpcBasedTests.cs
WalletWasabi.Tests/UnitTests/BitcoinCore/RpcBasedTests.cs
@@ -10,6 +10,7 @@ using WalletWasabi.KeyManagement;
using WalletWasabi.Models;
using WalletWasabi.Services;
using WalletWasabi.Stores;
+using WalletWasabi.Tests.Helpers;
using Xunit;
namespace WalletWasabi.Tests.UnitTests.BitcoinCore
@@ -19,12 +20,12 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
[Fact]
public async Task AllFeeEstimateAsync()
{
- var coreNode = await CoreNode.CreateAsync();
+ var coreNode = await TestNodeBuilder.CreateAsync();
try
{
var rpc = coreNode.RpcClient;
var estimations = await rpc.EstimateAllFeeAsync(EstimateSmartFeeMode.Conservative, simulateIfRegTest: true, tolerateBitcoinCoreBrainfuck: true);
- Assert.Equal(Helpers.Constants.OneDayConfirmationTarget, estimations.Estimations.Count);
+ Assert.Equal(WalletWasabi.Helpers.Constants.OneDayConfirmationTarget, estimations.Estimations.Count);
Assert.True(estimations.Estimations.First().Key < estimations.Estimations.Last().Key);
Assert.True(estimations.Estimations.First().Value > estimations.Estimations.Last().Value);
Assert.Equal(EstimateSmartFeeMode.Conservative, estimations.Type);

MODIFY
WalletWasabi.Tests/UnitTests/Hwi/DefaultResponseTests.cs
WalletWasabi.Tests/UnitTests/Hwi/DefaultResponseTests.cs
@@ -46,7 +46,7 @@ namespace WalletWasabi.Tests.UnitTests.Hwi
{
using var cts = new CancellationTokenSource(ReasonableRequestTimeout);
Version version = await client.GetVersionAsync(cts.Token);
- Assert.Equal(Helpers.Constants.HwiVersion, version);
+ Assert.Equal(WalletWasabi.Helpers.Constants.HwiVersion, version);
}
[Theory]

MODIFY
WalletWasabi.Tests/UnitTests/NBitcoinTests.cs
WalletWasabi.Tests/UnitTests/NBitcoinTests.cs
@@ -11,12 +11,12 @@ namespace WalletWasabi.Tests.UnitTests
[Fact]
public void DefaultPortsMatch()
{
- Assert.Equal(Helpers.Constants.DefaultMainNetBitcoinCoreRpcPort, Network.Main.RPCPort);
- Assert.Equal(Helpers.Constants.DefaultTestNetBitcoinCoreRpcPort, Network.TestNet.RPCPort);
- Assert.Equal(Helpers.Constants.DefaultRegTestBitcoinCoreRpcPort, Network.RegTest.RPCPort);
- Assert.Equal(Helpers.Constants.DefaultMainNetBitcoinP2pPort, Network.Main.DefaultPort);
- Assert.Equal(Helpers.Constants.DefaultTestNetBitcoinP2pPort, Network.TestNet.DefaultPort);
- Assert.Equal(Helpers.Constants.DefaultRegTestBitcoinP2pPort, Network.RegTest.DefaultPort);
+ Assert.Equal(WalletWasabi.Helpers.Constants.DefaultMainNetBitcoinCoreRpcPort, Network.Main.RPCPort);
+ Assert.Equal(WalletWasabi.Helpers.Constants.DefaultTestNetBitcoinCoreRpcPort, Network.TestNet.RPCPort);
+ Assert.Equal(WalletWasabi.Helpers.Constants.DefaultRegTestBitcoinCoreRpcPort, Network.RegTest.RPCPort);
+ Assert.Equal(WalletWasabi.Helpers.Constants.DefaultMainNetBitcoinP2pPort, Network.Main.DefaultPort);
+ Assert.Equal(WalletWasabi.Helpers.Constants.DefaultTestNetBitcoinP2pPort, Network.TestNet.DefaultPort);
+ Assert.Equal(WalletWasabi.Helpers.Constants.DefaultRegTestBitcoinP2pPort, Network.RegTest.DefaultPort);
}
}
}

MODIFY
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
@@ -14,6 +14,7 @@ using WalletWasabi.BitcoinCore;
using WalletWasabi.CoinJoin.Coordinator.Rounds;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
+using WalletWasabi.Tests.Helpers;
namespace WalletWasabi.Tests.XunitConfiguration
{
@@ -26,7 +27,7 @@ namespace WalletWasabi.Tests.XunitConfiguration
public RegTestFixture()
{
- BackendRegTestNode = CoreNode.CreateAsync(callerMemberName: "RegTests").GetAwaiter().GetResult();
+ BackendRegTestNode = TestNodeBuilder.CreateAsync(callerMemberName: "RegTests").GetAwaiter().GetResult();
var testnetBackendDir = EnvironmentHelpers.GetDataDir(Path.Combine("WalletWasabi", "Tests", "Backend"));
IoHelpers.DeleteRecursivelyWithMagicDustAsync(testnetBackendDir).GetAwaiter().GetResult();

MODIFY
WalletWasabi/BitcoinCore/BitcoindProcessBridge.cs
WalletWasabi/BitcoinCore/BitcoindProcessBridge.cs
@@ -15,7 +15,7 @@ namespace WalletWasabi.BitcoinCore
{
public class BitcoindProcessBridge : ProcessBridge
{
- public BitcoindProcessBridge() : base(EnvironmentHelpers.GetBinaryPath("bitcoind"))
+ public BitcoindProcessBridge() : base(MicroserviceHelpers.GetBinaryPath("bitcoind"))
{
}
}

MODIFY
WalletWasabi/BitcoinCore/CoreNode.cs
WalletWasabi/BitcoinCore/CoreNode.cs
@@ -26,10 +26,10 @@ namespace WalletWasabi.BitcoinCore
public Process Process { get; private set; }
public string DataDir { get; private set; }
- public static async Task<CoreNode> CreateAsync([CallerFilePath]string callerFilePath = null, [CallerMemberName]string callerMemberName = null, string additionalFolder = null)
+ public static async Task<CoreNode> CreateAsync(string dataDir)
{
var coreNode = new CoreNode();
- coreNode.DataDir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.ExtractFileName(callerFilePath), callerMemberName, additionalFolder ?? "");
+ coreNode.DataDir = Guard.NotNullOrEmptyOrWhitespace(nameof(dataDir), dataDir);
var configPath = Path.Combine(coreNode.DataDir, "bitcoin.conf");
if (File.Exists(configPath))

Adjust syntax