mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-22 15:35:10 +01:00
add "sourced" fees to fee report
This commit is contained in:
@@ -49,7 +49,8 @@ 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));
|
||||
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);
|
||||
|
||||
@@ -83,6 +84,7 @@ class ChannelControllerTest {
|
||||
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));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -212,8 +214,9 @@ class ChannelControllerTest {
|
||||
|
||||
@Test
|
||||
void getFeeReport() {
|
||||
when(feeService.getEarnedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofSatoshis(123));
|
||||
assertThat(channelController.getFeeReport(CHANNEL_ID)).isEqualTo(new FeeReportDto(Coins.ofSatoshis(123)));
|
||||
when(feeService.getEarnedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(1_234));
|
||||
when(feeService.getSourcedFeesForChannel(CHANNEL_ID)).thenReturn(Coins.ofMilliSatoshis(567));
|
||||
assertThat(channelController.getFeeReport(CHANNEL_ID)).isEqualTo(FEE_REPORT_DTO);
|
||||
verify(metrics).mark(argThat(name -> name.endsWith(".getFeeReport")));
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ class NodeControllerTest {
|
||||
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);
|
||||
NodeDetailsDto expectedDetails = new NodeDetailsDto(
|
||||
PUBKEY_2,
|
||||
ALIAS_2,
|
||||
@@ -94,7 +95,7 @@ class NodeControllerTest {
|
||||
new OnChainCostsDto(Coins.NONE, Coins.NONE),
|
||||
BalanceInformationDto.createFrom(BalanceInformation.EMPTY),
|
||||
true,
|
||||
new FeeReportDto("0")
|
||||
new FeeReportDto("0", "0")
|
||||
);
|
||||
when(nodeService.getNode(PUBKEY_2)).thenReturn(new Node(PUBKEY_2, ALIAS_2, 0, true));
|
||||
|
||||
@@ -119,6 +120,7 @@ class NodeControllerTest {
|
||||
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));
|
||||
NodeDetailsDto expectedDetails = new NodeDetailsDto(
|
||||
PUBKEY_2,
|
||||
ALIAS_2,
|
||||
@@ -129,7 +131,7 @@ class NodeControllerTest {
|
||||
new OnChainCostsDto(openCosts, closeCosts),
|
||||
BalanceInformationDto.createFrom(BALANCE_INFORMATION),
|
||||
false,
|
||||
new FeeReportDto("1234")
|
||||
new FeeReportDto("1234", "567")
|
||||
);
|
||||
|
||||
assertThat(nodeController.getDetails(PUBKEY_2)).isEqualTo(expectedDetails);
|
||||
@@ -175,7 +177,8 @@ class NodeControllerTest {
|
||||
@Test
|
||||
void getFeeReport() {
|
||||
when(feeService.getEarnedFeesForPeer(PUBKEY)).thenReturn(Coins.ofMilliSatoshis(1_234));
|
||||
assertThat(nodeController.getFeeReport(PUBKEY)).isEqualTo(new FeeReportDto("1234"));
|
||||
when(feeService.getSourcedFeesForPeer(PUBKEY)).thenReturn(Coins.ofMilliSatoshis(567));
|
||||
assertThat(nodeController.getFeeReport(PUBKEY)).isEqualTo(new FeeReportDto("1234", "567"));
|
||||
verify(metrics).mark(argThat(name -> name.endsWith(".getFeeReport")));
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ 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 FeeReportDto FEE_REPORT =
|
||||
new FeeReportDto(Coins.ofMilliSatoshis(1234), Coins.ofMilliSatoshis(567));
|
||||
private static final ChannelDetailsDto CHANNEL_DETAILS_DTO = new ChannelDetailsDto(
|
||||
CLOSED_CHANNEL,
|
||||
ALIAS,
|
||||
@@ -27,7 +29,7 @@ class ChannelDetailsDtoTest {
|
||||
ON_CHAIN_COSTS,
|
||||
PoliciesDto.EMPTY,
|
||||
CLOSE_DETAILS,
|
||||
new FeeReportDto(Coins.ofMilliSatoshis(1234))
|
||||
FEE_REPORT
|
||||
);
|
||||
|
||||
@Test
|
||||
@@ -84,7 +86,7 @@ class ChannelDetailsDtoTest {
|
||||
ON_CHAIN_COSTS,
|
||||
PoliciesDto.EMPTY,
|
||||
CLOSE_DETAILS,
|
||||
new FeeReportDto(Coins.ofMilliSatoshis(1234))
|
||||
FEE_REPORT
|
||||
);
|
||||
ChannelStatusDto channelStatusDto =
|
||||
ChannelStatusDto.createFrom(new ChannelStatus(false, true, false, OPEN));
|
||||
@@ -103,7 +105,7 @@ class ChannelDetailsDtoTest {
|
||||
|
||||
@Test
|
||||
void feeReport() {
|
||||
assertThat(CHANNEL_DETAILS_DTO.feeReport()).isEqualTo(new FeeReportDto(Coins.ofMilliSatoshis(1_234)));
|
||||
assertThat(CHANNEL_DETAILS_DTO.feeReport()).isEqualTo(FEE_REPORT);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,8 +6,17 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class FeeReportDtoTest {
|
||||
|
||||
private static final FeeReportDto FEE_REPORT_DTO =
|
||||
new FeeReportDto(Coins.ofMilliSatoshis(1_234), Coins.ofMilliSatoshis(567));
|
||||
|
||||
@Test
|
||||
void earned() {
|
||||
assertThat(new FeeReportDto(Coins.ofMilliSatoshis(1_234)).earned()).isEqualTo("1234");
|
||||
assertThat(FEE_REPORT_DTO.earned()).isEqualTo("1234");
|
||||
}
|
||||
|
||||
@Test
|
||||
void sourced() {
|
||||
assertThat(FEE_REPORT_DTO.sourced()).isEqualTo("567");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user