Skip to content

Commit

Permalink
Merge pull request #13071 from turbolay/fixIntegrationTests
Browse files Browse the repository at this point in the history
Fix or remove some IntegrationsTests
  • Loading branch information
turbolay committed May 24, 2024
2 parents ede4ac5 + a0cb280 commit 083d860
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 131 deletions.
6 changes: 3 additions & 3 deletions WalletWasabi.Tests/IntegrationTests/LiveServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task GetVersionsTestsAsync(Network network)
Assert.InRange(versions.ClientVersion, new(2, 0, 0), new(2, 99, 99));
Assert.InRange(versions.ClientVersion, new(2, 0, 0), WalletWasabi.Helpers.Constants.ClientVersion);
Assert.Equal(4, versions.BackendMajorVersion);
Assert.Equal(new(1, 0), versions.LegalDocumentsVersion);
Assert.Equal(new(2, 0), versions.LegalDocumentsVersion);
}

[Theory]
Expand All @@ -108,7 +108,7 @@ public async Task CheckUpdatesTestsAsync(Network network)

Assert.True(updateStatus.BackendCompatible);
Assert.True(updateStatus.ClientUpToDate);
Assert.Equal(new Version(1, 0), updateStatus.LegalDocumentsVersion);
Assert.Equal(new Version(2, 0), updateStatus.LegalDocumentsVersion);
Assert.Equal((ushort)4, updateStatus.CurrentBackendMajorVersion);
Assert.Equal(WalletWasabi.Helpers.Constants.ClientVersion.ToString(3), updateStatus.ClientVersion.ToString());

Expand All @@ -126,7 +126,7 @@ public async Task GetLegalDocumentsTestsAsync(Network network)
var content = await client.GetLegalDocumentsAsync(ctsTimeout.Token);
var lines = content.Split('\n', StringSplitOptions.RemoveEmptyEntries);

Assert.Equal("Last Updated: 2022-06-15", lines[0]);
Assert.Equal("Last Updated: May 01, 2024", lines[0]);
var lineCount = lines.Length;
Assert.InRange(lineCount, 100, 1000);
}
Expand Down
1 change: 1 addition & 0 deletions WalletWasabi.Tests/IntegrationTests/P2pTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public async Task TestServicesAsync(string networkString)
bitcoinStore.BlockRepository,
[specificNodeBlockProvider],
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled));
await blockDownloadService.StartAsync(CancellationToken.None);

using UnconfirmedTransactionChainProvider unconfirmedChainProvider = new(httpClientFactory);

Expand Down
128 changes: 0 additions & 128 deletions WalletWasabi.Tests/IntegrationTests/ShopWareApiClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,83 +15,6 @@ namespace WalletWasabi.Tests.IntegrationTests;

