From c348dfd136bebdf3eb2738ec137d31cc3833f334 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Tue, 6 Oct 2020 17:56:05 +0200 Subject: [PATCH] tests: add a test for closing a channel with LND Not sure if we should add this as the Dispose() method of the test class actually: https://stackoverflow.com/a/33516224/544947 --- tests/CommonTests.cs | 21 +++++++++++++++++++++ tests/Tester.cs | 13 ++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) 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(); } } }