Skip to content

Commit 2cfc4ed

Browse files
committed
Simulate subaddress generate duplication
1 parent 1ae5455 commit 2cfc4ed

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

BTCPayServer.Plugins.IntegrationTests/Monero/MoneroPluginIntegrationTest.cs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,96 @@ await s.Page.Locator("input#PrivateViewKey")
107107
await CleanUp(s);
108108
}
109109

110+
[Fact]
111+
public async Task EnableMoneroPluginSuccessfullySecond()
112+
{
113+
await using var s = CreatePlaywrightTester();
114+
await s.StartAsync();
115+
116+
if (s.Server.PayTester.MockRates)
117+
{
118+
var rateProviderFactory = s.Server.PayTester.GetService<RateProviderFactory>();
119+
rateProviderFactory.Providers.Clear();
120+
121+
var coinAverageMock = new MockRateProvider();
122+
coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("BTC_USD"), new BidAsk(5000m)));
123+
coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("BTC_EUR"), new BidAsk(4000m)));
124+
coinAverageMock.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("XMR_BTC"), new BidAsk(4500m)));
125+
rateProviderFactory.Providers.Add("coingecko", coinAverageMock);
126+
127+
var kraken = new MockRateProvider();
128+
kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("BTC_USD"), new BidAsk(0.1m)));
129+
kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("XMR_USD"), new BidAsk(0.1m)));
130+
kraken.ExchangeRates.Add(new PairRate(CurrencyPair.Parse("XMR_BTC"), new BidAsk(0.1m)));
131+
rateProviderFactory.Providers.Add("kraken", kraken);
132+
}
133+
134+
await s.RegisterNewUser(true);
135+
await s.CreateNewStore(preferredExchange: "Kraken");
136+
await s.Page.Locator("a.nav-link[href*='monerolike/XMR']").ClickAsync();
137+
await s.Page.Locator("input#PrimaryAddress")
138+
.FillAsync(
139+
"43Pnj6ZKGFTJhaLhiecSFfLfr64KPJZw7MyGH73T6PTDekBBvsTAaWEUSM4bmJqDuYLizhA13jQkMRPpz9VXBCBqQQb6y5L");
140+
await s.Page.Locator("input#PrivateViewKey")
141+
.FillAsync("1bfa03b0c78aa6bc8292cf160ec9875657d61e889c41d0ebe5c54fd3a2c4b40e");
142+
await s.Page.Locator("input#RestoreHeight").FillAsync("0");
143+
await s.Page.Locator("input#WalletPassword").FillAsync("pass123");
144+
await s.Page.ClickAsync("button[name='command'][value='set-wallet-details']");
145+
await s.Page.CheckAsync("#Enabled");
146+
await s.Page.SelectOptionAsync("#SettlementConfirmationThresholdChoice", "2");
147+
await s.Page.ClickAsync("#SaveButton");
148+
var classList = await s.Page.Locator("svg.icon-checkmark").GetAttributeAsync("class");
149+
Assert.Contains("text-success", classList);
150+
151+
// Set rate provider
152+
await s.Page.Locator("#menu-item-General").ClickAsync();
153+
await s.Page.Locator("#menu-item-Rates").ClickAsync();
154+
await s.Page.FillAsync("#DefaultCurrencyPairs", "BTC_USD,XMR_USD,XMR_BTC");
155+
await s.Page.SelectOptionAsync("#PrimarySource_PreferredExchange", "kraken");
156+
await s.Page.Locator("#page-primary").ClickAsync();
157+
158+
// Generate a new invoice
159+
await s.Page.Locator("a.nav-link[href*='invoices']").ClickAsync();
160+
await s.Page.Locator("#page-primary").ClickAsync();
161+
await s.Page.FillAsync("#Amount", "4.20");
162+
await s.Page.FillAsync("#BuyerEmail", "monero@monero.com");
163+
await Task.Delay(TimeSpan.FromSeconds(25)); // wallet-rpc needs some time to sync. refactor this later
164+
await s.Page.Locator("#page-primary").ClickAsync();
165+
166+
// View the invoice
167+
var href = await s.Page.Locator("a[href^='/i/']").GetAttributeAsync("href");
168+
var invoiceId = href?.Split("/i/").Last();
169+
await s.Page.Locator($"a[href='/i/{invoiceId}']").ClickAsync();
170+
await s.Page.ClickAsync("#DetailsToggle");
171+
172+
// Verify the total fiat amount is $4.20
173+
var totalFiat = await s.Page.Locator("#PaymentDetails-TotalFiat dd.clipboard-button").InnerTextAsync();
174+
Assert.Equal("$4.20", totalFiat);
175+
176+
await s.Page.GoBackAsync();
177+
await s.Page.Locator("a.nav-link[href*='monerolike/XMR']").ClickAsync();
178+
179+
// Create a new account label
180+
await s.Page.FillAsync("#NewAccountLabel", "tst-account");
181+
await s.Page.ClickAsync("button[name='command'][value='add-account']");
182+
183+
// Select primary Account Index
184+
await s.Page.Locator("a.nav-link[href*='monerolike/XMR']").ClickAsync();
185+
await s.Page.SelectOptionAsync("#AccountIndex", "1");
186+
await s.Page.ClickAsync("#SaveButton");
187+
188+
// Verify selected account index
189+
await s.Page.Locator("a.nav-link[href*='monerolike/XMR']").ClickAsync();
190+
var selectedValue = await s.Page.Locator("#AccountIndex").InputValueAsync();
191+
Assert.Equal("1", selectedValue);
192+
193+
// Select confirmation time to 0
194+
await s.Page.SelectOptionAsync("#SettlementConfirmationThresholdChoice", "3");
195+
await s.Page.ClickAsync("#SaveButton");
196+
197+
await CleanUp(s);
198+
}
199+
110200
[Fact]
111201
public async Task ShouldFailWhenWrongPrimaryAddress()
112202
{

0 commit comments

Comments
 (0)