Skip to content

Commit

Permalink
style and format cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rsafier committed Mar 26, 2024
1 parent bf3c16a commit 3665af8
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 135 deletions.
24 changes: 11 additions & 13 deletions LNBolt.Tests/Bech32Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,25 @@
using LNBolt.BOLT11;
using NUnit.Framework;
using org.ldk.structs;
using ServiceStack;

namespace LNBolt.Tests;

public class Bech32Tests
{

public record PaymentRequest
{
public byte[] PaymentHash { get; set; }
public Option_u64Z AmountMilliSatoshis { get; set; }
public long expiry_time { get; set; }
public byte[] payee_pub_key { get; set; }
}

[Test]
public async Task ldk()
{
for (int i = 0; i < 10000; i++)
for (var i = 0; i < 10000; i++)
{
var bolt11 = Bolt11Invoice.from_str(
"lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcsh2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqclj9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9dha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58aguqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphmsywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0vp62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh38s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5j5r6drg6k6zcqj0fcwg");
var x = bolt11 as Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_OK;
var res = new PaymentRequest()
var res = new PaymentRequest
{
PaymentHash = x.res.payment_hash(),
AmountMilliSatoshis = x.res.amount_milli_satoshis(),
expiry_time = x.res.expiry_time(),
payee_pub_key = x.res.payee_pub_key(),
payee_pub_key = x.res.payee_pub_key()
//RouteHints = x.res.route_hints(),
};
var y = x.res.payment_hash();
Expand Down Expand Up @@ -102,4 +92,12 @@ public void LNURLDecode()
Assert.AreEqual("https://service.com/api?q=3fc3645b439ce8e7f2553a69e5267081d96dcd340693afabe04be7b0ccd178df",
url);
}

public record PaymentRequest
{
public byte[] PaymentHash { get; set; }
public Option_u64Z AmountMilliSatoshis { get; set; }
public long expiry_time { get; set; }
public byte[] payee_pub_key { get; set; }
}
}
6 changes: 3 additions & 3 deletions LNBolt.Tests/LNBolt.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

<ItemGroup>
<PackageReference Include="EndianBinaryIO" Version="1.1.2"/>
<PackageReference Include="Microsoft.ClearScript.V8.Native.osx-arm64" Version="7.4.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="Microsoft.ClearScript.V8.Native.osx-arm64" Version="7.4.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="NUnit" Version="3.14.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
<PackageReference Include="org.ldk" Version="0.0.121.2"/>
<PackageReference Include="coverlet.collector" Version="3.1.2">
Expand Down
2 changes: 1 addition & 1 deletion LNBolt/LNBolt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="EndianBinaryIO" Version="1.1.2"/>
<PackageReference Include="NBitcoin" Version="7.0.31"/>
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0"/>
<PackageReference Include="ServiceStack.Text" Version="8.0.0" />
<PackageReference Include="ServiceStack.Text" Version="8.0.0"/>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>
Expand Down
2 changes: 1 addition & 1 deletion LNUnit.LND/LNDNodePool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public async Task<PoolRebalanceStats> RebalanceNodePool()
{
Value = valueInSataoshis,
Memo = "InvoicePayRebalance",
Expiry = 60, //1 minute
Expiry = 60 //1 minute
});
_logger?.LogDebug("InvoicePayRebalance: {PaymentRequest} for {Value} sats from {Source}",
invoice.PaymentRequest, valueInSataoshis, src.LocalAlias);
Expand Down
3 changes: 2 additions & 1 deletion LNUnit.LND/LNDSimpleHtlcInterceptorHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public LNDSimpleHtlcInterceptorHandler(LNDNodeConnection connection,
Func<ForwardHtlcInterceptRequest, Task<ForwardHtlcInterceptResponse>> interceptLogic)
{
Node = connection;
_task = Task.Factory.StartNew(AttachInterceptor, _cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Current);
_task = Task.Factory.StartNew(AttachInterceptor, _cancellationTokenSource.Token,
TaskCreationOptions.LongRunning, TaskScheduler.Current);
OnIntercept = interceptLogic;
while (!Running)
Task.Delay(100).Wait();
Expand Down
10 changes: 5 additions & 5 deletions LNUnit.LND/LNUnit.LND.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<ItemGroup>
<PackageReference Include="EndianBinaryIO" Version="1.1.2"/>
<PackageReference Include="Google.Protobuf" Version="3.25.1" />
<PackageReference Include="Google.Protobuf" Version="3.25.1"/>
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.59.0"/>
<PackageReference Include="Grpc.Net.Client" Version="2.59.0"/>
<PackageReference Include="Grpc.Net.Common" Version="2.59.0"/>
Expand All @@ -33,13 +33,13 @@

<PackageReference Include="Microsoft.NETCore.Targets" Version="5.0.0"/>

<PackageReference Include="NBitcoin" Version="7.0.31" />
<PackageReference Include="NBitcoin" Version="7.0.31"/>

<PackageReference Include="Portable.BouncyCastle" Version="1.9.0"/>

<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="ServiceStack.Text" Version="8.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<PackageReference Include="Serilog" Version="3.1.1"/>
<PackageReference Include="ServiceStack.Text" Version="8.0.0"/>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0"/>
</ItemGroup>


Expand Down
116 changes: 56 additions & 60 deletions LNUnit.Tests/AbcLightningFixture.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
using System.Collections.Immutable;
using System.Collections.Immutable;
using Dasync.Collections;
using Docker.DotNet;
using Docker.DotNet;
using Google.Protobuf;
using Grpc.Core;
using Lnrpc;
using LNUnit.Extentions;
using LNUnit.Fixtures;
using LNUnit.LND;
using LNUnit.Setup;
using LNUnit.Setup;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Routerrpc;
using Serilog;
using Serilog;
using ServiceStack;
using ServiceStack.Text;
using Assert = NUnit.Framework.Assert;
using LNUnit.Fixtures;
using Assert = NUnit.Framework.Assert;


[TestFixture("postgres")]
[TestFixture("boltdb")]
public class AbcLightningFixture : IDisposable
{
public AbcLightningFixture(string dbType)
{
_dbType = dbType;
}

[SetUp]
public async Task PerTestSetUp()
{
Expand All @@ -37,18 +32,18 @@ public async Task PerTestSetUp()

[OneTimeSetUp]
public async Task OneTimeSetup()
{
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory()) // Set the current directory as the base path
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile("appsettings.Development.json", optional: false, reloadOnChange: true)
.AddJsonFile("appsettings.json", false, true)
.AddJsonFile("appsettings.Development.json", false, true)
.Build();
var services = new ServiceCollection();
var services = new ServiceCollection();
var loggerConfiguration = new LoggerConfiguration().Enrich.FromLogContext();
loggerConfiguration.ReadFrom.Configuration(configuration);
Log.Logger = loggerConfiguration.CreateLogger();
services.AddLogging();
services.AddSerilog(Log.Logger, dispose: true);
services.AddSerilog(Log.Logger, true);
_serviceProvider = services.BuildServiceProvider();
Builder = ActivatorUtilities.CreateInstance<LNUnitBuilder>(_serviceProvider);

Expand All @@ -58,15 +53,21 @@ public async Task OneTimeSetup()
PostgresFixture.AddDb("bob");
PostgresFixture.AddDb("carol");
}

await _client.CreateDockerImageFromPath("../../../../Docker/lnd", ["custom_lnd", "custom_lnd:latest"]);
await SetupNetwork("custom_lnd", "latest", "/home/lnd/.lnd");
}


public AbcLightningFixture(string dbType)
{
_dbType = dbType;
}

public string DbContainerName { get; set; } = "postgres";
private readonly DockerClient _client = new DockerClientConfiguration().CreateClient();
private string _containerId;
private string _ip;

private ServiceProvider _serviceProvider;

public void Dispose()
Expand Down Expand Up @@ -99,38 +100,41 @@ public async Task SetupNetwork(string image = "lightninglabs/lnd", string tag =

if (pullImage) await _client.PullImageAndWaitForCompleted(image, tag);


Builder.AddPolarLNDNode("alice",

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► ChannelAcceptorDeny

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► CheckLNDVersion

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► ExportGraph

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► FailureInvoiceTimeout

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► FailureNoRouteBecauseFeesAreTooHigh

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► FailureReasonNoRoute

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► GetChannelPointFromAliases

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► GetChannelsFromAlias

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► GetNodeConnectionFromPool

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► GetPaymentFailureData

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()

Check failure on line 104 in LNUnit.Tests/AbcLightningFixture.cs

View workflow job for this annotation

GitHub Actions / Unit Tests

AbcLightningFixture("postgres") ► InterceptorTest

Failed test found in: coverage/test-results.trx Error: OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
Raw output
OneTimeSetUp: System.Collections.Generic.KeyNotFoundException : The given key 'alice' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AbcLightningFixture.SetupNetwork(String image, String tag, String lndRoot, Boolean pullImage) in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 104
   at AbcLightningFixture.OneTimeSetup() in /home/runner/work/LNUnit/LNUnit/LNUnit.Tests/AbcLightningFixture.cs:line 58
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
   at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()
[
new LNUnitNetworkDefinition.Channel
{
ChannelSize = 10_000_000, //10MSat
RemoteName = "bob"
}
], imageName: image, tagName: tag, pullImage: false, postgresDSN:_dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["alice"] : null);
[
new LNUnitNetworkDefinition.Channel
{
ChannelSize = 10_000_000, //10MSat
RemoteName = "bob"
}
], imageName: image, tagName: tag, pullImage: false,
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["alice"] : null);

Builder.AddPolarLNDNode("bob",
[
new LNUnitNetworkDefinition.Channel
{
ChannelSize = 10_000_000, //10MSat
RemotePushOnStart = 1_000_000, // 1MSat
RemoteName = "alice"
}
], imageName: image, tagName: tag, pullImage: false, postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["bob"] : null);
[
new LNUnitNetworkDefinition.Channel
{
ChannelSize = 10_000_000, //10MSat
RemotePushOnStart = 1_000_000, // 1MSat
RemoteName = "alice"
}
], imageName: image, tagName: tag, pullImage: false,
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["bob"] : null);

