mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Providing merchant_lnd and customer_lnd for testing
This commit is contained in:
parent
b03d271f85
commit
f8540dc78c
3 changed files with 72 additions and 14 deletions
|
@ -11,6 +11,7 @@ using Xunit.Abstractions;
|
|||
|
||||
namespace BTCPayServer.Tests.UnitTests
|
||||
{
|
||||
// this depends for now on `docker-compose up devlnd`
|
||||
public class LndTest
|
||||
{
|
||||
private readonly ITestOutputHelper output;
|
||||
|
@ -20,13 +21,17 @@ namespace BTCPayServer.Tests.UnitTests
|
|||
this.output = output;
|
||||
initializeEnvironment();
|
||||
|
||||
LndRpc = LndSwaggerClientCustomHttp.Create(new Uri("http://localhost:53280"), Network.RegTest);
|
||||
InvoiceClient = new LndClient(LndRpc);
|
||||
MerchantLnd = LndSwaggerClientCustomHttp.Create(new Uri("http://127.0.0.1:53280"), Network.RegTest);
|
||||
InvoiceClient = new LndClient(MerchantLnd);
|
||||
|
||||
CustomerLnd = LndSwaggerClientCustomHttp.Create(new Uri("http://127.0.0.1:53281"), Network.RegTest);
|
||||
}
|
||||
|
||||
private LndSwaggerClientCustomHttp LndRpc { get; set; }
|
||||
private LndSwaggerClientCustomHttp MerchantLnd { get; set; }
|
||||
private LndClient InvoiceClient { get; set; }
|
||||
|
||||
private LndSwaggerClientCustomHttp CustomerLnd { get; set; }
|
||||
|
||||
[Fact]
|
||||
public async Task GetInfo()
|
||||
{
|
||||
|
@ -55,14 +60,23 @@ namespace BTCPayServer.Tests.UnitTests
|
|||
[Fact]
|
||||
public async Task SetupWalletForPayment()
|
||||
{
|
||||
var nodeInfo = GetInfo();
|
||||
var addressResponse = await LndRpc.NewWitnessAddressAsync();
|
||||
var merchantNodeInfo = await InvoiceClient.GetInfo();
|
||||
var addressResponse = await CustomerLnd.NewWitnessAddressAsync();
|
||||
var address = BitcoinAddress.Create(addressResponse.Address, Network.RegTest);
|
||||
await ExplorerNode.SendToAddressAsync(address, Money.Coins(0.2m));
|
||||
ExplorerNode.Generate(1);
|
||||
await WaitLNSynched();
|
||||
await Task.Delay(1000);
|
||||
|
||||
var connectResp = await CustomerLnd.ConnectPeerAsync(new LnrpcConnectPeerRequest
|
||||
{
|
||||
Addr = new LnrpcLightningAddress
|
||||
{
|
||||
Pubkey = merchantNodeInfo.NodeId,
|
||||
Host = "merchant_lnd:8080"
|
||||
}
|
||||
});
|
||||
|
||||
// We need two instances of lnd... one for merchant, one for buyer
|
||||
// prepare that in next commit
|
||||
//var channelReq = new LnrpcOpenChannelRequest
|
||||
|
|
|
@ -44,7 +44,22 @@ services:
|
|||
- customer_lightningd
|
||||
- merchant_lightningd
|
||||
- lightning-charged
|
||||
- lnd
|
||||
- customer_lnd
|
||||
- merchant_lnd
|
||||
|
||||
devlnd:
|
||||
image: nicolasdorier/docker-bitcoin:0.16.0
|
||||
environment:
|
||||
BITCOIN_EXTRA_ARGS: |
|
||||
regtest=1
|
||||
connect=bitcoind:39388
|
||||
links:
|
||||
- nbxplorer
|
||||
- postgres
|
||||
- customer_lnd
|
||||
- merchant_lnd
|
||||
|
||||
|
||||
|
||||
nbxplorer:
|
||||
image: nicolasdorier/nbxplorer:1.0.2.2
|
||||
|
@ -180,7 +195,7 @@ services:
|
|||
expose:
|
||||
- "5432"
|
||||
|
||||
lnd:
|
||||
merchant_lnd:
|
||||
image: btcpayserver/lnd:0.4.1.0
|
||||
environment:
|
||||
RPCHOST: bitcoind:43782
|
||||
|
@ -193,8 +208,32 @@ services:
|
|||
DEBUG: debug
|
||||
ports:
|
||||
- "53280:8080"
|
||||
expose:
|
||||
- "8080"
|
||||
- "10009"
|
||||
volumes:
|
||||
- "lnd_datadir:/root/.lnd"
|
||||
- "merchant_lnd_datadir:/root/.lnd"
|
||||
links:
|
||||
- bitcoind
|
||||
|
||||
customer_lnd:
|
||||
image: btcpayserver/lnd:0.4.1.0
|
||||
environment:
|
||||
RPCHOST: bitcoind:43782
|
||||
RPCUSER: ceiwHEbqWI83
|
||||
RPCPASS: DwubwWsoo3
|
||||
ZMQPATH: tcp://bitcoind:28332
|
||||
NETWORK: regtest
|
||||
CHAIN: bitcoin
|
||||
BACKEND: bitcoind
|
||||
DEBUG: debug
|
||||
ports:
|
||||
- "53281:8080"
|
||||
expose:
|
||||
- "8080"
|
||||
- "10009"
|
||||
volumes:
|
||||
- "customer_lnd_datadir:/root/.lnd"
|
||||
links:
|
||||
- bitcoind
|
||||
|
||||
|
@ -203,4 +242,5 @@ volumes:
|
|||
customer_lightningd_datadir:
|
||||
merchant_lightningd_datadir:
|
||||
lightning_charge_datadir:
|
||||
lnd_datadir:
|
||||
customer_lnd_datadir:
|
||||
merchant_lnd_datadir:
|
||||
|
|
|
@ -51,14 +51,18 @@ namespace BTCPayServer.Payments.Lightning.Lnd
|
|||
{
|
||||
var resp = await _Decorator.GetInfoAsync(cancellation);
|
||||
|
||||
var invoice = new LightningNodeInformation
|
||||
var nodeInfo = new LightningNodeInformation
|
||||
{
|
||||
Address = resp.Uris?.FirstOrDefault(),
|
||||
BlockHeight = (int?)resp.Block_height ?? 0,
|
||||
NodeId = resp.Alias,
|
||||
P2PPort = 0
|
||||
NodeId = resp.Identity_pubkey
|
||||
};
|
||||
return invoice;
|
||||
|
||||
// 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;
|
||||
|
||||
return nodeInfo;
|
||||
}
|
||||
|
||||
public async Task<LightningInvoice> GetInvoice(string invoiceId, CancellationToken cancellation = default(CancellationToken))
|
||||
|
|
Loading…
Add table
Reference in a new issue