mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-29 10:54:18 +01:00
add missing information to peer fee report
This commit is contained in:
@@ -43,8 +43,8 @@ public class RebalanceService {
|
||||
getAmountFromPeer(pubkey),
|
||||
getTargetCostsForPeer(pubkey),
|
||||
getAmountToPeer(pubkey),
|
||||
Coins.NONE,
|
||||
Coins.NONE
|
||||
getSupportAsSourceAmountFromPeer(pubkey),
|
||||
getSupportAsTargetAmountToPeer(pubkey)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,34 @@ class RebalanceServiceTest {
|
||||
assertThat(rebalanceService.getReportForPeer(PUBKEY)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRebalanceReportForPeer_supportAsSource() {
|
||||
RebalanceReport expected = new RebalanceReport(
|
||||
FEE_FOR_TWO_REBALANCES,
|
||||
AMOUNT_FOR_TWO_REBALANCES,
|
||||
Coins.NONE,
|
||||
Coins.NONE,
|
||||
Coins.ofMilliSatoshis(123),
|
||||
Coins.NONE
|
||||
);
|
||||
mockSupportAsSourceForPeer();
|
||||
assertThat(rebalanceService.getReportForPeer(PUBKEY)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRebalanceReportForPeer_supportAsTarget() {
|
||||
RebalanceReport expected = new RebalanceReport(
|
||||
Coins.NONE,
|
||||
Coins.NONE,
|
||||
Coins.ofMilliSatoshis(20),
|
||||
Coins.ofMilliSatoshis(246),
|
||||
Coins.NONE,
|
||||
Coins.ofMilliSatoshis(123)
|
||||
);
|
||||
mockSupportAsTargetForPeer();
|
||||
assertThat(rebalanceService.getReportForPeer(PUBKEY)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSourceCostsForChannel() {
|
||||
mockSelfPaymentsFromChannel(CHANNEL_ID.toString());
|
||||
@@ -275,12 +303,7 @@ class RebalanceServiceTest {
|
||||
|
||||
@Test
|
||||
void getSupportAsSourceAmountFromPeer() {
|
||||
when(channelService.getAllChannelsWith(PUBKEY)).thenReturn(Set.of(CLOSED_CHANNEL));
|
||||
when(selfPaymentsService.getSelfPaymentsFromChannel(CHANNEL_ID)).thenReturn(List.of(
|
||||
getSelfPayment("from " + CHANNEL_ID, 0),
|
||||
getSelfPayment("from: " + CHANNEL_ID, 1),
|
||||
getSelfPayment("to: " + CHANNEL_ID_2, 2)
|
||||
));
|
||||
mockSupportAsSourceForPeer();
|
||||
assertThat(rebalanceService.getSupportAsSourceAmountFromPeer(PUBKEY)).isEqualTo(AMOUNT_PAID);
|
||||
}
|
||||
|
||||
@@ -296,12 +319,7 @@ class RebalanceServiceTest {
|
||||
|
||||
@Test
|
||||
void getSupportAsTargetAmountToPeer() {
|
||||
when(channelService.getAllChannelsWith(PUBKEY)).thenReturn(Set.of(CLOSED_CHANNEL_2));
|
||||
when(selfPaymentsService.getSelfPaymentsToChannel(CHANNEL_ID_2)).thenReturn(List.of(
|
||||
getSelfPayment("from " + CHANNEL_ID, 0),
|
||||
getSelfPayment("to " + CHANNEL_ID_2, 1),
|
||||
getSelfPayment("to " + CHANNEL_ID_2, 2)
|
||||
));
|
||||
mockSupportAsTargetForPeer();
|
||||
assertThat(rebalanceService.getSupportAsTargetAmountToPeer(PUBKEY)).isEqualTo(AMOUNT_PAID);
|
||||
}
|
||||
|
||||
@@ -379,4 +397,22 @@ class RebalanceServiceTest {
|
||||
when(selfPaymentsService.getSelfPaymentsFromChannel(id1)).thenReturn(List.of(selfPayment1));
|
||||
when(selfPaymentsService.getSelfPaymentsFromChannel(id2)).thenReturn(List.of(selfPayment2));
|
||||
}
|
||||
|
||||
private void mockSupportAsSourceForPeer() {
|
||||
when(channelService.getAllChannelsWith(PUBKEY)).thenReturn(Set.of(CLOSED_CHANNEL));
|
||||
when(selfPaymentsService.getSelfPaymentsFromChannel(CHANNEL_ID)).thenReturn(List.of(
|
||||
getSelfPayment("from " + CHANNEL_ID, 0),
|
||||
getSelfPayment("from: " + CHANNEL_ID, 1),
|
||||
getSelfPayment("to: " + CHANNEL_ID_2, 2)
|
||||
));
|
||||
}
|
||||
|
||||
private void mockSupportAsTargetForPeer() {
|
||||
when(channelService.getAllChannelsWith(PUBKEY)).thenReturn(Set.of(CLOSED_CHANNEL_2));
|
||||
when(selfPaymentsService.getSelfPaymentsToChannel(CHANNEL_ID_2)).thenReturn(List.of(
|
||||
getSelfPayment("from " + CHANNEL_ID, 0),
|
||||
getSelfPayment("to " + CHANNEL_ID_2, 1),
|
||||
getSelfPayment("to " + CHANNEL_ID_2, 2)
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user