コード例 #1
0
        public void Dispose()
        {
            // Cleanup tests...

            BackendHost?.StopAsync().GetAwaiter().GetResult();
            BackendHost?.Dispose();
            BackendRegTestNode?.TryKillAsync(cleanFolder: true).GetAwaiter().GetResult();
            BackendNodeBuilder?.Dispose();
        }
コード例 #2
0
        public RegTestFixture()
        {
            BackendNodeBuilder = NodeBuilder.CreateAsync(nameof(RegTestFixture)).GetAwaiter().GetResult();
            BackendNodeBuilder.CreateNodeAsync().GetAwaiter().GetResult();
            BackendNodeBuilder.StartAllAsync().GetAwaiter().GetResult();
            BackendRegTestNode = BackendNodeBuilder.Nodes[0];

            var rpc = BackendRegTestNode.CreateRpcClient();
            var connectionString = new RPCCredentialString()
            {
                Server       = rpc.Address.AbsoluteUri,
                UserPassword = BackendRegTestNode.Creds
            }.ToString();

            var testnetBackendDir = EnvironmentHelpers.GetDataDir(Path.Combine("WalletWasabi", "Tests", "Backend"));

            IoHelpers.DeleteRecursivelyWithMagicDustAsync(testnetBackendDir).GetAwaiter().GetResult();
            Thread.Sleep(100);
            Directory.CreateDirectory(testnetBackendDir);
            Thread.Sleep(100);
            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(testnetBackendDir, "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(testnetBackendDir, "CcjRoundConfig.json");

            roundConfig.SetFilePath(roundConfigFilePath);
            roundConfig.ToFileAsync().GetAwaiter().GetResult();

            var conf = new ConfigurationBuilder()
                       .AddInMemoryCollection(new[] { new KeyValuePair <string, string>("datadir", testnetBackendDir) })
                       .Build();

            BackendEndPoint = $"http://localhost:{new Random().Next(37130, 38000)}/";
            BackendHost     = WebHost.CreateDefaultBuilder()
                              .UseStartup <Startup>()
                              .UseConfiguration(conf)
                              .UseWebRoot("../../../../WalletWasabi.Backend/wwwroot")
                              .UseUrls(BackendEndPoint)
                              .Build();
            Global = (Backend.Global)BackendHost.Services.GetService(typeof(Backend.Global));
            var hostInitializationTask = BackendHost.RunWithTasksAsync();

            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)
        }
コード例 #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    BackendHost?.StopAsync().GetAwaiter().GetResult();
                    BackendHost?.Dispose();
                    BackendRegTestNode?.TryStopAsync().GetAwaiter().GetResult();
                }

                _disposedValue = true;
            }
        }