Builder.AddPolarLNDNode("carol",
[
new LNUnitNetworkDefinition.Channel
{
ChannelSize = 10_000_000, //10MSat
RemotePushOnStart = 1_000_000, // 1MSat
RemoteName = "bob"
}
], imageName: image, tagName: tag, pullImage: false , postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["carol"] : null);
[
new LNUnitNetworkDefinition.Channel
{
ChannelSize = 10_000_000, //10MSat
RemotePushOnStart = 1_000_000, // 1MSat
RemoteName = "bob"
}
], imageName: image, tagName: tag, pullImage: false,
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["carol"] : null);

await Builder.Build(lndRoot: lndRoot);

WaitNodesReady();
await WaitGraphReady();
}
Expand Down Expand Up @@ -161,8 +165,6 @@ private async Task WaitGraphReady()
}
}




public async Task<bool> IsRunning()
{
Expand All @@ -178,17 +180,10 @@ public async Task<bool> IsRunning()

return false;
}






///////
///
///
/// ///



[Test]
[Category("Payment")]
[NonParallelizable]
Expand Down Expand Up @@ -243,7 +238,7 @@ public async Task PoolRebalance()
stats.PrintDump();
}


[Test]
[Category("Version")]
[NonParallelizable]
Expand Down Expand Up @@ -540,7 +535,7 @@ public async Task FailureReasonNoRoute()
invoice.PrintDump();
//Apply HTLC hold to prevent payment from settling
await Builder.DelayAllHTLCsOnAlias("bob", 600_000); //600s

