mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-22 15:35:10 +01:00
add endpoint providing basic channel information
This commit is contained in:
@@ -2,6 +2,7 @@ package de.cotto.lndmanagej.controller;
|
||||
|
||||
import de.cotto.lndmanagej.controller.dto.BalanceInformationDto;
|
||||
import de.cotto.lndmanagej.controller.dto.ChannelDetailsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.ChannelDto;
|
||||
import de.cotto.lndmanagej.controller.dto.FeeConfigurationDto;
|
||||
import de.cotto.lndmanagej.controller.dto.OnChainCostsDto;
|
||||
import de.cotto.lndmanagej.metrics.Metrics;
|
||||
@@ -73,6 +74,20 @@ class ChannelControllerTest {
|
||||
lenient().when(feeService.getFeeConfiguration(CHANNEL_ID)).thenReturn(FEE_CONFIGURATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBasicInformation_channel_not_found() {
|
||||
assertThatExceptionOfType(NotFoundException.class)
|
||||
.isThrownBy(() -> channelController.getBasicInformation(CHANNEL_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBasicInformation() throws NotFoundException {
|
||||
ChannelDto basicInformation = new ChannelDto(LOCAL_OPEN_CHANNEL);
|
||||
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 getDetails_channel_not_found() {
|
||||
assertThatExceptionOfType(NotFoundException.class)
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.model.ChannelStatus;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static de.cotto.lndmanagej.model.ChannelFixtures.CAPACITY;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
import static de.cotto.lndmanagej.model.ChannelPointFixtures.CHANNEL_POINT;
|
||||
import static de.cotto.lndmanagej.model.CoopClosedChannelFixtures.CLOSED_CHANNEL;
|
||||
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL;
|
||||
import static de.cotto.lndmanagej.model.OpenCloseStatus.OPEN;
|
||||
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);
|
||||
|
||||
@Test
|
||||
void channelIdShort() {
|
||||
assertThat(CHANNEL_DTO.channelIdShort()).isEqualTo(String.valueOf(CHANNEL_ID.getShortChannelId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void channelIdCompact() {
|
||||
assertThat(CHANNEL_DTO.channelIdCompact()).isEqualTo(CHANNEL_ID.getCompactForm());
|
||||
}
|
||||
|
||||
@Test
|
||||
void channelIdCompactLnd() {
|
||||
assertThat(CHANNEL_DTO.channelIdCompactLnd()).isEqualTo(CHANNEL_ID.getCompactFormLnd());
|
||||
}
|
||||
|
||||
@Test
|
||||
void channelPoint() {
|
||||
assertThat(CHANNEL_DTO.channelPoint()).isEqualTo(CHANNEL_POINT);
|
||||
}
|
||||
|
||||
@Test
|
||||
void openHeight() {
|
||||
assertThat(CHANNEL_DTO.openHeight()).isEqualTo(CHANNEL_ID.getBlockHeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
void remotePubkey() {
|
||||
assertThat(CHANNEL_DTO.remotePubkey()).isEqualTo(PUBKEY_2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void capacity() {
|
||||
assertThat(CHANNEL_DTO.capacity()).isEqualTo(String.valueOf(CAPACITY.satoshis()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void status() {
|
||||
ChannelDto dto = new ChannelDto(LOCAL_OPEN_CHANNEL);
|
||||
ChannelStatusDto channelStatusDto =
|
||||
ChannelStatusDto.createFrom(new ChannelStatus(false, true, false, OPEN));
|
||||
assertThat(dto.status()).isEqualTo(channelStatusDto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user