A bunch of stylistic changes
MODIFY
WalletWasabi.Backend/Config.cs
WalletWasabi.Backend/Config.cs
@@ -118,7 +118,7 @@ namespace WalletWasabi.Backend
MainNetBitcoinCorePort = Guard.NotNull(nameof(mainNetBitcoinCorePort), mainNetBitcoinCorePort);
TestNetBitcoinCorePort = Guard.NotNull(nameof(testNetBitcoinCorePort), testNetBitcoinCorePort);
RegTestBitcoinCorePort = Guard.NotNull(nameof(regTestBitcoinCorePort), regTestBitcoinCorePort);
- ListenRoundConfigFileChanges = listenRoundConfigFileChanges.HasValue ? listenRoundConfigFileChanges.Value : true;
+ ListenRoundConfigFileChanges = listenRoundConfigFileChanges ?? true;
}
/// <inheritdoc />

MODIFY
WalletWasabi.Backend/Controllers/BlockchainController.cs
WalletWasabi.Backend/Controllers/BlockchainController.cs
@@ -292,8 +292,7 @@ namespace WalletWasabi.Backend.Controllers
return NoContent();
}
- var response = new FiltersResponse
- {
+ var response = new FiltersResponse {
BestHeight = bestHeight,
Filters = filters
};

MODIFY
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
@@ -34,17 +34,16 @@ namespace WalletWasabi.Backend.Controllers
[Route("api/v" + Constants.BackendMajorVersion + "/btc/[controller]")]
public class ChaumianCoinJoinController : Controller
{
- public ChaumianCoinJoinController(Global global)
- {
- Global = global;
- }
public Global Global { get; }
private RPCClient RpcClient => Global.RpcClient;
-
private Network Network => Global.Config.Network;
-
private CcjCoordinator Coordinator => Global.Coordinator;
+ public ChaumianCoinJoinController(Global global)
+ {
+ Global = global;
+ }
+
/// <summary>
/// Satoshi gets various status information.
/// </summary>

MODIFY
WalletWasabi.Backend/Extensions.cs
WalletWasabi.Backend/Extensions.cs
@@ -13,9 +13,10 @@ namespace WalletWasabi.Backend
public static IServiceCollection AddStartupTask<T>(this IServiceCollection services)
where T : class, IStartupTask
=> services.AddTransient<IStartupTask, T>();
+
public static async Task RunWithTasksAsync(this IWebHost webHost, CancellationToken cancellationToken = default)
{
- await Task.WhenAll(webHost.Services.GetServices<IStartupTask>().Select(t => t.ExecuteAsync(cancellationToken)).ToArray());
+ await Task.WhenAll(webHost.Services.GetServices<IStartupTask>().Select(t => t.ExecuteAsync(cancellationToken)));
await webHost.RunAsync(cancellationToken);
}
}

MODIFY
WalletWasabi.Backend/InitConfigStartupTask.cs
WalletWasabi.Backend/InitConfigStartupTask.cs
@@ -15,32 +15,30 @@ namespace WalletWasabi.Backend
{
public class InitConfigStartupTask : IStartupTask
{
- private readonly Global _global;
- private readonly HostingEnvironment _hostingEnvironment;
- private UnversionedWebBuilder _unversionedWebBuilder;
-
private static List<string> Last5CoinJoins { get; set; } = new List<string>();
private static object UpdateUnversionedLock { get; } = new object();
+ public UnversionedWebBuilder UnversionedWebBuilder { get; }
+ public Global Global { get; }
public InitConfigStartupTask(Global global, IHostingEnvironment hostingEnvironment)
{
- _global = global;
- _hostingEnvironment = (HostingEnvironment)hostingEnvironment;
+ Global = global;
+ UnversionedWebBuilder = new UnversionedWebBuilder(global, ((HostingEnvironment)hostingEnvironment).WebRootPath);
}
public async Task ExecuteAsync(CancellationToken cancellationToken)
{
- Logger.InitializeDefaults(Path.Combine(_global.DataDir, "Logs.txt"));
+ Logger.InitializeDefaults(Path.Combine(Global.DataDir, "Logs.txt"));
Logger.LogStarting("Wasabi Backend");
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
- var configFilePath = Path.Combine(_global.DataDir, "Config.json");
+ var configFilePath = Path.Combine(Global.DataDir, "Config.json");
var config = new Config(configFilePath);
await config.LoadOrCreateDefaultFileAsync();
Logger.LogInfo<Config>("Config is successfully initialized.");
- var roundConfigFilePath = Path.Combine(_global.DataDir, "CcjRoundConfig.json");
+ var roundConfigFilePath = Path.Combine(Global.DataDir, "CcjRoundConfig.json");
var roundConfig = new CcjRoundConfig(roundConfigFilePath);
await roundConfig.LoadOrCreateDefaultFileAsync();
Logger.LogInfo<CcjRoundConfig>("RoundConfig is successfully initialized.");
@@ -49,23 +47,22 @@ namespace WalletWasabi.Backend
credentials: RPCCredentialString.Parse(config.BitcoinRpcConnectionString),
network: config.Network);
- await _global.InitializeAsync(config, roundConfig, rpc);
+ await Global.InitializeAsync(config, roundConfig, rpc);
try
{
- _unversionedWebBuilder = new UnversionedWebBuilder(_hostingEnvironment.WebRootPath);
- Directory.CreateDirectory(_unversionedWebBuilder.UnversionedFolder);
- _unversionedWebBuilder.CreateDownloadTextWithVersionHtml();
- _unversionedWebBuilder.CloneAndUpdateOnionIndexHtml();
+ Directory.CreateDirectory(UnversionedWebBuilder.UnversionedFolder);
+ UnversionedWebBuilder.CreateDownloadTextWithVersionHtml();
+ UnversionedWebBuilder.CloneAndUpdateOnionIndexHtml();
- if (File.Exists(_global.Coordinator.CoinJoinsFilePath))
+ if (File.Exists(Global.Coordinator.CoinJoinsFilePath))
{
- string[] allLines = File.ReadAllLines(_global.Coordinator.CoinJoinsFilePath);
+ string[] allLines = File.ReadAllLines(Global.Coordinator.CoinJoinsFilePath);
Last5CoinJoins = allLines.TakeLast(5).Reverse().ToList();
- _unversionedWebBuilder.UpdateCoinJoinsHtml(_global, Last5CoinJoins);
+ UnversionedWebBuilder.UpdateCoinJoinsHtml(Last5CoinJoins);
}
- _global.Coordinator.CoinJoinBroadcasted += Coordinator_CoinJoinBroadcasted;
+ Global.Coordinator.CoinJoinBroadcasted += Coordinator_CoinJoinBroadcasted;
}
catch (Exception ex)
{
@@ -94,7 +91,7 @@ namespace WalletWasabi.Backend
Last5CoinJoins.RemoveLast();
}
Last5CoinJoins.Insert(0, tx.GetHash().ToString());
- _unversionedWebBuilder.UpdateCoinJoinsHtml(_global, Last5CoinJoins);
+ UnversionedWebBuilder.UpdateCoinJoinsHtml(Last5CoinJoins);
}
}
catch (Exception ex)

MODIFY
WalletWasabi.Backend/Startup.cs
WalletWasabi.Backend/Startup.cs
@@ -57,7 +57,7 @@ namespace WalletWasabi.Backend
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
#pragma warning disable IDE0060 // Remove unused parameter
- public void Configure(IApplicationBuilder app, IHostingEnvironment env, Global backendGlobal)
+ public void Configure(IApplicationBuilder app, IHostingEnvironment env, Global global)
#pragma warning restore IDE0060 // Remove unused parameter
{
app.UseStaticFiles();
@@ -81,34 +81,34 @@ namespace WalletWasabi.Backend
app.UseMvc();
var applicationLifetime = app.ApplicationServices.GetRequiredService<IApplicationLifetime>();
- applicationLifetime.ApplicationStopping.Register(() => OnShutdown(backendGlobal)); // Don't register async, that won't hold up the shutdown
+ applicationLifetime.ApplicationStopping.Register(() => OnShutdown(global)); // Don't register async, that won't hold up the shutdown
}
- private void OnShutdown(Global backendGlobal)
+ private void OnShutdown(Global global)
{
- CleanupAsync(backendGlobal).GetAwaiter().GetResult(); // This is needed, if async function is registered then it won't wait until it finishes
+ CleanupAsync(global).GetAwaiter().GetResult(); // This is needed, if async function is registered then it won't wait until it finishes
}
- private async Task CleanupAsync(Global backendGlobal)
+ private async Task CleanupAsync(Global global)
{
- backendGlobal.Coordinator?.Dispose();
+ global.Coordinator?.Dispose();
Logger.LogInfo<Startup>("Coordinator is disposed.");
- if (backendGlobal.IndexBuilderService != null)
+ if (global.IndexBuilderService != null)
{
- await backendGlobal.IndexBuilderService.StopAsync();
+ await global.IndexBuilderService.StopAsync();
Logger.LogInfo<Startup>("IndexBuilderService is disposed.");
}
- if (backendGlobal.RoundConfigWatcher != null)
+ if (global.RoundConfigWatcher != null)
{
- await backendGlobal.RoundConfigWatcher.StopAsync();
+ await global.RoundConfigWatcher.StopAsync();
Logger.LogInfo<Startup>("RoundConfigWatcher is disposed.");
}
- if (backendGlobal.LocalNode != null)
+ if (global.LocalNode != null)
{
- backendGlobal.DisconnectDisposeNullLocalNode();
+ global.DisconnectDisposeNullLocalNode();
Logger.LogInfo<Startup>("LocalNode is disposed.");
}

MODIFY
WalletWasabi.Backend/UnversionedWebBuilder.cs
WalletWasabi.Backend/UnversionedWebBuilder.cs
@@ -8,16 +8,17 @@ namespace WalletWasabi.Backend
{
public class UnversionedWebBuilder
{
- public UnversionedWebBuilder(string rootFolder)
+ public Global Global { get; }
+ public string RootFolder { get; }
+ public string UnversionedFolder { get; }
+
+ public UnversionedWebBuilder(Global global, string rootFolder)
{
+ Global = global;
RootFolder = rootFolder;
UnversionedFolder = Path.GetFullPath(Path.Combine(RootFolder, "unversioned"));
}
- public string RootFolder { get; }
-
- public string UnversionedFolder { get; }
-
public string CreateFilePath(string fileName) => Path.Combine(UnversionedFolder, fileName);
public static string HtmlStartLine { get; } = "<link href=\"../css/bootstrap.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n<link href=\"../css/OpenSansCondensed300700.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n";
@@ -44,7 +45,7 @@ namespace WalletWasabi.Backend
File.WriteAllText(onionPath, content);
}
- public void UpdateCoinJoinsHtml(Global backendGlobal, IEnumerable<string> coinJoins)
+ public void UpdateCoinJoinsHtml(IEnumerable<string> coinJoins)
{
var filePath = CreateFilePath("coinjoins-table.html");
var onionFilePath = CreateFilePath("onion-coinjoins-table.html");
@@ -54,7 +55,7 @@ namespace WalletWasabi.Backend
var endContent = "</ul>";
string blockstreamPath;
string onionBlockstreamPath;
- if (backendGlobal.Config.Network == Network.TestNet)
+ if (Global.Config.Network == Network.TestNet)
{
blockstreamPath = "https://blockstream.info/testnet/tx/";
onionBlockstreamPath = "http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/testnet/tx/";

MODIFY
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
WalletWasabi.Tests/NodeBuilding/NodeBuilder.cs
@@ -130,6 +130,7 @@ namespace WalletWasabi.Tests.NodeBuilding
public string BitcoinD { get; }
public List<CoreNode> Nodes { get; } = new List<CoreNode>();
public NodeConfigParameters ConfigParameters { get; } = new NodeConfigParameters();
+ public Network Network => NBitcoin.Network.RegTest;
public async Task<CoreNode> CreateNodeAsync(bool start = false)
{
@@ -215,7 +216,6 @@ namespace WalletWasabi.Tests.NodeBuilding
}
private List<IDisposable> Disposables { get; } = new List<IDisposable>();
- public Network Network => NBitcoin.Network.RegTest;
internal void AddDisposable(IDisposable group)
{

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -72,7 +72,7 @@ namespace WalletWasabi.Tests
}
}
- private async Task<(string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal)> InitializeTestEnvironmentAsync(int numberOfBlocksToGenerate, [CallerMemberName] string caller = null)
+ private async Task<(string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global)> InitializeTestEnvironmentAsync(int numberOfBlocksToGenerate, [CallerMemberName] string caller = null)
{
var global = RegTestFixture.Global;
await AssertFiltersInitializedAsync(global); // Make sure fitlers are created on the server side.
@@ -123,7 +123,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task BroadcastReplayTxAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
var utxos = await rpc.ListUnspentAsync();
var utxo = utxos[0];
@@ -143,7 +143,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task BroadcastInvalidTxAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
var content = new StringContent($"''", Encoding.UTF8, "application/json");
@@ -161,13 +161,13 @@ namespace WalletWasabi.Tests
[Fact]
public async Task FilterBuilderTestAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
var indexBuilderServiceDir = Path.Combine(Global.Instance.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, backendGlobal.TrustedNodeNotifyingBehavior, indexFilePath, utxoSetFilePath);
+ var indexBuilderService = new IndexBuilderService(rpc, global.TrustedNodeNotifyingBehavior, indexFilePath, utxoSetFilePath);
try
{
indexBuilderService.Synchronize();
@@ -230,7 +230,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task AllFeeEstimateRpcAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
var estimations = await rpc.EstimateAllFeeAsync(EstimateSmartFeeMode.Conservative, simulateIfRegTest: true, tolerateBitcoinCoreBrainfuck: true);
Assert.Equal(Constants.OneDayConfirmationTarget, estimations.Estimations.Count);
@@ -256,7 +256,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task MempoolAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
var mempoolService = new MempoolService();
Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
@@ -304,7 +304,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task FilterDownloaderTestAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
var synchronizer = new WasabiSynchronizer(rpc.Network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
try
@@ -369,7 +369,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task ReorgTestAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
var keyManager = KeyManager.CreateNew(out _, password);
@@ -398,14 +398,14 @@ namespace WalletWasabi.Tests
bitcoinStore.IndexStore.Reorged += ReorgTestAsync_Downloader_Reorged;
// Test initial synchronization.
- await WaitForIndexesToSyncAsync(backendGlobal, TimeSpan.FromSeconds(90), bitcoinStore);
+ await WaitForIndexesToSyncAsync(global, TimeSpan.FromSeconds(90), bitcoinStore);
var tip = await rpc.GetBestBlockHashAsync();
Assert.Equal(tip, bitcoinStore.HashChain.TipHash);
var tipBlock = await rpc.GetBlockHeaderAsync(tip);
Assert.Equal(tipBlock.HashPrevBlock, bitcoinStore.HashChain.GetChain().Select(x => x.hash).ToArray()[bitcoinStore.HashChain.HashCount - 2]);
- var utxoPath = backendGlobal.IndexBuilderService.Bech32UtxoSetFilePath;
+ var utxoPath = global.IndexBuilderService.Bech32UtxoSetFilePath;
var utxoLines = await File.ReadAllTextAsync(utxoPath);
Assert.Contains(tx1.ToString(), utxoLines);
Assert.Contains(tx2.ToString(), utxoLines);
@@ -420,7 +420,7 @@ namespace WalletWasabi.Tests
var tx1bumpRes = await rpc.BumpFeeAsync(tx1); // RBF it
await rpc.GenerateAsync(5);
- await WaitForIndexesToSyncAsync(backendGlobal, TimeSpan.FromSeconds(90), bitcoinStore);
+ await WaitForIndexesToSyncAsync(global, TimeSpan.FromSeconds(90), bitcoinStore);
utxoLines = await File.ReadAllTextAsync(utxoPath);
Assert.Contains(tx1bumpRes.TransactionId.ToString(), utxoLines); // assert the tx1bump is the correct tx
@@ -488,9 +488,9 @@ namespace WalletWasabi.Tests
}
}
- private async Task WaitForIndexesToSyncAsync(Backend.Global backendGlobal, TimeSpan timeout, BitcoinStore bitcoinStore)
+ private async Task WaitForIndexesToSyncAsync(Backend.Global global, TimeSpan timeout, BitcoinStore bitcoinStore)
{
- var bestHash = await backendGlobal.RpcClient.GetBestBlockHashAsync();
+ var bestHash = await global.RpcClient.GetBestBlockHashAsync();
var times = 0;
while (bitcoinStore.HashChain.TipHash != bestHash)
@@ -519,11 +519,11 @@ namespace WalletWasabi.Tests
[Fact]
public async Task WalletTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(backendGlobal.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -751,11 +751,11 @@ namespace WalletWasabi.Tests
[Fact]
public async Task SendTestsFromHiddenWalletAsync() // These tests are taken from HiddenWallet, they were tests on the testnet.
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(backendGlobal.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -1197,11 +1197,11 @@ namespace WalletWasabi.Tests
[Fact]
public async Task BuildTransactionValidationsTestAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(backendGlobal.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -1363,11 +1363,11 @@ namespace WalletWasabi.Tests
[Fact]
public async Task BuildTransactionReorgsTestAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(backendGlobal.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -1530,11 +1530,11 @@ namespace WalletWasabi.Tests
[Fact]
public async Task SpendUnconfirmedTxTestAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(backendGlobal.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -1699,11 +1699,11 @@ namespace WalletWasabi.Tests
[Fact]
public async Task ReplaceByFeeTxTestAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(backendGlobal.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.
@@ -1808,7 +1808,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CcjCoordinatorCtorTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
Logger.TurnOff(); // turn off at the end, otherwise, the tests logs would have of warnings
@@ -1828,7 +1828,7 @@ namespace WalletWasabi.Tests
mempoolTxId.ToString()
});
- using (var coordinatorToTest = new CcjCoordinator(network, backendGlobal.TrustedNodeNotifyingBehavior, folder, rpc, coordinator.RoundConfig))
+ using (var coordinatorToTest = new CcjCoordinator(network, global.TrustedNodeNotifyingBehavior, folder, rpc, coordinator.RoundConfig))
{
var txIds = await File.ReadAllLinesAsync(cjfile);
@@ -1843,7 +1843,7 @@ namespace WalletWasabi.Tests
"This line is invalid (the file is corrupted)",
offchainTxId.ToString(),
});
- var coordinatorToTest2 = new CcjCoordinator(network, backendGlobal.TrustedNodeNotifyingBehavior, folder, rpc, coordinatorToTest.RoundConfig);
+ var coordinatorToTest2 = new CcjCoordinator(network, global.TrustedNodeNotifyingBehavior, folder, rpc, coordinatorToTest.RoundConfig);
coordinatorToTest2?.Dispose();
txIds = await File.ReadAllLinesAsync(cjfile);
Assert.Single(txIds);
@@ -1858,7 +1858,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CcjTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
Money denomination = Money.Coins(0.2m);
decimal coordinatorFeePercent = 0.2m;
@@ -2377,7 +2377,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CcjEqualInputTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
Money denomination = Money.Coins(0.1m);
decimal coordinatorFeePercent = 0.0002m;
@@ -2525,7 +2525,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task NotingTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
Money denomination = Money.Coins(1m);
decimal coordinatorFeePercent = 0.1m;
@@ -2606,7 +2606,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task BanningTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
Money denomination = Money.Coins(0.1m);
decimal coordinatorFeePercent = 0.1m;
@@ -2808,7 +2808,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task Ccj100ParticipantsTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
Money denomination = Money.Coins(0.1m);
decimal coordinatorFeePercent = 0.003m;
@@ -3025,7 +3025,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CcjFeeTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
var synchronizer = new WasabiSynchronizer(network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
synchronizer.Start(requestInterval: TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), 10000); // Start wasabi synchronizer service.
@@ -3149,7 +3149,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CcjClientTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(1);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
var synchronizer = new WasabiSynchronizer(network, bitcoinStore, new Uri(RegTestFixture.BackendEndPoint), null);
synchronizer.Start(requestInterval: TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), 10000); // Start wasabi synchronizer service.
@@ -3305,7 +3305,7 @@ namespace WalletWasabi.Tests
[Fact]
public async Task CoinJoinMultipleRoundTestsAsync()
{
- (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global backendGlobal) = await InitializeTestEnvironmentAsync(3);
+ (string password, RPCClient rpc, Network network, CcjCoordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(3);
Money denomination = Money.Coins(0.1m);
decimal coordinatorFeePercent = 0.1m;
@@ -3317,10 +3317,10 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(backendGlobal.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
- var nodes2 = new NodesGroup(backendGlobal.Config.Network, requirements: Constants.NodeRequirements);
+ var nodes2 = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
nodes2.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
// 2. Create mempool service.

MODIFY
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using NBitcoin;
+using NBitcoin.RPC;
using System;
using System.IO;
using System.Net;
@@ -17,12 +18,10 @@ namespace WalletWasabi.Tests.XunitConfiguration
public class RegTestFixture : IDisposable
{
public string BackendEndPoint { get; internal set; }
-
public IWebHost BackendHost { get; internal set; }
-
public NodeBuilder BackendNodeBuilder { get; internal set; }
-
public CoreNode BackendRegTestNode { get; internal set; }
+ public Backend.Global Global { get; }
public RegTestFixture()
{
@@ -32,19 +31,18 @@ namespace WalletWasabi.Tests.XunitConfiguration
BackendRegTestNode = BackendNodeBuilder.Nodes[0];
var rpc = BackendRegTestNode.CreateRpcClient();
- var connectionString = new NBitcoin.RPC.RPCCredentialString()
- {
+ var connectionString = new RPCCredentialString() {
Server = rpc.Address.AbsoluteUri,
UserPassword = BackendRegTestNode.Creds
}.ToString();
- var backendGlobal = new Backend.Global();
+ var global = new Backend.Global();
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, false);
- var configFilePath = Path.Combine(backendGlobal.DataDir, "Config.json");
+ var configFilePath = Path.Combine(global.DataDir, "Config.json");
config.SetFilePath(configFilePath);
config.ToFileAsync().GetAwaiter().GetResult();
var roundConfig = CreateRoundConfig(Money.Coins(0.1m), Constants.OneDayConfirmationTarget, 0.7, 0.1m, 100, 120, 60, 60, 60, 1, 24, true, 11);
- var roundConfigFilePath = Path.Combine(backendGlobal.DataDir, "CcjRoundConfig.json");
+ var roundConfigFilePath = Path.Combine(global.DataDir, "CcjRoundConfig.json");
roundConfig.SetFilePath(roundConfigFilePath);
roundConfig.ToFileAsync().GetAwaiter().GetResult();
@@ -61,6 +59,7 @@ namespace WalletWasabi.Tests.XunitConfiguration
var delayTask = Task.Delay(3000);
Task.WaitAny(delayTask, hostInitializationTask); // Wait for server to initialize (Without this OSX CI will fail)
}
+
public static CcjRoundConfig CreateRoundConfig(Money denomination,
int confirmationTarget,
double confirmationTargetReductionRate,
@@ -91,7 +90,7 @@ namespace WalletWasabi.Tests.XunitConfiguration
MaximumMixingLevelCount = maximumMixingLevelCount,
};
}
- public Backend.Global Global { get; set; }
+
public void Dispose()
{
// Cleanup tests...

A bunch of stylistic changes