mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-22 07:24:23 +01:00
add fee report model
This commit is contained in:
@@ -11,6 +11,7 @@ import de.cotto.lndmanagej.metrics.Metrics;
|
||||
import de.cotto.lndmanagej.model.BalanceInformation;
|
||||
import de.cotto.lndmanagej.model.CloseInitiator;
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import de.cotto.lndmanagej.model.FeeReport;
|
||||
import de.cotto.lndmanagej.model.LocalChannel;
|
||||
import de.cotto.lndmanagej.service.BalanceService;
|
||||
import de.cotto.lndmanagej.service.ChannelService;
|
||||
@@ -49,10 +50,10 @@ class ChannelControllerTest {
|
||||
private static final Coins CLOSE_COSTS = Coins.ofSatoshis(2);
|
||||
private static final OnChainCostsDto ON_CHAIN_COSTS = new OnChainCostsDto(OPEN_COSTS, CLOSE_COSTS);
|
||||
private static final PoliciesDto FEE_CONFIGURATION_DTO = PoliciesDto.createFrom(POLICIES);
|
||||
private static final FeeReportDto FEE_REPORT_DTO =
|
||||
new FeeReportDto(Coins.ofMilliSatoshis(1234), Coins.ofMilliSatoshis(567));
|
||||
private static final ClosedChannelDetailsDto CLOSED_CHANNEL_DETAILS_DTO =
|
||||
new ClosedChannelDetailsDto(CloseInitiator.REMOTE, 987_654);
|
||||
private static final FeeReport FEE_REPORT = new FeeReport(Coins.ofMilliSatoshis(1_234), Coins.ofMilliSatoshis(567));
|
||||
private static final FeeReportDto FEE_REPORT_DTO = FeeReportDto.createFrom(FEE_REPORT);
|
||||
|
||||
@InjectMocks
|
||||
private ChannelController channelController;
|
||||
@@ -83,8 +84,7 @@ class ChannelControllerTest {
|
||||
lenient().when(onChainCostService.getOpenCosts(CHANNEL_ID)).thenReturn(Optional.of(OPEN_COSTS));
|
||||
lenient().when(onChainCostService.getCloseCosts(CHANNEL_ID)).thenReturn(Optional.of(CLOSE_COSTS));
|
||||
lenient().when(policyService.getPolicies(CHANNEL_ID)).thenReturn(POLICIES);
|
||||
lenient().when(feeService.getEarnedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(1_234));
|
||||
lenient().when(feeService.getSourcedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(567));
|
||||
lenient().when(feeService.getFeeReportForChannel(CHANNEL_ID)).thenReturn(FEE_REPORT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -214,8 +214,7 @@ class ChannelControllerTest {
|
||||
|
||||
@Test
|
||||
void getFeeReport() {
|
||||
when(feeService.getEarnedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(1_234));
|
||||
when(feeService.getSourcedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(567));
|
||||
when(feeService.getFeeReportForChannel(CHANNEL_ID)).thenReturn(FEE_REPORT);
|
||||
assertThat(channelController.getFeeReport(CHANNEL_ID)).isEqualTo(FEE_REPORT_DTO);
|
||||
verify(metrics).mark(argThat(name -> name.endsWith(".getFeeReport")));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import de.cotto.lndmanagej.controller.dto.OnChainCostsDto;
|
||||
import de.cotto.lndmanagej.metrics.Metrics;
|
||||
import de.cotto.lndmanagej.model.BalanceInformation;
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import de.cotto.lndmanagej.model.FeeReport;
|
||||
import de.cotto.lndmanagej.model.Node;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import de.cotto.lndmanagej.service.BalanceService;
|
||||
@@ -49,6 +50,8 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class NodeControllerTest {
|
||||
private static final FeeReport FEE_REPORT = new FeeReport(Coins.ofMilliSatoshis(1_234), Coins.ofMilliSatoshis(567));
|
||||
|
||||
@InjectMocks
|
||||
private NodeController nodeController;
|
||||
|
||||
@@ -83,8 +86,7 @@ class NodeControllerTest {
|
||||
when(onChainCostService.getOpenCostsWith(any())).thenReturn(Coins.NONE);
|
||||
when(onChainCostService.getCloseCostsWith(any())).thenReturn(Coins.NONE);
|
||||
when(balanceService.getBalanceInformation(any(Pubkey.class))).thenReturn(BalanceInformation.EMPTY);
|
||||
when(feeService.getEarnedFeesForPeer(any())).thenReturn(Coins.NONE);
|
||||
when(feeService.getSourcedFeesForPeer(any())).thenReturn(Coins.NONE);
|
||||
when(feeService.getFeeReportForPeer(any())).thenReturn(new FeeReport(Coins.NONE, Coins.NONE));
|
||||
NodeDetailsDto expectedDetails = new NodeDetailsDto(
|
||||
PUBKEY_2,
|
||||
ALIAS_2,
|
||||
@@ -119,8 +121,7 @@ class NodeControllerTest {
|
||||
when(onChainCostService.getOpenCostsWith(PUBKEY_2)).thenReturn(openCosts);
|
||||
when(onChainCostService.getCloseCostsWith(PUBKEY_2)).thenReturn(closeCosts);
|
||||
when(balanceService.getBalanceInformation(PUBKEY_2)).thenReturn(BALANCE_INFORMATION);
|
||||
when(feeService.getEarnedFeesForPeer(any())).thenReturn(Coins.ofMilliSatoshis(1234));
|
||||
when(feeService.getSourcedFeesForPeer(any())).thenReturn(Coins.ofMilliSatoshis(567));
|
||||
when(feeService.getFeeReportForPeer(PUBKEY_2)).thenReturn(FEE_REPORT);
|
||||
NodeDetailsDto expectedDetails = new NodeDetailsDto(
|
||||
PUBKEY_2,
|
||||
ALIAS_2,
|
||||
@@ -176,8 +177,7 @@ class NodeControllerTest {
|
||||
|
||||
@Test
|
||||
void getFeeReport() {
|
||||
when(feeService.getEarnedFeesForPeer(PUBKEY)).thenReturn(Coins.ofMilliSatoshis(1_234));
|
||||
when(feeService.getSourcedFeesForPeer(PUBKEY)).thenReturn(Coins.ofMilliSatoshis(567));
|
||||
when(feeService.getFeeReportForPeer(PUBKEY)).thenReturn(FEE_REPORT);
|
||||
assertThat(nodeController.getFeeReport(PUBKEY)).isEqualTo(new FeeReportDto("1234", "567"));
|
||||
verify(metrics).mark(argThat(name -> name.endsWith(".getFeeReport")));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import de.cotto.lndmanagej.model.FeeReport;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -19,4 +20,10 @@ class FeeReportDtoTest {
|
||||
void sourced() {
|
||||
assertThat(FEE_REPORT_DTO.sourced()).isEqualTo("567");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createFrom() {
|
||||
assertThat(FeeReportDto.createFrom(new FeeReport(Coins.ofSatoshis(1), Coins.ofSatoshis(2))))
|
||||
.isEqualTo(new FeeReportDto("1000", "2000"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user