add "sourced" fees to fee report

This commit is contained in:
Carsten Otto
2021-11-30 13:26:41 +01:00
parent 75b17b6072
commit beca0a2aaa
14 changed files with 111 additions and 18 deletions

View File

@@ -127,6 +127,7 @@ class ChannelControllerIT {
when(onChainCostService.getCloseCosts(CHANNEL_ID)).thenReturn(Optional.of(Coins.ofSatoshis(2000)));
when(balanceService.getBalanceInformation(CHANNEL_ID)).thenReturn(Optional.of(BALANCE_INFORMATION_2));
when(feeService.getEarnedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(1_234));
when(feeService.getSourcedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(567));
mockMvc.perform(get(DETAILS_PREFIX))
.andExpect(jsonPath("$.channelIdShort", is(String.valueOf(CHANNEL_ID.getShortChannelId()))))
.andExpect(jsonPath("$.channelIdCompact", is(CHANNEL_ID.getCompactForm())))
@@ -157,13 +158,15 @@ class ChannelControllerIT {
.andExpect(jsonPath("$.policies.local.baseFeeMilliSat", is(10)))
.andExpect(jsonPath("$.policies.remote.feeRatePpm", is(222)))
.andExpect(jsonPath("$.policies.remote.baseFeeMilliSat", is(0)))
.andExpect(jsonPath("$.feeReport.earned", is("1234")));
.andExpect(jsonPath("$.feeReport.earned", is("1234")))
.andExpect(jsonPath("$.feeReport.sourced", is("567")));
}
@Test
void getChannelDetails_closed_channel() throws Exception {
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(CLOSED_CHANNEL));
when(feeService.getEarnedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.NONE);
when(feeService.getSourcedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.NONE);
mockMvc.perform(get(DETAILS_PREFIX))
.andExpect(jsonPath("$.closeDetails.initiator", is("REMOTE")))
.andExpect(jsonPath("$.closeDetails.height", is(987_654)))
@@ -225,7 +228,9 @@ class ChannelControllerIT {
@Test
void getFeeReport() throws Exception {
when(feeService.getEarnedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(1_234));
when(feeService.getSourcedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(567));
mockMvc.perform(get(CHANNEL_PREFIX + "/fee-report"))
.andExpect(jsonPath("$.earned", is("1234")));
.andExpect(jsonPath("$.earned", is("1234")))
.andExpect(jsonPath("$.sourced", is("567")));
}
}

View File

@@ -85,6 +85,7 @@ class NodeControllerIT {
when(onChainCostService.getCloseCostsWith(PUBKEY_2)).thenReturn(Coins.ofSatoshis(456));
when(balanceService.getBalanceInformation(PUBKEY_2)).thenReturn(BALANCE_INFORMATION);
when(feeService.getEarnedFeesForPeer(PUBKEY_2)).thenReturn(Coins.ofMilliSatoshis(1_234));
when(feeService.getSourcedFeesForPeer(PUBKEY_2)).thenReturn(Coins.ofMilliSatoshis(567));
List<String> channelIds = List.of(CHANNEL_ID.toString(), CHANNEL_ID_2.toString());
List<String> closedChannelIds = List.of(CHANNEL_ID.toString(), CHANNEL_ID_3.toString());
List<String> waitingCloseChannelIds = List.of(CHANNEL_ID.toString());
@@ -105,6 +106,7 @@ class NodeControllerIT {
.andExpect(jsonPath("$.balance.remoteReserve", is("10")))
.andExpect(jsonPath("$.balance.remoteAvailable", is("113")))
.andExpect(jsonPath("$.feeReport.earned", is("1234")))
.andExpect(jsonPath("$.feeReport.sourced", is("567")))
.andExpect(jsonPath("$.online", is(true)));
}
@@ -141,7 +143,9 @@ class NodeControllerIT {
@Test
void getFeeReport() throws Exception {
when(feeService.getEarnedFeesForPeer(PUBKEY_2)).thenReturn(Coins.ofMilliSatoshis(1_234));
when(feeService.getSourcedFeesForPeer(PUBKEY_2)).thenReturn(Coins.ofMilliSatoshis(567));
mockMvc.perform(get(NODE_PREFIX + "/fee-report"))
.andExpect(jsonPath("$.earned", is("1234")));
.andExpect(jsonPath("$.earned", is("1234")))
.andExpect(jsonPath("$.sourced", is("567")));
}
}