Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RodriFS committed Aug 8, 2023
1 parent 3bbf44f commit f0f98ac
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions test/NodeGuard.Tests/Services/LightningServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ public async Task GetChannelsStatus_SourceNodeIsManaged_SourceIsInitiator()
[Fact]
public async Task GetChannelsStatus_SourceNodeIsManaged_SourceIsNotInitiator()
{
// Arrange
// Arrange
var nodeRepository = new Mock<INodeRepository>();
var lightningClientService = new Mock<ILightningClientService>();

Expand Down Expand Up @@ -1690,7 +1690,7 @@ public async Task GetChannelsStatus_BothNodesAreManaged_SourceIsInitiator()
}
});

var listChannelsResponse = new ListChannelsResponse
var listChannelsResponse1 = new ListChannelsResponse
{
Channels =
{
Expand All @@ -1705,7 +1705,24 @@ public async Task GetChannelsStatus_BothNodesAreManaged_SourceIsInitiator()
}
};

lightningClientService.Setup(x => x.ListChannels(It.IsAny<Node>(), null)).ReturnsAsync(listChannelsResponse);
var listChannelsResponse2 = new ListChannelsResponse
{
Channels =
{
new Lnrpc.Channel
{
ChanId = 0,
LocalBalance = 0,
RemoteBalance = 500,
Initiator = false,
RemotePubkey = "managedPubKey1"
}
}
};

lightningClientService.SetupSequence(x => x.ListChannels(It.IsAny<Node>(), null))
.ReturnsAsync(listChannelsResponse1)
.ReturnsAsync(listChannelsResponse2);
var lightningService = new LightningService(null, null, nodeRepository.Object, null, null, null, null, null ,null, lightningClientService.Object);

// Act
Expand Down Expand Up @@ -1740,7 +1757,22 @@ public async Task GetChannelsStatus_BothNodesAreManaged_SourceIsNotInitiator()
}
});

var listChannelsResponse = new ListChannelsResponse
var listChannelsResponse1 = new ListChannelsResponse
{
Channels =
{
new Lnrpc.Channel
{
ChanId = 0,
LocalBalance = 0,
RemoteBalance = 500,
Initiator = false,
RemotePubkey = "managedPubKey2"
}
}
};

var listChannelsResponse2 = new ListChannelsResponse
{
Channels =
{
Expand All @@ -1750,12 +1782,14 @@ public async Task GetChannelsStatus_BothNodesAreManaged_SourceIsNotInitiator()
LocalBalance = 500,
RemoteBalance = 0,
Initiator = true,
RemotePubkey = "managedPubKey2"
RemotePubkey = "managedPubKey1"
}
}
};

lightningClientService.Setup(x => x.ListChannels(It.IsAny<Node>(), null)).ReturnsAsync(listChannelsResponse);
lightningClientService.SetupSequence(x => x.ListChannels(It.IsAny<Node>(), null))
.ReturnsAsync(listChannelsResponse1)
.ReturnsAsync(listChannelsResponse2);
var lightningService = new LightningService(null, null, nodeRepository.Object, null, null, null, null, null ,null, lightningClientService.Object);

// Act
Expand Down

0 comments on commit f0f98ac

Please sign in to comment.