mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-23 07:54:24 +01:00
include close details in channel basic information
This commit is contained in:
@@ -86,12 +86,20 @@ class ChannelControllerTest {
|
||||
|
||||
@Test
|
||||
void getBasicInformation() throws NotFoundException {
|
||||
ChannelDto basicInformation = new ChannelDto(LOCAL_OPEN_CHANNEL);
|
||||
ChannelDto basicInformation = new ChannelDto(LOCAL_OPEN_CHANNEL, ClosedChannelDetailsDto.UNKNOWN);
|
||||
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(LOCAL_OPEN_CHANNEL));
|
||||
assertThat(channelController.getBasicInformation(CHANNEL_ID)).isEqualTo(basicInformation);
|
||||
verify(metrics).mark(argThat(name -> name.endsWith(".getBasicInformation")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBasicInformation_closed_channel() throws NotFoundException {
|
||||
ChannelDto basicInformation = new ChannelDto(CLOSED_CHANNEL, CLOSED_CHANNEL_DETAILS_DTO);
|
||||
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(CLOSED_CHANNEL));
|
||||
assertThat(channelController.getBasicInformation(CHANNEL_ID)).isEqualTo(basicInformation);
|
||||
verify(metrics).mark(argThat(name -> name.endsWith(".getBasicInformation")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDetails_channel_not_found() {
|
||||
assertThatExceptionOfType(NotFoundException.class)
|
||||
@@ -106,7 +114,7 @@ class ChannelControllerTest {
|
||||
LOCAL_OPEN_CHANNEL.getBalanceInformation(),
|
||||
ON_CHAIN_COSTS,
|
||||
FEE_CONFIGURATION_DTO,
|
||||
new ClosedChannelDetailsDto("", 0)
|
||||
ClosedChannelDetailsDto.UNKNOWN
|
||||
);
|
||||
when(nodeService.getAlias(PUBKEY_2)).thenReturn(ALIAS_2);
|
||||
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(LOCAL_OPEN_CHANNEL));
|
||||
@@ -125,7 +133,7 @@ class ChannelControllerTest {
|
||||
LOCAL_OPEN_CHANNEL_PRIVATE.getBalanceInformation(),
|
||||
ON_CHAIN_COSTS,
|
||||
FEE_CONFIGURATION_DTO,
|
||||
new ClosedChannelDetailsDto("", 0)
|
||||
ClosedChannelDetailsDto.UNKNOWN
|
||||
);
|
||||
when(nodeService.getAlias(PUBKEY_2)).thenReturn(ALIAS_2);
|
||||
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(LOCAL_OPEN_CHANNEL_PRIVATE));
|
||||
|
||||
@@ -19,13 +19,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class ChannelDetailsDtoTest {
|
||||
|
||||
private static final OnChainCostsDto ON_CHAIN_COSTS = new OnChainCostsDto(Coins.ofSatoshis(1), Coins.ofSatoshis(2));
|
||||
private static final ClosedChannelDetailsDto CLOSE_DETAILS = new ClosedChannelDetailsDto("abc", 123);
|
||||
private static final ChannelDetailsDto CHANNEL_DETAILS_DTO = new ChannelDetailsDto(
|
||||
CLOSED_CHANNEL,
|
||||
ALIAS,
|
||||
BALANCE_INFORMATION,
|
||||
ON_CHAIN_COSTS,
|
||||
PoliciesDto.EMPTY,
|
||||
new ClosedChannelDetailsDto("", 0)
|
||||
CLOSE_DETAILS
|
||||
);
|
||||
|
||||
@Test
|
||||
@@ -81,13 +82,18 @@ class ChannelDetailsDtoTest {
|
||||
BALANCE_INFORMATION,
|
||||
ON_CHAIN_COSTS,
|
||||
PoliciesDto.EMPTY,
|
||||
new ClosedChannelDetailsDto("", 0)
|
||||
CLOSE_DETAILS
|
||||
);
|
||||
ChannelStatusDto channelStatusDto =
|
||||
ChannelStatusDto.createFrom(new ChannelStatus(false, true, false, OPEN));
|
||||
assertThat(dto.status()).isEqualTo(channelStatusDto);
|
||||
}
|
||||
|
||||
@Test
|
||||
void closeDetails() {
|
||||
assertThat(CHANNEL_DETAILS_DTO.closeDetails()).isEqualTo(CLOSE_DETAILS);
|
||||
}
|
||||
|
||||
@Test
|
||||
void balance() {
|
||||
assertThat(CHANNEL_DETAILS_DTO.balance()).isEqualTo(BalanceInformationDto.createFrom(BALANCE_INFORMATION));
|
||||
|
||||
@@ -16,7 +16,8 @@ import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ChannelDtoTest {
|
||||
private static final ChannelDto CHANNEL_DTO = new ChannelDto(CLOSED_CHANNEL);
|
||||
private static final ClosedChannelDetailsDto CLOSE_DETAILS = new ClosedChannelDetailsDto("abc", 123);
|
||||
private static final ChannelDto CHANNEL_DTO = new ChannelDto(CLOSED_CHANNEL, CLOSE_DETAILS);
|
||||
|
||||
@Test
|
||||
void channelIdShort() {
|
||||
@@ -55,13 +56,13 @@ class ChannelDtoTest {
|
||||
|
||||
@Test
|
||||
void totalSent() {
|
||||
assertThat(new ChannelDto(LOCAL_OPEN_CHANNEL).totalSent())
|
||||
assertThat(new ChannelDto(LOCAL_OPEN_CHANNEL, CLOSE_DETAILS).totalSent())
|
||||
.isEqualTo(String.valueOf(TOTAL_SENT.satoshis()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void totalReceived() {
|
||||
assertThat(new ChannelDto(LOCAL_OPEN_CHANNEL).totalReceived())
|
||||
assertThat(new ChannelDto(LOCAL_OPEN_CHANNEL, CLOSE_DETAILS).totalReceived())
|
||||
.isEqualTo(String.valueOf(TOTAL_RECEIVED.satoshis()));
|
||||
}
|
||||
|
||||
@@ -70,9 +71,14 @@ class ChannelDtoTest {
|
||||
assertThat(CHANNEL_DTO.openInitiator()).isEqualTo(OpenInitiator.LOCAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
void closeDetails() {
|
||||
assertThat(CHANNEL_DTO.closeDetails()).isEqualTo(CLOSE_DETAILS);
|
||||
}
|
||||
|
||||
@Test
|
||||
void status() {
|
||||
ChannelDto dto = new ChannelDto(LOCAL_OPEN_CHANNEL);
|
||||
ChannelDto dto = new ChannelDto(LOCAL_OPEN_CHANNEL, CLOSE_DETAILS);
|
||||
ChannelStatusDto channelStatusDto =
|
||||
ChannelStatusDto.createFrom(new ChannelStatus(false, true, false, OPEN));
|
||||
assertThat(dto.status()).isEqualTo(channelStatusDto);
|
||||
|
||||
Reference in New Issue
Block a user