var paymentTask = Builder.MakeLightningPaymentFromAlias("alice", new SendPaymentRequest
{
PaymentRequest = invoice.PaymentRequest,
Expand All @@ -561,7 +556,7 @@ public async Task FailureReasonNoRoute()
payment.PrintDump();
paymentTask.Dispose();
Assert.That(payment != null && payment.Status == Payment.Types.PaymentStatus.Failed);
Assert.That(payment != null && payment.FailureReason == PaymentFailureReason.FailureReasonNoRoute);
Assert.That(payment != null && payment.FailureReason == PaymentFailureReason.FailureReasonNoRoute);
}


Expand Down Expand Up @@ -679,7 +674,7 @@ public async Task GetPaymentFailureData()
IncludeIncomplete = true // this included failures per docs
});
var finalized = new List<Payment.Types.PaymentStatus>
{Payment.Types.PaymentStatus.Failed};
{ Payment.Types.PaymentStatus.Failed };
await foreach (var p in payments.Payments.Where(x => finalized.Contains(x.Status) && x.Htlcs.Any()))
{
var destinationNode = p.Htlcs.Last().Route.Hops.Last().PubKey;
Expand Down Expand Up @@ -722,6 +717,7 @@ async Task Record(bool success, Payment p, LNDNodeConnection c)
}
}
}

private readonly MemoryCache _aliasCache = new(new MemoryCacheOptions { SizeLimit = 10000 });
private readonly string _dbType;

Expand All @@ -747,7 +743,7 @@ private async Task<string> ToAlias(LNDNodeConnection c, string remotePubkey)

return alias;
}

[Test]
[Category("Payment")]
[Category("Invoice")]
Expand Down
3 changes: 2 additions & 1 deletion LNUnit.Tests/DataSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,5 @@
// Assert.That(li.Invoices.Count > 0);
// Assert.That(li.Invoices.First().State == Invoice.Types.InvoiceState.Settled);
// }
// }
// }

7 changes: 5 additions & 2 deletions LNUnit.Tests/DockerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,16 @@ private string GetRandomHexString(int size = 8)
[Category("Docker")]
public async Task BuildDockerImage()
{
await _client.CreateDockerImageFromPath("./../../../../Docker/lnd", new List<string> { "custom_lnd", "custom_lnd:latest" });
await _client.CreateDockerImageFromPath("./../../../../Docker/lnd",
new List<string> { "custom_lnd", "custom_lnd:latest" });
}

[Test]
[Category("Docker")]
public async Task BuildBitcoin_27_0_rc1_DockerImage()
{
await _client.CreateDockerImageFromPath("./../../../../Docker/bitcoin/27.0rc1", new List<string> { "bitcoin:27.0rc1" });
await _client.CreateDockerImageFromPath("./../../../../Docker/bitcoin/27.0rc1",
new List<string> { "bitcoin:27.0rc1" });
}


Expand Down
Loading

0 comments on commit 3665af8

Please sign in to comment.