mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 01:43:50 +01:00
Partially Revert "Adapt controller and partially fix tests"
This reverts commit d4828f8d0e
.
This commit is contained in:
parent
d99bd28386
commit
af44d6aeac
@ -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<InvoiceRepository>();
|
||||
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<LNURLPayRequest>(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<LNURLPayRequest>(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<LNUrlStatusResponse>(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<InvoiceRepository>();
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user