Skip to content

Commit

Permalink
tests: add a test for closing a channel with LND
Browse files Browse the repository at this point in the history
Not sure if we should add this as the Dispose() method
of the test class actually:
https://stackoverflow.com/a/33516224/544947
  • Loading branch information
knocte committed Oct 6, 2020
1 parent 00a3fef commit c348dfd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
21 changes: 21 additions & 0 deletions tests/CommonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,5 +536,26 @@ public void CanParseLightningURL()
Assert.True(LightningConnectionString.TryParse("type=charge;server=http://api-token:[email protected]: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);
//}
}
}
}
13 changes: 10 additions & 3 deletions tests/Tester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

0 comments on commit c348dfd

Please sign in to comment.