Remove SharedFixture from Tests and use Global instead
MODIFY
WalletWasabi.Tests/CryptoTests.cs
WalletWasabi.Tests/CryptoTests.cs
@@ -12,15 +12,8 @@ using static NBitcoin.Crypto.SchnorrBlinding;
namespace WalletWasabi.Tests
{
- public class CryptoTests : IClassFixture<SharedFixture>
+ public class CryptoTests
{
- private SharedFixture SharedFixture { get; }
-
- public CryptoTests(SharedFixture fixture)
- {
- SharedFixture = fixture;
- }
-
[Fact]
public void CipherTests()
{

MODIFY
WalletWasabi.Tests/ExternalApiTests.cs
WalletWasabi.Tests/ExternalApiTests.cs
@@ -16,15 +16,8 @@ using Xunit;
namespace WalletWasabi.Tests
{
- public class ExternalApiTests : IClassFixture<SharedFixture>
+ public class ExternalApiTests
{
- public SharedFixture SharedFixture { get; }
-
- public ExternalApiTests(SharedFixture sharedFixture)
- {
- SharedFixture = sharedFixture;
- }
-
[Theory]
[InlineData("test")]
[InlineData("main")]

MODIFY
WalletWasabi.Tests/KeyManagementTests.cs
WalletWasabi.Tests/KeyManagementTests.cs
@@ -9,15 +9,8 @@ using Xunit;
namespace WalletWasabi.Tests
{
- public class KeyManagementTests : IClassFixture<SharedFixture>
+ public class KeyManagementTests
{
- private SharedFixture SharedFixture { get; }
-
- public KeyManagementTests(SharedFixture sharedFixture)
- {
- SharedFixture = sharedFixture;
- }
-
[Fact]
public void CanCreateNew()
{
@@ -90,7 +83,7 @@ namespace WalletWasabi.Tests
{
string password = "password";
- var filePath = Path.Combine(SharedFixture.DataDir, nameof(CanSerialize), "Wallet.json");
+ var filePath = Path.Combine(Global.DataDir, nameof(CanSerialize), "Wallet.json");
DeleteFileAndDirectoryIfExists(filePath);
Logger.TurnOff();

MODIFY
WalletWasabi.Tests/LiveServerTests.cs
WalletWasabi.Tests/LiveServerTests.cs
@@ -14,18 +14,15 @@ using Xunit;
namespace WalletWasabi.Tests
{
[Collection("LiveServerTests collection")]
- public class LiveServerTests : IClassFixture<SharedFixture>
+ public class LiveServerTests
{
- private SharedFixture SharedFixture { get; }
-
private LiveServerTestsFixture LiveServerTestsFixture { get; }
- public LiveServerTests(SharedFixture sharedFixture, LiveServerTestsFixture liveServerTestsFixture)
+ public LiveServerTests(LiveServerTestsFixture liveServerTestsFixture)
{
- SharedFixture = sharedFixture;
LiveServerTestsFixture = liveServerTestsFixture;
- var torManager = new TorProcessManager(SharedFixture.TorSocks5Endpoint, SharedFixture.TorLogsFile);
+ var torManager = new TorProcessManager(Global.TorSocks5Endpoint, Global.TorLogsFile);
torManager.Start(ensureRunning: true, dataDir: Path.GetFullPath(AppContext.BaseDirectory));
Task.Delay(3000).GetAwaiter().GetResult();
}
@@ -37,7 +34,7 @@ namespace WalletWasabi.Tests
[InlineData(NetworkType.Testnet)]
public async Task GetFeesAsync(NetworkType networkType)
{
- using (var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType], SharedFixture.TorSocks5Endpoint))
+ using (var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType], Global.TorSocks5Endpoint))
{
var feeEstimationPairs = await client.GetFeesAsync(1000);
@@ -50,7 +47,7 @@ namespace WalletWasabi.Tests
[InlineData(NetworkType.Testnet)]
public async Task GetFiltersAsync(NetworkType networkType)
{
- using (var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType], SharedFixture.TorSocks5Endpoint))
+ using (var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType], Global.TorSocks5Endpoint))
{
var filterModel = WasabiSynchronizer.GetStartingFilter(Network.GetNetwork(networkType.ToString()));
@@ -66,7 +63,7 @@ namespace WalletWasabi.Tests
[InlineData(NetworkType.Testnet)]
public async Task GetAllRoundStatesAsync(NetworkType networkType)
{
- using (var client = new SatoshiClient(LiveServerTestsFixture.UriMappings[networkType], SharedFixture.TorSocks5Endpoint))
+ using (var client = new SatoshiClient(LiveServerTestsFixture.UriMappings[networkType], Global.TorSocks5Endpoint))
{
var states = await client.GetAllRoundStatesAsync();
Assert.True(states.NotNullAndNotEmpty());
@@ -83,7 +80,7 @@ namespace WalletWasabi.Tests
[InlineData(NetworkType.Testnet)]
public async Task GetExchangeRateAsync(NetworkType networkType) // xunit wtf: If this function is called GetExchangeRatesAsync, it'll stuck on 1 CPU VMs (Manjuro, Fedora)
{
- using (var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType], SharedFixture.TorSocks5Endpoint))
+ using (var client = new WasabiClient(LiveServerTestsFixture.UriMappings[networkType], Global.TorSocks5Endpoint))
{
var exchangeRates = await client.GetExchangeRatesAsync();

MODIFY
WalletWasabi.Tests/ModelTests.cs
WalletWasabi.Tests/ModelTests.cs
@@ -20,15 +20,8 @@ using Xunit;
namespace WalletWasabi.Tests
{
- public class ModelTests : IClassFixture<SharedFixture>
+ public class ModelTests
{
- private SharedFixture SharedFixture { get; }
-
- public ModelTests(SharedFixture sharedFixture)
- {
- SharedFixture = sharedFixture;
- }
-
[Fact]
public void SmartTransactionEquality()
{

MODIFY
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
@@ -25,7 +25,7 @@ namespace WalletWasabi.Tests.NodeBuilding
{
using (await Lock.LockAsync())
{
- WorkingDirectory = Path.Combine(SharedFixture.DataDir, caller);
+ WorkingDirectory = Path.Combine(Global.DataDir, caller);
version = version ?? "0.17.1";
var path = await EnsureDownloadedAsync(version);
return new NodeBuilder(WorkingDirectory, path);
@@ -56,7 +56,7 @@ namespace WalletWasabi.Tests.NodeBuilding
string bitcoindFolderName = $"bitcoin-{version}";
// Remove old bitcoind folders.
- IEnumerable<string> existingBitcoindFolderPaths = Directory.EnumerateDirectories(SharedFixture.DataDir, "bitcoin-*", SearchOption.TopDirectoryOnly);
+ IEnumerable<string> existingBitcoindFolderPaths = Directory.EnumerateDirectories(Global.DataDir, "bitcoin-*", SearchOption.TopDirectoryOnly);
foreach (string dirPath in existingBitcoindFolderPaths)
{
string dirName = Path.GetFileName(dirPath);
@@ -68,13 +68,13 @@ namespace WalletWasabi.Tests.NodeBuilding
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- bitcoind = Path.Combine(SharedFixture.DataDir, bitcoindFolderName, "bin", "bitcoind.exe");
+ bitcoind = Path.Combine(Global.DataDir, bitcoindFolderName, "bin", "bitcoind.exe");
if (File.Exists(bitcoind))
{
return bitcoind;
}
- zip = Path.Combine(SharedFixture.DataDir, $"bitcoin-{version}-win32.zip");
+ zip = Path.Combine(Global.DataDir, $"bitcoin-{version}-win32.zip");
string url = string.Format("https://bitcoincore.org/bin/bitcoin-core-{0}/" + Path.GetFileName(zip), version);
using (var client = new HttpClient())
{
@@ -86,15 +86,15 @@ namespace WalletWasabi.Tests.NodeBuilding
}
else
{
- bitcoind = Path.Combine(SharedFixture.DataDir, bitcoindFolderName, "bin", "bitcoind");
+ bitcoind = Path.Combine(Global.DataDir, bitcoindFolderName, "bin", "bitcoind");
if (File.Exists(bitcoind))
{
return bitcoind;
}
zip = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ?
- Path.Combine(SharedFixture.DataDir, $"bitcoin-{version}-x86_64-linux-gnu.tar.gz")
- : Path.Combine(SharedFixture.DataDir, $"bitcoin-{version}-osx64.tar.gz");
+ Path.Combine(Global.DataDir, $"bitcoin-{version}-x86_64-linux-gnu.tar.gz")
+ : Path.Combine(Global.DataDir, $"bitcoin-{version}-osx64.tar.gz");
string url = string.Format("https://bitcoincore.org/bin/bitcoin-core-{0}/" + Path.GetFileName(zip), version);
using (var client = new HttpClient())
@@ -103,7 +103,7 @@ namespace WalletWasabi.Tests.NodeBuilding
var data = await client.GetByteArrayAsync(url);
await File.WriteAllBytesAsync(zip, data);
- using (var process = Process.Start("tar", "-zxvf " + zip + " -C " + SharedFixture.DataDir))
+ using (var process = Process.Start("tar", "-zxvf " + zip + " -C " + Global.DataDir))
{
process.WaitForExit();
}

MODIFY
WalletWasabi.Tests/P2pTests.cs
WalletWasabi.Tests/P2pTests.cs
@@ -22,15 +22,8 @@ using Xunit;
namespace WalletWasabi.Tests
{
- public class P2pTests : IClassFixture<SharedFixture>
+ public class P2pTests
{
- private SharedFixture SharedFixture { get; }
-
- public P2pTests(SharedFixture sharedFixture)
- {
- SharedFixture = sharedFixture;
- }
-
[Theory]
[InlineData("test")]
[InlineData("main")]
@@ -55,9 +48,9 @@ namespace WalletWasabi.Tests
throw new NotSupportedException(network.ToString());
}
- var addressManagerFolderPath = Path.Combine(SharedFixture.DataDir, "AddressManager");
+ var addressManagerFolderPath = Path.Combine(Global.DataDir, "AddressManager");
var addressManagerFilePath = Path.Combine(addressManagerFolderPath, $"AddressManager{network}.dat");
- var blocksFolderPath = Path.Combine(SharedFixture.DataDir, "Blocks", network.ToString());
+ var blocksFolderPath = Path.Combine(Global.DataDir, "Blocks", network.ToString());
var connectionParameters = new NodeConnectionParameters();
AddressManager addressManager = null;
try
@@ -85,14 +78,14 @@ namespace WalletWasabi.Tests
var nodes = new NodesGroup(network, connectionParameters, requirements: Helpers.Constants.NodeRequirements);
KeyManager keyManager = KeyManager.CreateNew(out _, "password");
- WasabiSynchronizer syncer = new WasabiSynchronizer(network, Path.Combine(SharedFixture.DataDir, nameof(TestServicesAsync), "IndexDownloader.txt"), new Uri("http://localhost:12345"), SharedFixture.TorSocks5Endpoint);
+ WasabiSynchronizer syncer = new WasabiSynchronizer(network, Path.Combine(Global.DataDir, nameof(TestServicesAsync), "IndexDownloader.txt"), new Uri("http://localhost:12345"), Global.TorSocks5Endpoint);
WalletService walletService = new WalletService(
keyManager,
syncer,
- new CcjClient(syncer, network, keyManager, new Uri("http://localhost:12345"), SharedFixture.TorSocks5Endpoint),
+ new CcjClient(syncer, network, keyManager, new Uri("http://localhost:12345"), Global.TorSocks5Endpoint),
memPoolService,
nodes,
- SharedFixture.DataDir,
+ Global.DataDir,
new ServiceConfiguration(50, 2, 21, 50, new IPEndPoint(IPAddress.Loopback, network.DefaultPort)));
Assert.True(Directory.Exists(blocksFolderPath));

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -37,21 +37,18 @@ using static NBitcoin.Crypto.SchnorrBlinding;
namespace WalletWasabi.Tests
{
[Collection("RegTest collection")]
- public class RegTests : IClassFixture<SharedFixture>
+ public class RegTests
{
- private SharedFixture SharedFixture { get; }
-
private RegTestFixture RegTestFixture { get; }
- public RegTests(SharedFixture sharedFixture, RegTestFixture regTestFixture)
+ public RegTests(RegTestFixture regTestFixture)
{
- SharedFixture = sharedFixture;
RegTestFixture = regTestFixture;
}
private async Task AssertFiltersInitializedAsync()
{
- var firstHash = await Global.RpcClient.GetBlockHashAsync(0);
+ var firstHash = await Backend.Global.RpcClient.GetBlockHashAsync(0);
while (true)
{
using (var client = new WasabiClient(new Uri(RegTestFixture.BackendEndPoint), null))
@@ -77,13 +74,13 @@ namespace WalletWasabi.Tests
await AssertFiltersInitializedAsync(); // Make sure fitlers are created on the server side.
if (numberOfBlocksToGenerate != 0)
{
- await Global.RpcClient.GenerateAsync(numberOfBlocksToGenerate); // Make sure everything is confirmed.
+ await Backend.Global.RpcClient.GenerateAsync(numberOfBlocksToGenerate); // Make sure everything is confirmed.
}
- Global.Coordinator.UtxoReferee.Clear();
+ Backend.Global.Coordinator.UtxoReferee.Clear();
- var network = Global.RpcClient.Network;
+ var network = Backend.Global.RpcClient.Network;
var serviceConfiguration = new ServiceConfiguration(2, 2, 21, 50, RegTestFixture.BackendRegTestNode.Endpoint);
- return ("password", Global.RpcClient, network, Global.Coordinator, serviceConfiguration);
+ return ("password", Backend.Global.RpcClient, network, Backend.Global.Coordinator, serviceConfiguration);
}
#region BackendTests
@@ -159,11 +156,11 @@ namespace WalletWasabi.Tests
{
(string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration) = await InitializeTestEnvironmentAsync(1);
- var indexBuilderServiceDir = Path.Combine(SharedFixture.DataDir, nameof(IndexBuilderService));
+ var indexBuilderServiceDir = Path.Combine(Global.DataDir, nameof(IndexBuilderService));
var indexFilePath = Path.Combine(indexBuilderServiceDir, $"Index{rpc.Network}.dat");
var utxoSetFilePath = Path.Combine(indexBuilderServiceDir, $"UtxoSet{rpc.Network}.dat");
- var indexBuilderService = new IndexBuilderService(rpc, Global.TrustedNodeNotifyingBehavior, indexFilePath, utxoSetFilePath);
+ var indexBuilderService = new IndexBuilderService(rpc, Backend.Global.TrustedNodeNotifyingBehavior, indexFilePath, utxoSetFilePath);
try
{
indexBuilderService.Synchronize();
@@ -302,7 +299,7 @@ namespace WalletWasabi.Tests
{
(string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration) = await InitializeTestEnvironmentAsync(1);
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(FilterDownloaderTestAsync), $"Index{rpc.Network}.dat");
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(FilterDownloaderTestAsync), $"Index{rpc.Network}.dat");
using (var synchronizer = new WasabiSynchronizer(rpc.Network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null))
{
@@ -374,7 +371,7 @@ namespace WalletWasabi.Tests
_reorgTestAsync_ReorgCount = 0;
var node = RegTestFixture.BackendRegTestNode;
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(ReorgTestAsync), $"Index{rpc.Network}.dat");
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(ReorgTestAsync), $"Index{rpc.Network}.dat");
using (var synchronizer = new WasabiSynchronizer(rpc.Network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null))
{
@@ -394,7 +391,7 @@ namespace WalletWasabi.Tests
var tipBlock = await rpc.GetBlockHeaderAsync(tip);
Assert.Contains(tipBlock.HashPrevBlock.ToString(), indexLines.TakeLast(2).First());
- var utxoPath = Global.IndexBuilderService.Bech32UtxoSetFilePath;
+ var utxoPath = Backend.Global.IndexBuilderService.Bech32UtxoSetFilePath;
var utxoLines = await File.ReadAllTextAsync(utxoPath);
Assert.Contains(tx1.ToString(), utxoLines);
Assert.Contains(tx2.ToString(), utxoLines);
@@ -460,7 +457,7 @@ namespace WalletWasabi.Tests
private async Task WaitForIndexesToSyncAsync(TimeSpan timeout, WasabiSynchronizer synchronizer)
{
- var bestHash = await Global.RpcClient.GetBestBlockHashAsync();
+ var bestHash = await Backend.Global.RpcClient.GetBestBlockHashAsync();
var times = 0;
while (synchronizer.GetFilters().SingleOrDefault(x => x.BlockHash == bestHash) is null)
@@ -493,7 +490,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(Backend.Global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -503,7 +500,7 @@ namespace WalletWasabi.Tests
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(WalletTestsAsync), $"Index{rpc.Network}.dat");
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(WalletTestsAsync), $"Index{rpc.Network}.dat");
var synchronizer = new WasabiSynchronizer(rpc.Network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null);
// 4. Create key manager service.
@@ -513,7 +510,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 5. Create wallet service.
- var workDir = Path.Combine(SharedFixture.DataDir, nameof(WalletTestsAsync));
+ var workDir = Path.Combine(Global.DataDir, nameof(WalletTestsAsync));
var wallet = new WalletService(keyManager, synchronizer, chaumianClient, memPoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -723,7 +720,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(Backend.Global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -732,7 +729,7 @@ namespace WalletWasabi.Tests
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Index{rpc.Network}.dat");
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Index{rpc.Network}.dat");
var synchronizer = new WasabiSynchronizer(rpc.Network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null);
// 4. Create key manager service.
@@ -742,7 +739,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync));
+ var workDir = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync));
var wallet = new WalletService(keyManager, synchronizer, chaumianClient, memPoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1167,7 +1164,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(Backend.Global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -1176,7 +1173,7 @@ namespace WalletWasabi.Tests
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Index{rpc.Network}.dat");
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Index{rpc.Network}.dat");
var synchronizer = new WasabiSynchronizer(rpc.Network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null);
// 4. Create key manager service.
@@ -1186,7 +1183,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync));
+ var workDir = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync));
var wallet = new WalletService(keyManager, synchronizer, chaumianClient, memPoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1331,7 +1328,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(Backend.Global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -1340,7 +1337,7 @@ namespace WalletWasabi.Tests
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Index{rpc.Network}.dat");
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync), $"Index{rpc.Network}.dat");
var synchronizer = new WasabiSynchronizer(rpc.Network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null);
// 4. Create key manager service.
@@ -1350,7 +1347,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync));
+ var workDir = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync));
var wallet = new WalletService(keyManager, synchronizer, chaumianClient, memPoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1496,7 +1493,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(Backend.Global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -1505,7 +1502,7 @@ namespace WalletWasabi.Tests
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync),
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync),
$"Index{rpc.Network}.dat");
var synchronizer =
new WasabiSynchronizer(rpc.Network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null);
@@ -1517,7 +1514,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync));
+ var workDir = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync));
var wallet = new WalletService(keyManager, synchronizer, chaumianClient, memPoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1658,7 +1655,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(Backend.Global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -1667,7 +1664,7 @@ namespace WalletWasabi.Tests
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
// 3. Create wasabi synchronizer service.
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync),
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync),
$"Index{rpc.Network}.dat");
var synchronizer =
new WasabiSynchronizer(rpc.Network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null);
@@ -1679,7 +1676,7 @@ namespace WalletWasabi.Tests
var chaumianClient = new CcjClient(synchronizer, rpc.Network, keyManager, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(SharedFixture.DataDir, nameof(SendTestsFromHiddenWalletAsync));
+ var workDir = Path.Combine(Global.DataDir, nameof(SendTestsFromHiddenWalletAsync));
var wallet = new WalletService(keyManager, synchronizer, chaumianClient, memPoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
@@ -1770,7 +1767,7 @@ namespace WalletWasabi.Tests
var offchainTxId = network.Consensus.ConsensusFactory.CreateTransaction().GetHash();
var mempoolTxId = rpc.SendToAddress(new Key().PubKey.GetSegwitAddress(network), Money.Coins(1));
- var folder = Path.Combine(SharedFixture.DataDir, nameof(CcjCoordinatorCtorTestsAsync));
+ var folder = Path.Combine(Global.DataDir, nameof(CcjCoordinatorCtorTestsAsync));
await IoHelpers.DeleteRecursivelyWithMagicDustAsync(folder);
Directory.CreateDirectory(folder);
var cjfile = Path.Combine(folder, $"CoinJoins{network}.txt");
@@ -1780,7 +1777,7 @@ namespace WalletWasabi.Tests
mempoolTxId.ToString()
});
- using (var coordinatorToTest = new CcjCoordinator(network, Global.TrustedNodeNotifyingBehavior, folder, rpc, coordinator.RoundConfig))
+ using (var coordinatorToTest = new CcjCoordinator(network, Backend.Global.TrustedNodeNotifyingBehavior, folder, rpc, coordinator.RoundConfig))
{
var txIds = await File.ReadAllLinesAsync(cjfile);
@@ -1795,7 +1792,7 @@ namespace WalletWasabi.Tests
"This line is invalid (the file is corrupted)",
offchainTxId.ToString(),
});
- var coordinatorToTest2 = new CcjCoordinator(network, Global.TrustedNodeNotifyingBehavior, folder, rpc, coordinatorToTest.RoundConfig);
+ var coordinatorToTest2 = new CcjCoordinator(network, Backend.Global.TrustedNodeNotifyingBehavior, folder, rpc, coordinatorToTest.RoundConfig);
coordinatorToTest2?.Dispose();
txIds = await File.ReadAllLinesAsync(cjfile);
Assert.Single(txIds);
@@ -1821,7 +1818,7 @@ namespace WalletWasabi.Tests
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
Uri baseUri = new Uri(RegTestFixture.BackendEndPoint);
- using (var torClient = new TorHttpClient(baseUri, SharedFixture.TorSocks5Endpoint))
+ using (var torClient = new TorHttpClient(baseUri, Global.TorSocks5Endpoint))
using (var satoshiClient = new SatoshiClient(baseUri, null))
{
#region PostInputsGetStates
@@ -2341,7 +2338,7 @@ namespace WalletWasabi.Tests
coordinator.AbortAllRoundsInInputRegistration(nameof(RegTests), "");
Uri baseUri = new Uri(RegTestFixture.BackendEndPoint);
- using (var torClient = new TorHttpClient(baseUri, SharedFixture.TorSocks5Endpoint))
+ using (var torClient = new TorHttpClient(baseUri, Global.TorSocks5Endpoint))
using (var satoshiClient = new SatoshiClient(baseUri, null))
{
var round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
@@ -2980,7 +2977,7 @@ namespace WalletWasabi.Tests
{
(string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration) = await InitializeTestEnvironmentAsync(1);
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(CcjFeeTestsAsync), $"Index{network}.dat");
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(CcjFeeTestsAsync), $"Index{network}.dat");
var synchronizer = new WasabiSynchronizer(network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null);
synchronizer.Start(requestInterval: TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), 10000); // Start wasabi synchronizer service.
@@ -3105,7 +3102,7 @@ namespace WalletWasabi.Tests
{
(string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration) = await InitializeTestEnvironmentAsync(1);
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(CcjClientTestsAsync), $"Index{network}.dat");
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(CcjClientTestsAsync), $"Index{network}.dat");
var synchronizer = new WasabiSynchronizer(network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null);
synchronizer.Start(requestInterval: TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), 10000); // Start wasabi synchronizer service.
@@ -3272,10 +3269,10 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(Backend.Global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
- var nodes2 = new NodesGroup(Global.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes2 = new NodesGroup(Backend.Global.Config.Network, requirements: Constants.NodeRequirements);
nodes2.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -3288,10 +3285,10 @@ namespace WalletWasabi.Tests
node2.Behaviors.Add(new MemPoolBehavior(memPoolService2));
// 3. Create wasabi synchronizer service.
- var indexFilePath = Path.Combine(SharedFixture.DataDir, nameof(CoinJoinMultipleRoundTestsAsync), $"Index{network}.dat");
+ var indexFilePath = Path.Combine(Global.DataDir, nameof(CoinJoinMultipleRoundTestsAsync), $"Index{network}.dat");
var synchronizer = new WasabiSynchronizer(network, indexFilePath, new Uri(RegTestFixture.BackendEndPoint), null);
- var indexFilePath2 = Path.Combine(SharedFixture.DataDir, nameof(CoinJoinMultipleRoundTestsAsync), $"Index{network}2.dat");
+ var indexFilePath2 = Path.Combine(Global.DataDir, nameof(CoinJoinMultipleRoundTestsAsync), $"Index{network}2.dat");
var synchronizer2 = new WasabiSynchronizer(network, indexFilePath2, new Uri(RegTestFixture.BackendEndPoint), null);
// 4. Create key manager service.
@@ -3305,11 +3302,11 @@ namespace WalletWasabi.Tests
var chaumianClient2 = new CcjClient(synchronizer, network, keyManager2, new Uri(RegTestFixture.BackendEndPoint), null);
// 6. Create wallet service.
- var workDir = Path.Combine(SharedFixture.DataDir, nameof(CoinJoinMultipleRoundTestsAsync));
+ var workDir = Path.Combine(Global.DataDir, nameof(CoinJoinMultipleRoundTestsAsync));
var wallet = new WalletService(keyManager, synchronizer, chaumianClient, memPoolService, nodes, workDir, serviceConfiguration);
wallet.NewFilterProcessed += Wallet_NewFilterProcessed;
- var workDir2 = Path.Combine(SharedFixture.DataDir, $"{nameof(CoinJoinMultipleRoundTestsAsync)}2");
+ var workDir2 = Path.Combine(Global.DataDir, $"{nameof(CoinJoinMultipleRoundTestsAsync)}2");
var wallet2 = new WalletService(keyManager2, synchronizer2, chaumianClient2, memPoolService2, nodes2, workDir2, serviceConfiguration);
// Get some money, make it confirm.

MODIFY
WalletWasabi.Tests/TorTests.cs
WalletWasabi.Tests/TorTests.cs
@@ -12,14 +12,11 @@ using Xunit;
namespace WalletWasabi.Tests
{
// Tor must be running
- public class TorTests : IClassFixture<SharedFixture>
+ public class TorTests
{
- private SharedFixture SharedFixture { get; }
-
- public TorTests(SharedFixture sharedFixture)
+ public TorTests()
{
- SharedFixture = sharedFixture;
- var torManager = new TorProcessManager(SharedFixture.TorSocks5Endpoint, SharedFixture.TorLogsFile);
+ var torManager = new TorProcessManager(Global.TorSocks5Endpoint, Global.TorLogsFile);
torManager.Start(ensureRunning: true, dataDir: Path.GetFullPath(AppContext.BaseDirectory));
Task.Delay(3000).GetAwaiter().GetResult();
}
@@ -27,7 +24,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CanDoRequestManyDifferentAsync()
{
- using (var client = new TorHttpClient(new Uri("http://api.qbit.ninja"), SharedFixture.TorSocks5Endpoint))
+ using (var client = new TorHttpClient(new Uri("http://api.qbit.ninja"), Global.TorSocks5Endpoint))
{
await QBitTestAsync(client, 10, alterRequests: true);
}
@@ -36,7 +33,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CanRequestChunkEncodedAsync()
{
- using (var client = new TorHttpClient(new Uri("https://jigsaw.w3.org/"), SharedFixture.TorSocks5Endpoint))
+ using (var client = new TorHttpClient(new Uri("https://jigsaw.w3.org/"), Global.TorSocks5Endpoint))
{
var response = await client.SendAsync(HttpMethod.Get, "/HTTP/ChunkedScript");
var content = await response.Content.ReadAsStringAsync();
@@ -58,7 +55,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CanDoBasicPostHttpsRequestAsync()
{
- using (var client = new TorHttpClient(new Uri("https://api.smartbit.com.au"), SharedFixture.TorSocks5Endpoint))
+ using (var client = new TorHttpClient(new Uri("https://api.smartbit.com.au"), Global.TorSocks5Endpoint))
{
HttpContent content = new StringContent("{\"hex\": \"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d03a58605204d696e656420627920416e74506f6f6c20757361311f10b53620558903d80272a70c0000724c0600ffffffff010f9e5096000000001976a9142ef12bd2ac1416406d0e132e5bc8d0b02df3861b88ac00000000\"}");
@@ -85,7 +82,7 @@ namespace WalletWasabi.Tests
}
// 2. Get Tor IP
- using (var client = new TorHttpClient(new Uri(requestUri), SharedFixture.TorSocks5Endpoint))
+ using (var client = new TorHttpClient(new Uri(requestUri), Global.TorSocks5Endpoint))
{
var content = await (await client.SendAsync(HttpMethod.Get, "")).Content.ReadAsStringAsync();
var gotIp = IPAddress.TryParse(content.Replace("\n", ""), out torIp);
@@ -98,7 +95,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CanDoHttpsAsync()
{
- using (var client = new TorHttpClient(new Uri("https://slack.com"), SharedFixture.TorSocks5Endpoint))
+ using (var client = new TorHttpClient(new Uri("https://slack.com"), Global.TorSocks5Endpoint))
{
var content =
await (await client.SendAsync(HttpMethod.Get, "api/api.test")).Content.ReadAsStringAsync();
@@ -110,7 +107,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CanDoIpAddressAsync()
{
- using (var client = new TorHttpClient(new Uri("http://172.217.6.142"), SharedFixture.TorSocks5Endpoint))
+ using (var client = new TorHttpClient(new Uri("http://172.217.6.142"), Global.TorSocks5Endpoint))
{
var content = await (await client.SendAsync(HttpMethod.Get, "")).Content.ReadAsStringAsync();
@@ -121,7 +118,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CanRequestInRowAsync()
{
- using (var client = new TorHttpClient(new Uri("http://api.qbit.ninja"), SharedFixture.TorSocks5Endpoint))
+ using (var client = new TorHttpClient(new Uri("http://api.qbit.ninja"), Global.TorSocks5Endpoint))
{
await (await client.SendAsync(HttpMethod.Get, "/transactions/38d4cfeb57d6685753b7a3b3534c3cb576c34ca7344cd4582f9613ebf0c2b02a?format=json&headeronly=true")).Content.ReadAsStringAsync();
await (await client.SendAsync(HttpMethod.Get, "/balances/15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe?unspentonly=true")).Content.ReadAsStringAsync();
@@ -132,7 +129,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CanRequestOnionV2Async()
{
- using (var client = new TorHttpClient(new Uri("http://expyuzz4wqqyqhjn.onion/"), SharedFixture.TorSocks5Endpoint))
+ using (var client = new TorHttpClient(new Uri("http://expyuzz4wqqyqhjn.onion/"), Global.TorSocks5Endpoint))
{
HttpResponseMessage response = await client.SendAsync(HttpMethod.Get, "");
var content = await response.Content.ReadAsStringAsync();
@@ -146,7 +143,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CanRequestOnionV3Async()
{
- using (var client = new TorHttpClient(new Uri("http://dds6qkxpwdeubwucdiaord2xgbbeyds25rbsgr73tbfpqpt4a6vjwsyd.onion"), SharedFixture.TorSocks5Endpoint))
+ using (var client = new TorHttpClient(new Uri("http://dds6qkxpwdeubwucdiaord2xgbbeyds25rbsgr73tbfpqpt4a6vjwsyd.onion"), Global.TorSocks5Endpoint))
{
HttpResponseMessage response = await client.SendAsync(HttpMethod.Get, "");
var content = await response.Content.ReadAsStringAsync();
@@ -160,9 +157,9 @@ namespace WalletWasabi.Tests
[Fact]
public async Task DoesntIsolateStreamsAsync()
{
- using (var c1 = new TorHttpClient(new Uri("http://api.ipify.org"), SharedFixture.TorSocks5Endpoint))
- using (var c2 = new TorHttpClient(new Uri("http://api.ipify.org"), SharedFixture.TorSocks5Endpoint))
- using (var c3 = new TorHttpClient(new Uri("http://api.ipify.org"), SharedFixture.TorSocks5Endpoint))
+ using (var c1 = new TorHttpClient(new Uri("http://api.ipify.org"), Global.TorSocks5Endpoint))
+ using (var c2 = new TorHttpClient(new Uri("http://api.ipify.org"), Global.TorSocks5Endpoint))
+ using (var c3 = new TorHttpClient(new Uri("http://api.ipify.org"), Global.TorSocks5Endpoint))
{
var t1 = c1.SendAsync(HttpMethod.Get, "");
var t2 = c2.SendAsync(HttpMethod.Get, "");
@@ -182,9 +179,9 @@ namespace WalletWasabi.Tests
[Fact]
public async Task IsolatesStreamsAsync()
{
- using (var c1 = new TorHttpClient(new Uri("http://api.ipify.org"), SharedFixture.TorSocks5Endpoint, isolateStream: true))
- using (var c2 = new TorHttpClient(new Uri("http://api.ipify.org"), SharedFixture.TorSocks5Endpoint, isolateStream: true))
- using (var c3 = new TorHttpClient(new Uri("http://api.ipify.org"), SharedFixture.TorSocks5Endpoint, isolateStream: true))
+ using (var c1 = new TorHttpClient(new Uri("http://api.ipify.org"), Global.TorSocks5Endpoint, isolateStream: true))
+ using (var c2 = new TorHttpClient(new Uri("http://api.ipify.org"), Global.TorSocks5Endpoint, isolateStream: true))
+ using (var c3 = new TorHttpClient(new Uri("http://api.ipify.org"), Global.TorSocks5Endpoint, isolateStream: true))
{
var t1 = c1.SendAsync(HttpMethod.Get, "");
var t2 = c2.SendAsync(HttpMethod.Get, "");
@@ -219,7 +216,7 @@ namespace WalletWasabi.Tests
var task = client.SendAsync(HttpMethod.Get, relativetUri);
if (alterRequests)
{
- using (var ipClient = new TorHttpClient(new Uri("https://api.ipify.org/"), SharedFixture.TorSocks5Endpoint))
+ using (var ipClient = new TorHttpClient(new Uri("https://api.ipify.org/"), Global.TorSocks5Endpoint))
{
var task2 = ipClient.SendAsync(HttpMethod.Get, "/");
tasks.Add(task2);

MODIFY
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
@@ -35,7 +35,7 @@ namespace WalletWasabi.Tests.XunitConfiguration
var roundConfig = new CcjRoundConfig(Money.Coins(0.1m), 144, 0.1m, 100, 120, 60, 60, 60, 1, 24, true, 11);
- Global.InitializeAsync(config, roundConfig, rpc).GetAwaiter().GetResult();
+ Backend.Global.InitializeAsync(config, roundConfig, rpc).GetAwaiter().GetResult();
BackendEndPoint = $"http://localhost:{new Random().Next(37130, 38000)}/";
BackendHost = WebHost.CreateDefaultBuilder()
@@ -44,7 +44,7 @@ namespace WalletWasabi.Tests.XunitConfiguration
.Build();
var hostInitializationTask = BackendHost.RunAsync();
- Logger.LogInfo<SharedFixture>($"Started Backend webhost: {BackendEndPoint}");
+ Logger.LogInfo($"Started Backend webhost: {BackendEndPoint}", nameof(Global));
var delayTask = Task.Delay(3000);
Task.WaitAny(delayTask, hostInitializationTask); // Wait for server to initialize (Without this OSX CI will fail)

Remove SharedFixture from Tests and use Global instead