Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
rsafier committed Jul 11, 2024
1 parent 2117f4e commit 5de4cc4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
14 changes: 7 additions & 7 deletions LNUnit.LND/LNDChannelEventsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public LNDChannelEventsHandler(LNDNodeConnection connection,
public bool Running { get; private set; }
public ulong InterceptCount { get; private set; }


public void Dispose()
{
if (!_disposed)
Expand All @@ -39,20 +39,20 @@ public void Dispose()
_task.Dispose();
Node.Dispose();
}
}
}

public event Action<Lnrpc.ChannelEventUpdate> OnChannelEvent;

private async Task StartListening()
{
Debug.Print($"StartListening: {Node.LocalAlias}");
try
{

using (var streamingEvents =
Node.LightningClient.SubscribeChannelEvents (new ChannelEventSubscription()
Node.LightningClient.SubscribeChannelEvents(new ChannelEventSubscription()
{

}))
{
Running = true;
Expand All @@ -74,7 +74,7 @@ private async Task StartListening()
Running = false;
}



public void Cancel()
{
Expand Down
14 changes: 7 additions & 7 deletions LNUnit.LND/LNDGraphEventsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public class LNDGraphEventsHandler : IDisposable

public LNDGraphEventsHandler(LNDNodeConnection connection,
Action<GraphTopologyUpdate> onGraphEvent)
{
{
Node = connection;
_task = Task.Factory.StartNew(StartListening, _cancellationTokenSource.Token,
TaskCreationOptions.LongRunning, TaskScheduler.Current);
_task = Task.Factory.StartNew(StartListening, _cancellationTokenSource.Token,
TaskCreationOptions.LongRunning, TaskScheduler.Current);
OnGraphEvent = onGraphEvent;
while (!Running)
Task.Delay(100).GetAwaiter().GetResult();
Expand All @@ -39,8 +39,8 @@ public void Dispose()
_task.Dispose();
Node.Dispose();
}
}
}

public event Action<GraphTopologyUpdate> OnGraphEvent;

private async Task StartListening()
Expand All @@ -51,7 +51,7 @@ private async Task StartListening()
using (var streamingEvents =
Node.LightningClient.SubscribeChannelGraph(new GraphTopologySubscription()
{

}))
{
Running = true;
Expand All @@ -73,7 +73,7 @@ private async Task StartListening()
Running = false;
}



public void Cancel()
{
Expand Down
58 changes: 29 additions & 29 deletions LNUnit.Tests/Abstract/AbcLightningAbstractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,34 +356,34 @@ public async Task CheckLNDVersion()
var info = n.LightningClient.GetInfo(new GetInfoRequest());
info.Version.Print();
}
[Test]
[Category("OnChannelEvent")]
[NonParallelizable]
[Ignore("when needed")]
public async Task OnChannelEventBasics()
{
var a = await Builder.GetNodeFromAlias("alice");
var b = await Builder.GetNodeFromAlias("bob");
using var e = new LNDChannelEventsHandler(a, OnChannelEvent);
using var e2 = new LNDGraphEventsHandler(a, OnGraphEvent);
await Task.Delay(5000);
await Builder.RestartByAlias("bob");
await Task.Delay(30000);
e.InterceptCount.PrintDump();
}

private void OnGraphEvent(GraphTopologyUpdate obj)
{
"OnGraphEvent".Print();
obj.PrintDump();
}

private void OnChannelEvent(ChannelEventUpdate obj)
{
"OnChannelEvent".Print();
obj.PrintDump();
}

[Test]
[Category("OnChannelEvent")]
[NonParallelizable]
[Ignore("when needed")]
public async Task OnChannelEventBasics()
{
var a = await Builder.GetNodeFromAlias("alice");
var b = await Builder.GetNodeFromAlias("bob");
using var e = new LNDChannelEventsHandler(a, OnChannelEvent);
using var e2 = new LNDGraphEventsHandler(a, OnGraphEvent);
await Task.Delay(5000);
await Builder.RestartByAlias("bob");
await Task.Delay(30000);
e.InterceptCount.PrintDump();
}

private void OnGraphEvent(GraphTopologyUpdate obj)
{
"OnGraphEvent".Print();
obj.PrintDump();
}

private void OnChannelEvent(ChannelEventUpdate obj)
{
"OnChannelEvent".Print();
obj.PrintDump();
}


[Test]
Expand Down Expand Up @@ -632,7 +632,7 @@ public async Task Keysend_To_Bob_PaymentsPerSecondMax_Threaded(int threads)
$"Failed : {fail_count}".Print();
var successful_pps = success_count / (sw.ElapsedMilliseconds / 1000.0);
$"Successful Payments per second: {successful_pps}".Print();

//Let us also pull mission control data
var mc = await alice.RouterClient.QueryMissionControlAsync(new QueryMissionControlRequest()
{
Expand Down

0 comments on commit 5de4cc4

Please sign in to comment.