Testing invoice payment with Lnd

This commit is contained in:
rockstardev 2018-05-12 00:43:13 -05:00
parent 8fc1b0c856
commit f97173e9e7
2 changed files with 18 additions and 6 deletions

View file

@ -9,6 +9,7 @@ using NBitcoin.RPC;
using Xunit;
using Xunit.Abstractions;
using System.Linq;
using System.Threading;
namespace BTCPayServer.Tests.UnitTests
{
@ -59,9 +60,19 @@ namespace BTCPayServer.Tests.UnitTests
[Fact]
public async Task SetupWalletForPayment()
public async Task CreateLndInvoiceAndPay()
{
var merchantInvoice = await InvoiceClient.CreateInvoice(10000, "Hello world", TimeSpan.FromSeconds(3600));
await EnsureLightningChannelAsync();
var payResponse = await CustomerLnd.SendPaymentSyncAsync(new LnrpcSendRequest
{
Payment_request = merchantInvoice.BOLT11
});
var invoice = await InvoiceClient.GetInvoice(merchantInvoice.Id);
Assert.True(invoice.PaidAt.HasValue);
}

View file

@ -57,10 +57,10 @@ namespace BTCPayServer.Payments.Lightning.Lnd
NodeId = resp.Identity_pubkey
};
// Lnd doesn't return this data as Clightning so we add it manually from data we have
var uri = new Uri(_Decorator.BaseUrl);
nodeInfo.Address = uri.Host;
nodeInfo.P2PPort = uri.Port;
// Lnd doesn't return this data as Clightning, find alternative ways to supply
// it always should be merchant_lnd:9735 because of docker
nodeInfo.Address = null;
nodeInfo.P2PPort = 9735;
return nodeInfo;
}
@ -71,6 +71,7 @@ namespace BTCPayServer.Payments.Lightning.Lnd
return ConvertLndInvoice(resp);
}
// TODO: These two methods where you wait on invoice are still work in progress
public Task<ILightningListenInvoiceSession> Listen(CancellationToken cancellation = default(CancellationToken))
{
return Task.FromResult<ILightningListenInvoiceSession>(this);
@ -80,8 +81,8 @@ namespace BTCPayServer.Payments.Lightning.Lnd
{
var resp = await _Decorator.SubscribeInvoicesAsync(cancellation);
return ConvertLndInvoice(resp);
}
// Eof work in progress
// utility static methods... maybe move to separate class