public class ShopWareApiClientTests
{
[Fact]
public async Task GenerateOrderAsync()
{
await using TestSetup testSetup = TestSetup.ForClearnet();
ShopWareApiClient shopWareApiClient = testSetup.ShopWareApiClient;

var customerRegistrationRequest = ShopWareRequestFactory.CustomerRegistrationRequest(
"018b6635785b70679f479eadf50330f3", "Lucas", "Carvalho", $"{Guid.NewGuid()}@me.com", "Password", "5d54dfdc2b384a8e9fff2bfd6e64c186", "comment", "https://wasabi.shopinbit.com");

var customer = await shopWareApiClient.RegisterCustomerAsync("none", customerRegistrationRequest, CancellationToken.None);

var shoppingCart = await shopWareApiClient.GetOrCreateShoppingCartAsync(customer.ContextTokens[0],
ShopWareRequestFactory.ShoppingCartCreationRequest("My little shopping cart"), CancellationToken.None);
var shoppingCartItemsResponse = await shopWareApiClient.AddItemToShoppingCartAsync(customer.ContextTokens[0],
ShopWareRequestFactory.ShoppingCartItemsRequest("018c0cec5299719f9458dba04f88eb8c"), CancellationToken.None);
var orderResponse = await shopWareApiClient.GenerateOrderAsync(shoppingCartItemsResponse.Token,
ShopWareRequestFactory.OrderGenerationRequest(), CancellationToken.None);
var orderListResponse = await shopWareApiClient.GetOrderListAsync(shoppingCartItemsResponse.Token,
ShopWareRequestFactory.GetOrderListRequest(), CancellationToken.None);
var uniqueOrder = Assert.Single(orderListResponse.Orders.Elements);
Assert.Equal(uniqueOrder.OrderNumber, orderResponse.OrderNumber);

var cancelledOrder = await shopWareApiClient.CancelOrderAsync(shoppingCartItemsResponse.Token,
ShopWareRequestFactory.CancelOrderRequest(uniqueOrder.Id), CancellationToken.None);

Assert.Equal("Cancelled", cancelledOrder.Name);
}

[Fact]
public async Task CanRegisterAndLogInClearnetAsync()
{
await using TestSetup testSetup = TestSetup.ForClearnet();
ShopWareApiClient shopWareApiClient = testSetup.ShopWareApiClient;

await CanRegisterAndLogInAsync(shopWareApiClient);
}

// Make sure tor.exe is running locally, otherwise the test fails.
[Fact]
public async Task CanRegisterAndLogInTorAsync()
{
await using TestSetup testSetup = TestSetup.ForTor();
ShopWareApiClient shopWareApiClient = testSetup.ShopWareApiClient;

await CanRegisterAndLogInAsync(shopWareApiClient);
}

private async Task CanRegisterAndLogInAsync(ShopWareApiClient shopWareApiClient)
{
// Register a user.
var customerRequestWithRandomData = CreateRandomCustomer("a comment", out var email, out var password);
var customer = await shopWareApiClient.RegisterCustomerAsync("none", customerRequestWithRandomData, CancellationToken.None);
Assert.NotNull(customer);

var ogCustomerNumber = customer.CustomerNumber;
var ogCustomerToken = customer.ContextTokens[0];
var ogCustomerId = customer.Id;

// Log in with the new user.
var loggedInCustomer = await shopWareApiClient.LoginCustomerAsync("none", ShopWareRequestFactory.CustomerLoginRequest(email, password), CancellationToken.None);
Assert.Equal(loggedInCustomer.ContextToken, customer.ContextTokens[0]);

// Register with a new user.
var newCustomerRequestWithRandomData = CreateRandomCustomer("no comments", out _, out _);
var newCustomer = await shopWareApiClient.RegisterCustomerAsync("none", newCustomerRequestWithRandomData, CancellationToken.None);
Assert.NotNull(newCustomer);

var newCustomerNumber = newCustomer.CustomerNumber;
var newCustomerToken = newCustomer.ContextTokens[0];
var newCustomerId = newCustomer.Id;

// Assert that new user's data isn't the same as the first one.
Assert.NotEqual(ogCustomerNumber, newCustomerNumber);
Assert.NotEqual(ogCustomerId, newCustomerId);
Assert.NotEqual(ogCustomerToken, newCustomerToken);
}

[Fact]
public async Task CanFetchCountriesAndStatesAsync()
{
Expand Down Expand Up @@ -132,57 +55,6 @@ public async Task CanFetchCountriesAndStatesAsync()
// await File.WriteAllTextAsync(Path.Combine(outputFolder.FullName, "Countries.json"), JsonSerializer.Serialize(toSerialize));
}

[Fact]
public async Task CanUpdateBillingAddressAsync()
{
var customerRequestWithRandomData = CreateRandomCustomer("Set billing address please.", out var email, out var password);

await using TestSetup testSetup = TestSetup.ForClearnet();
ShopWareApiClient shopWareApiClient = testSetup.ShopWareApiClient;

// Register
var customer = await shopWareApiClient.RegisterCustomerAsync("none", customerRequestWithRandomData, CancellationToken.None);

// Login
var loggedInCustomer = await shopWareApiClient.LoginCustomerAsync(customer.ContextTokens[0], ShopWareRequestFactory.CustomerLoginRequest(email, password), CancellationToken.None);

// Update billing address
await shopWareApiClient.UpdateCustomerBillingAddressAsync(
loggedInCustomer.ContextToken,
ShopWareRequestFactory.BillingAddressRequest(
customerRequestWithRandomData["firstName"].ToString()!,
customerRequestWithRandomData["lastName"].ToString()!,
"My updated street",
"123",
"1022",
"Budapest",
"none",
"6ab3247e27174ee898a2479071754912"),
CancellationToken.None);

await Task.Delay(10000);

// Check admin site if the customer billing address got updated or not.
}

private PropertyBag CreateRandomCustomer(string message, out string email, out string password)
{
email = $"{Guid.NewGuid()}@me.com";
password = "Password";

PropertyBag crr = ShopWareRequestFactory.CustomerRegistrationRequest(
salutationId: "018b6635785b70679f479eadf50330f3",
firstName: "Random",
lastName: "Dude Jr.",
email: email,
password: password,
countryId: "5d54dfdc2b384a8e9fff2bfd6e64c186",
message: message,
storefrontUrl: "https://wasabi.shopinbit.com");

return crr;
}

private class TestSetup : IAsyncDisposable
{
private TestSetup(bool useTor)
Expand Down

0 comments on commit 083d860

Please sign in to comment.