Skip to content

Commit

Permalink
Merge pull request #4324 from kiminuo/feature/2020-09-08-torTests
Browse files Browse the repository at this point in the history
Use `IAsyncLifetime` in TorTests & LiveServerTests.
  • Loading branch information
molnard committed Sep 15, 2020
2 parents 15ac1ed + 30a3e32 commit 157b33d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
16 changes: 13 additions & 3 deletions WalletWasabi.Tests/IntegrationTests/LiveServerTests.cs
Expand Up @@ -2,6 +2,7 @@
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -17,18 +18,27 @@
namespace WalletWasabi.Tests.IntegrationTests
{
[Collection("LiveServerTests collection")]
public class LiveServerTests
public class LiveServerTests : IAsyncLifetime
{
public LiveServerTests(LiveServerTestsFixture liveServerTestsFixture)
{
LiveServerTestsFixture = liveServerTestsFixture;
}

public async Task InitializeAsync()
{
EndPoint endpoint = Global.Instance.TorSocks5Endpoint;
string dataDir = Path.GetFullPath(AppContext.BaseDirectory);
string torLogsFile = Global.Instance.TorLogsFile;

var torManager = new TorProcessManager(Global.Instance.TorSocks5Endpoint, dataDir, torLogsFile);
var torManager = new TorProcessManager(endpoint, dataDir, torLogsFile);
torManager.Start(ensureRunning: true);
Task.Delay(3000).GetAwaiter().GetResult();
await Task.Delay(3000);
}

public Task DisposeAsync()
{
return Task.CompletedTask;
}

private LiveServerTestsFixture LiveServerTestsFixture { get; }
Expand Down
14 changes: 10 additions & 4 deletions WalletWasabi.Tests/IntegrationTests/TorTests.cs
Expand Up @@ -12,16 +12,22 @@
namespace WalletWasabi.Tests.IntegrationTests
{
// Tor must be running
public class TorTests
public class TorTests : IAsyncLifetime
{
public TorTests()
public async Task InitializeAsync()
{
EndPoint endpoint = Global.Instance.TorSocks5Endpoint;
string dataDir = Path.GetFullPath(AppContext.BaseDirectory);
string torLogsFile = Global.Instance.TorLogsFile;

var torManager = new TorProcessManager(Global.Instance.TorSocks5Endpoint, dataDir, torLogsFile);
var torManager = new TorProcessManager(endpoint, dataDir, torLogsFile);
torManager.Start(ensureRunning: true);
Task.Delay(3000).GetAwaiter().GetResult();
await Task.Delay(3000);
}

public Task DisposeAsync()
{
return Task.CompletedTask;
}

[Fact]
Expand Down

0 comments on commit 157b33d

Please sign in to comment.