diff --git a/tests/CommonTests.cs b/tests/CommonTests.cs index cb6f52b1..95d202c1 100644 --- a/tests/CommonTests.cs +++ b/tests/CommonTests.cs @@ -536,5 +536,26 @@ public void CanParseLightningURL() Assert.True(LightningConnectionString.TryParse("type=charge;server=http://api-token:foiewnccewuify@127.0.0.1:54938/;allowinsecure=true", out conn)); Assert.Equal("type=charge;server=http://127.0.0.1:54938/;api-token=foiewnccewuify;allowinsecure=true", conn.ToString()); } + + [Fact(Timeout = Timeout)] + public async Task CanCloseLndChannel() + { + // TODO: test in all LN implementations, not just LND + //foreach (var test in Tester.GetTestedPairs()) + //{ + var test = Tester.GetTestedLndPair(); + await EnsureConnectedToDestinations(test); + var customer = (ILightningClient)test.Customer; + var senderChannel = (await customer.ListChannels()).First(); + + var senderInfo = await customer.GetInfo(); + var closeChannelRequest = new CloseChannelRequest() + { + NodeInfo = senderInfo.NodeInfoList.First(), + ChannelPointOutputIndex = senderChannel.ChannelPoint.N + }; + await test.Merchant.CloseChannel(closeChannelRequest, CancellationToken.None); + //} + } } } diff --git a/tests/Tester.cs b/tests/Tester.cs index 8d983523..5ee69295 100644 --- a/tests/Tester.cs +++ b/tests/Tester.cs @@ -87,11 +87,18 @@ public static LndClient CreateLndClientDest() yield return ("Eclair (Client)", CreateEclairClient()); } + private static (string Name, ILightningClient Customer, ILightningClient Merchant) GetTestedCLightningPair() + => ("C-Lightning", CreateCLightningClient(), CreateCLightningClientDest()); + internal static (string Name, LndClient Customer, LndClient Merchant) GetTestedLndPair() + => ("LND", CreateLndClient(), CreateLndClientDest()); + private static (string Name, ILightningClient Customer, ILightningClient Merchant) GetTestedEclairPair() + => ("Eclair", CreateEclairClient(), CreateEclairClientDest()); + public static IEnumerable<(string Name, ILightningClient Customer, ILightningClient Merchant)> GetTestedPairs() { - yield return ("C-Lightning", CreateCLightningClient(), CreateCLightningClientDest()); - yield return ("LND", CreateLndClient(), CreateLndClientDest()); - yield return ("Eclair", CreateEclairClient(), CreateEclairClientDest()); + yield return GetTestedCLightningPair(); + yield return GetTestedLndPair(); + yield return GetTestedEclairPair(); } } }