Make RegTestFixture use its own data directory
MODIFY
WalletWasabi.Backend/Global.cs
WalletWasabi.Backend/Global.cs
@@ -33,9 +33,12 @@ namespace WalletWasabi.Backend
public CcjRoundConfig RoundConfig { get; private set; }
- public Global()
+ public Global(string dataDir)
+ {
+ DataDir = dataDir ?? EnvironmentHelpers.GetDataDir(Path.Combine("WalletWasabi", "Backend"));
+ }
+ public Global() : this(null)
{
- DataDir = EnvironmentHelpers.GetDataDir(Path.Combine("WalletWasabi", "Backend"));
}
public async Task InitializeAsync(Config config, CcjRoundConfig roundConfig, RPCClient rpc)

MODIFY
WalletWasabi.Backend/Startup.cs
WalletWasabi.Backend/Startup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NBitcoin;
@@ -19,6 +20,12 @@ namespace WalletWasabi.Backend
{
public class Startup
{
+ public IConfiguration Configuration { get; }
+
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
@@ -49,7 +56,7 @@ namespace WalletWasabi.Backend
services.AddLogging(Logging => Logging.AddFilter((s, level) => level >= Microsoft.Extensions.Logging.LogLevel.Warning));
services.AddSingleton<IExchangeRateProvider>(new ExchangeRateProvider());
- services.AddSingleton<Global>(new Global());
+ services.AddSingleton<Global>(new Global(Configuration["datadir"]));
services.AddStartupTask<InitConfigStartupTask>();
services.AddResponseCompression();
}

MODIFY
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
using NBitcoin;
using NBitcoin.RPC;
using System;
+using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading;
@@ -35,7 +37,12 @@ namespace WalletWasabi.Tests.XunitConfiguration
Server = rpc.Address.AbsoluteUri,
UserPassword = BackendRegTestNode.Creds
}.ToString();
- var global = new Backend.Global();
+
+ IoHelpers.DeleteRecursivelyWithMagicDustAsync(nameof(RegTestFixture)).GetAwaiter().GetResult();
+ Thread.Sleep(100);
+ Directory.CreateDirectory(nameof(RegTestFixture));
+ Thread.Sleep(100);
+ var global = new Backend.Global(nameof(RegTestFixture));
var config = new Config(BackendNodeBuilder.Network, connectionString, IPAddress.Loopback.ToString(), IPAddress.Loopback.ToString(), BackendRegTestNode.Endpoint.Address.ToString(), Network.Main.DefaultPort, Network.TestNet.DefaultPort, BackendRegTestNode.Endpoint.Port);
var configFilePath = Path.Combine(global.DataDir, "Config.json");
config.SetFilePath(configFilePath);
@@ -46,9 +53,13 @@ namespace WalletWasabi.Tests.XunitConfiguration
roundConfig.SetFilePath(roundConfigFilePath);
roundConfig.ToFileAsync().GetAwaiter().GetResult();
+ var conf = new ConfigurationBuilder()
+ .AddInMemoryCollection(new[] { new KeyValuePair<string,string>("datadir", nameof(RegTestFixture)) })
+ .Build();
BackendEndPoint = $"http://localhost:{new Random().Next(37130, 38000)}/";
BackendHost = WebHost.CreateDefaultBuilder()
.UseStartup<Startup>()
+ .UseConfiguration(conf)
.UseWebRoot("../../../../WalletWasabi.Backend/wwwroot")
.UseUrls(BackendEndPoint)
.Build();

Make RegTestFixture use its own data directory