diff --git a/.gitignore b/.gitignore
index a98a4d9..2a37c17 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,6 @@ Plugins/packed
.vs/
coverage
nuget-packages
-**/.AssemblyAttributes
\ No newline at end of file
+**/.AssemblyAttributes
+btcpay-monero-plugin.sln.DotSettings.user
+.DS_Store
\ No newline at end of file
diff --git a/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj b/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj
index 561c6d8..5487a18 100644
--- a/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj
+++ b/BTCPayServer.Plugins.IntegrationTests/BTCPayServer.Plugins.IntegrationTests.csproj
@@ -11,7 +11,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/BTCPayServer.Plugins.IntegrationTests/Monero/MoneroIntegrationTestBase.cs b/BTCPayServer.Plugins.IntegrationTests/Monero/MoneroIntegrationTestBase.cs
index 05e452e..148eed4 100644
--- a/BTCPayServer.Plugins.IntegrationTests/Monero/MoneroIntegrationTestBase.cs
+++ b/BTCPayServer.Plugins.IntegrationTests/Monero/MoneroIntegrationTestBase.cs
@@ -11,6 +11,7 @@ namespace BTCPayServer.Plugins.IntegrationTests.Monero
{
SetDefaultEnv("BTCPAY_XMR_DAEMON_URI", "http://127.0.0.1:18081");
SetDefaultEnv("BTCPAY_XMR_WALLET_DAEMON_URI", "http://127.0.0.1:18082");
+ SetDefaultEnv("BTCPAY_XMR_WALLET_DAEMON_WALLETDIR", "/wallet");
}
private static void SetDefaultEnv(string key, string defaultValue)
diff --git a/BTCPayServer.Plugins.IntegrationTests/Monero/MoneroPluginUITest.cs b/BTCPayServer.Plugins.IntegrationTests/Monero/MoneroPluginUITest.cs
index 3bae8ef..287dd0c 100644
--- a/BTCPayServer.Plugins.IntegrationTests/Monero/MoneroPluginUITest.cs
+++ b/BTCPayServer.Plugins.IntegrationTests/Monero/MoneroPluginUITest.cs
@@ -1,4 +1,7 @@
+using BTCPayServer.Rating;
+using BTCPayServer.Services.Rates;
using BTCPayServer.Tests;
+using BTCPayServer.Tests.Mocks;
using Xunit;
using Xunit.Abstractions;
@@ -12,13 +15,78 @@ public class MoneroPluginIntegrationTest(ITestOutputHelper helper) : MoneroAndBi
{
await using var s = CreatePlaywrightTester();
await s.StartAsync();
+
+ if (s.Server.PayTester.MockRates)
+ {
+ var rateProviderFactory = s.Server.PayTester.GetService();
+ rateProviderFactory.Providers.Clear();
+
+ var coinAverageMock = new MockRateProvider();
+ coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("BTC_USD"), new BidAsk(5000m)));
+ coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("BTC_EUR"), new BidAsk(4000m)));
+ coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("XMR_BTC"), new BidAsk(4500m)));
+ rateProviderFactory.Providers.Add("coingecko", coinAverageMock);
+
+ var kraken = new MockRateProvider();
+ kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("BTC_USD"), new BidAsk(0.1m)));
+ kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("XMR_USD"), new BidAsk(0.1m)));
+ kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("XMR_BTC"), new BidAsk(0.1m)));
+ rateProviderFactory.Providers.Add("kraken", kraken);
+ }
+
await s.RegisterNewUser(true);
- await s.CreateNewStore();
+ await s.CreateNewStore(preferredExchange: "Kraken");
await s.Page.Locator("a.nav-link[href*='monerolike/XMR']").ClickAsync();
await s.Page.CheckAsync("#Enabled");
await s.Page.SelectOptionAsync("#SettlementConfirmationThresholdChoice", "2");
await s.Page.ClickAsync("#SaveButton");
var classList = await s.Page.Locator("svg.icon-checkmark").GetAttributeAsync("class");
Assert.Contains("text-success", classList);
+
+ // Set rate provider
+ await s.Page.Locator("#StoreNav-General").ClickAsync();
+ await s.Page.Locator("#mainNav #StoreNav-Rates").ClickAsync();
+ await s.Page.FillAsync("#DefaultCurrencyPairs", "BTC_USD,XMR_USD,XMR_BTC");
+ await s.Page.SelectOptionAsync("#PrimarySource_PreferredExchange", "kraken");
+ await s.Page.Locator("#page-primary").ClickAsync();
+
+ // Generate a new invoice
+ await s.Page.Locator("a.nav-link[href*='invoices']").ClickAsync();
+ await s.Page.Locator("#page-primary").ClickAsync();
+ await s.Page.FillAsync("#Amount", "4.20");
+ await s.Page.FillAsync("#BuyerEmail", "monero@monero.com");
+ await Task.Delay(TimeSpan.FromSeconds(25)); // wallet-rpc needs some time to sync. refactor this later
+ await s.Page.Locator("#page-primary").ClickAsync();
+
+ // View the invoice
+ var href = await s.Page.Locator("a[href^='/i/']").GetAttributeAsync("href");
+ var invoiceId = href?.Split("/i/").Last();
+ await s.Page.Locator($"a[href='/i/{invoiceId}']").ClickAsync();
+ await s.Page.ClickAsync("#DetailsToggle");
+
+ // Verify the total fiat amount is $4.20
+ var totalFiat = await s.Page.Locator("#PaymentDetails-TotalFiat dd.clipboard-button").InnerTextAsync();
+ Assert.Equal("$4.20", totalFiat);
+
+ await s.Page.GoBackAsync();
+ await s.Page.Locator("a.nav-link[href*='monerolike/XMR']").ClickAsync();
+
+ // Create a new account label
+ await s.Page.FillAsync("#NewAccountLabel", "tst-account");
+ await s.Page.ClickAsync("button[name='command'][value='add-account']");
+
+ // Select primary Account Index
+ await s.Page.Locator("a.nav-link[href*='monerolike/XMR']").ClickAsync();
+ await s.Page.SelectOptionAsync("#AccountIndex", "1");
+ await s.Page.ClickAsync("#SaveButton");
+
+ // Verify selected account index
+ await s.Page.Locator("a.nav-link[href*='monerolike/XMR']").ClickAsync();
+ var selectedValue = await s.Page.Locator("#AccountIndex").InputValueAsync();
+ Assert.Equal("1", selectedValue);
+
+ // Select confirmation time to 0
+ await s.Page.SelectOptionAsync("#SettlementConfirmationThresholdChoice", "3");
+ await s.Page.ClickAsync("#SaveButton");
}
}
\ No newline at end of file
diff --git a/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml b/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml
index da87f8d..8078534 100644
--- a/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml
+++ b/BTCPayServer.Plugins.IntegrationTests/docker-compose.yml
@@ -13,6 +13,7 @@ services:
TESTS_INCONTAINER: "true"
BTCPAY_XMR_DAEMON_URI: http://monerod:18081
BTCPAY_XMR_WALLET_DAEMON_URI: http://xmr_wallet:18082
+ BTCPAY_XMR_WALLET_DAEMON_WALLETDIR: /wallet
depends_on:
- nbxplorer
- postgres
diff --git a/btcpay-monero-plugin.sln b/btcpay-monero-plugin.sln
index f9a6c00..eb8942e 100644
--- a/btcpay-monero-plugin.sln
+++ b/btcpay-monero-plugin.sln
@@ -87,6 +87,10 @@ Global
{BC95362E-D430-4CB4-B888-EE1C054C1E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC95362E-D430-4CB4-B888-EE1C054C1E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC95362E-D430-4CB4-B888-EE1C054C1E7A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EE24163B-B82C-4561-92F2-C7198CE91F67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EE24163B-B82C-4561-92F2-C7198CE91F67}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EE24163B-B82C-4561-92F2-C7198CE91F67}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EE24163B-B82C-4561-92F2-C7198CE91F67}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{049FC011-1952-4140-9652-12921C106B02} = {891F21E0-262C-4430-90C5-7A540AD7C9AD}