mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-30 19:24:29 +01:00
move method down
This commit is contained in:
@@ -30,13 +30,6 @@ public class GrpcChannelsBase {
|
||||
throw new IllegalStateException("unexpected open initiator: " + openInitiator);
|
||||
}
|
||||
|
||||
Optional<ChannelId> getChannelId(long chanId, ChannelPoint channelPoint) {
|
||||
if (chanId == 0) {
|
||||
return resolveChannelId(channelPoint);
|
||||
}
|
||||
return Optional.of(ChannelId.fromShortChannelId(chanId));
|
||||
}
|
||||
|
||||
Optional<ChannelId> resolveChannelId(ChannelPoint channelPoint) {
|
||||
return channelIdResolver.resolveFromChannelPoint(channelPoint);
|
||||
}
|
||||
|
||||
@@ -140,4 +140,11 @@ public class GrpcClosedChannels extends GrpcChannelsBase {
|
||||
}
|
||||
throw new IllegalStateException("unexpected close initiator: " + closeInitiator);
|
||||
}
|
||||
|
||||
private Optional<ChannelId> getChannelId(long chanId, ChannelPoint channelPoint) {
|
||||
if (chanId == 0) {
|
||||
return resolveChannelId(channelPoint);
|
||||
}
|
||||
return Optional.of(ChannelId.fromShortChannelId(chanId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,23 +43,6 @@ class GrpcChannelsBaseTest {
|
||||
assertThat(grpcChannelsBase.getOpenInitiator(Initiator.INITIATOR_REMOTE)).isEqualTo(OpenInitiator.REMOTE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getChannelId_already_resolved() {
|
||||
assertThat(grpcChannelsBase.getChannelId(CHANNEL_ID.getShortChannelId(), CHANNEL_POINT)).contains(CHANNEL_ID);
|
||||
verify(channelIdResolver, never()).resolveFromChannelPoint(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getChannelId_resolved() {
|
||||
when(channelIdResolver.resolveFromChannelPoint(CHANNEL_POINT)).thenReturn(Optional.of(CHANNEL_ID_2));
|
||||
assertThat(grpcChannelsBase.getChannelId(0, CHANNEL_POINT)).contains(CHANNEL_ID_2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getChannelId_not_resolved() {
|
||||
assertThat(grpcChannelsBase.getChannelId(0, CHANNEL_POINT)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveChannelId_resolved() {
|
||||
when(channelIdResolver.resolveFromChannelPoint(CHANNEL_POINT)).thenReturn(Optional.of(CHANNEL_ID_2));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.cotto.lndmanagej.grpc;
|
||||
|
||||
import de.cotto.lndmanagej.hardcoded.HardcodedService;
|
||||
import de.cotto.lndmanagej.model.Channel;
|
||||
import de.cotto.lndmanagej.model.ChannelIdResolver;
|
||||
import de.cotto.lndmanagej.model.CloseInitiator;
|
||||
import de.cotto.lndmanagej.model.ClosedChannelFixtures;
|
||||
@@ -222,6 +223,33 @@ class GrpcClosedChannelsTest {
|
||||
verify(channelIdResolver, never()).resolveFromChannelPoint(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getChannelId_already_resolved() {
|
||||
when(grpcService.getClosedChannels()).thenReturn(List.of(
|
||||
closedChannel(CHANNEL_ID_SHORT, COOPERATIVE_CLOSE, INITIATOR_LOCAL, INITIATOR_REMOTE)
|
||||
));
|
||||
assertThat(grpcClosedChannels.getClosedChannels()).map(Channel::getId).containsExactly(CHANNEL_ID);
|
||||
verify(channelIdResolver, never()).resolveFromChannelPoint(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getChannelId_resolved() {
|
||||
when(grpcService.getClosedChannels()).thenReturn(List.of(
|
||||
closedChannel(0, COOPERATIVE_CLOSE, INITIATOR_LOCAL, INITIATOR_REMOTE)
|
||||
));
|
||||
when(channelIdResolver.resolveFromChannelPoint(CHANNEL_POINT)).thenReturn(Optional.of(CHANNEL_ID_2));
|
||||
assertThat(grpcClosedChannels.getClosedChannels()).map(Channel::getId).containsExactly(CHANNEL_ID_2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getChannelId_not_resolved() {
|
||||
when(grpcService.getClosedChannels()).thenReturn(List.of(
|
||||
closedChannel(0, COOPERATIVE_CLOSE, INITIATOR_LOCAL, INITIATOR_REMOTE)
|
||||
));
|
||||
assertThat(grpcClosedChannels.getClosedChannels()).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
private ChannelCloseSummary closedChannel(
|
||||
long channelId,
|
||||
ChannelCloseSummary.ClosureType closeType,
|
||||
|
||||
Reference in New Issue
Block a user