diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index d2dc6d6ee..d33d8b460 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -2423,8 +2423,14 @@ namespace BTCPayServer.Tests break; } } + + // Check that no BTCPay invoice got generated on initial LNURL request + var repo = s.Server.PayTester.GetService(); + var invoices = await repo.GetInvoices(new InvoiceQuery { StoreId = new[] { s.StoreId } }); + Assert.Empty(invoices); var lnUsername = lnaddress1.Split('@')[0]; + LNURLPayRequest req; using (var resp = await s.Server.PayTester.HttpClient.GetAsync($"/.well-known/lnurlp/{lnUsername}")) { @@ -2436,42 +2442,30 @@ namespace BTCPayServer.Tests Assert.Equal(new LightMoney(1000), req.MinSendable); Assert.Equal(LightMoney.FromUnit(6.12m, LightMoneyUnit.BTC), req.MaxSendable); } - lnUsername = lnaddress2.Split('@')[0]; using (var resp = await s.Server.PayTester.HttpClient.GetAsync($"/.well-known/lnurlp/{lnUsername}")) { var str = await resp.Content.ReadAsStringAsync(); req = JsonConvert.DeserializeObject(str); - Assert.Contains(req.ParsedMetadata, m => m.Key == "text/identifier" && m.Value == lnaddress2); - Assert.Contains(req.ParsedMetadata, m => m.Key == "text/plain" && m.Value.StartsWith("Paid to")); Assert.Equal(new LightMoney(2000), req.MinSendable); Assert.Equal(new LightMoney(10_000), req.MaxSendable); } - // Check if we can get the same payrequest through the callback using (var resp = await s.Server.PayTester.HttpClient.GetAsync(req.Callback)) { var str = await resp.Content.ReadAsStringAsync(); req = JsonConvert.DeserializeObject(str); - Assert.Contains(req.ParsedMetadata, m => m.Key == "text/identifier" && m.Value == lnaddress2); - Assert.Contains(req.ParsedMetadata, m => m.Key == "text/plain" && m.Value.StartsWith("Paid to")); Assert.Equal(new LightMoney(2000), req.MinSendable); Assert.Equal(new LightMoney(10_000), req.MaxSendable); } // Can we ask for invoice? (Should fail, below minSpendable) - using (var resp = await s.Server.PayTester.HttpClient.GetAsync(req.Callback + "?amount=999")) + using (var resp = await s.Server.PayTester.HttpClient.GetAsync(req.Callback + "?amount=1999")) { var str = await resp.Content.ReadAsStringAsync(); var err = JsonConvert.DeserializeObject(str); Assert.Equal("Amount is out of bounds.", err.Reason); } - - // Check that no BTCPay invoice got generated on initial LN Address requests - var repo = s.Server.PayTester.GetService(); - var invoices = await repo.GetInvoices(new InvoiceQuery { StoreId = new[] { s.StoreId } }); - Assert.Empty(invoices); - // Can we ask for invoice? using (var resp = await s.Server.PayTester.HttpClient.GetAsync(req.Callback + "?amount=2000")) { @@ -2480,8 +2474,6 @@ namespace BTCPayServer.Tests Assert.NotNull(succ.Pr); Assert.Equal(new LightMoney(2000), BOLT11PaymentRequest.Parse(succ.Pr, Network.RegTest).MinimumAmount); } - invoices = await repo.GetInvoices(new InvoiceQuery { StoreId = new[] { s.StoreId } }); - Assert.Single(invoices); // Can we change comment? using (var resp = await s.Server.PayTester.HttpClient.GetAsync(req.Callback + "?amount=2001")) @@ -2491,6 +2483,8 @@ namespace BTCPayServer.Tests Assert.NotNull(succ.Pr); Assert.Equal(new LightMoney(2001), BOLT11PaymentRequest.Parse(succ.Pr, Network.RegTest).MinimumAmount); } + + // Again, check the invoices invoices = await repo.GetInvoices(new InvoiceQuery { StoreId = new[] { s.StoreId } }); Assert.Equal(2, invoices.Length);