Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IAsyncLifetime in TorTests & LiveServerTests. #4324

Merged
merged 2 commits into from Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions WalletWasabi.Tests/IntegrationTests/LiveServerTests.cs
Expand Up @@ -17,15 +17,23 @@
namespace WalletWasabi.Tests.IntegrationTests
{
[Collection("LiveServerTests collection")]
public class LiveServerTests
public class LiveServerTests : IAsyncLifetime
{
public LiveServerTests(LiveServerTestsFixture liveServerTestsFixture)
{
LiveServerTestsFixture = liveServerTestsFixture;
}

public async Task InitializeAsync()
{
var torManager = new TorProcessManager(Global.Instance.TorSocks5Endpoint, Global.Instance.TorLogsFile);
torManager.Start(ensureRunning: true, dataDir: Path.GetFullPath(AppContext.BaseDirectory));
Task.Delay(3000).GetAwaiter().GetResult();
await Task.Delay(3000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we ask TorProcessManager is Tor is running or not?

Copy link
Collaborator Author

@kiminuo kiminuo Sep 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it is helpful at this point because my PRs attempt to reach the state where we would just call: await torManager.Start(ensureRunning: true) and that would wait for Tor to be running or throw an exception that Tor is not reachable.

EDIT: And also that would remove await Task.Delay(3000);.

}

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

private LiveServerTestsFixture LiveServerTestsFixture { get; }
Expand Down
14 changes: 9 additions & 5 deletions WalletWasabi.Tests/IntegrationTests/TorTests.cs
Expand Up @@ -5,20 +5,24 @@
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using WalletWasabi.Tests.XunitConfiguration;
using WalletWasabi.TorSocks5;
using Xunit;

namespace WalletWasabi.Tests.IntegrationTests
{
// Tor must be running
public class TorTests
public class TorTests : IAsyncLifetime
{
public TorTests()
public async Task InitializeAsync()
{
var torManager = new TorProcessManager(Global.Instance.TorSocks5Endpoint, Global.Instance.TorLogsFile);
var torManager = new TorProcessManager(Global.Instance.TorSocks5Endpoint, logFile: Global.Instance.TorLogsFile);
torManager.Start(ensureRunning: true, dataDir: Path.GetFullPath(AppContext.BaseDirectory));
Task.Delay(3000).GetAwaiter().GetResult();
await Task.Delay(3000);
}

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

[Fact]
Expand Down