add fee-configuration endpoint for channel

This commit is contained in:
Carsten Otto
2021-11-24 12:40:40 +01:00
parent 7ac9230adc
commit 30aae170fe
5 changed files with 54 additions and 14 deletions

View File

@@ -124,6 +124,19 @@ class ChannelControllerTest {
assertThat(channelController.getDetails(CHANNEL_ID)).isEqualTo(expectedDetails);
}
@Test
void getFeeConfiguration() {
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(LOCAL_OPEN_CHANNEL));
when(feeService.getFeeConfiguration(CHANNEL_ID)).thenReturn(FEE_CONFIGURATION);
assertThat(channelController.getFeeConfiguration(CHANNEL_ID)).isEqualTo(FEE_CONFIGURATION_DTO);
verify(metrics).mark(argThat(name -> name.endsWith(".getFeeConfiguration")));
}
@Test
void getFeeConfiguration_waiting_close() {
assertThat(channelController.getFeeConfiguration(CHANNEL_ID)).isEqualTo(FeeConfigurationDto.EMPTY);
}
private ChannelDetailsDto mockForChannelWithoutFeeConfiguration(LocalChannel channel) {
when(nodeService.getAlias(PUBKEY_2)).thenReturn(ALIAS_2);
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(channel));
@@ -133,7 +146,7 @@ class ChannelControllerTest {
ALIAS_2,
BalanceInformation.EMPTY,
ON_CHAIN_COSTS,
new FeeConfigurationDto(0, 0, 0, 0)
FeeConfigurationDto.EMPTY
);
}
}

View File

@@ -18,10 +18,13 @@ 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 FeeConfigurationDto FEE_CONFIGURATION_DTO =
new FeeConfigurationDto(0, 0, 0, 0);
private static final ChannelDetailsDto CHANNEL_DETAILS_DTO =
new ChannelDetailsDto(CLOSED_CHANNEL, ALIAS, BALANCE_INFORMATION, ON_CHAIN_COSTS, FEE_CONFIGURATION_DTO);
private static final ChannelDetailsDto CHANNEL_DETAILS_DTO = new ChannelDetailsDto(
CLOSED_CHANNEL,
ALIAS,
BALANCE_INFORMATION,
ON_CHAIN_COSTS,
FeeConfigurationDto.EMPTY
);
@Test
void channelIdShort() {
@@ -70,7 +73,7 @@ class ChannelDetailsDtoTest {
ALIAS,
BALANCE_INFORMATION,
ON_CHAIN_COSTS,
FEE_CONFIGURATION_DTO
FeeConfigurationDto.EMPTY
);
ChannelStatusDto channelStatusDto =
ChannelStatusDto.createFrom(new ChannelStatus(false, true, false, OPEN));