add model for on chain costs

This commit is contained in:
Carsten Otto
2021-12-10 14:24:26 +01:00
parent 5858a84ef9
commit 3c0fca7d5c
20 changed files with 234 additions and 125 deletions

View File

@@ -10,6 +10,7 @@ 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.OnChainCosts;
import de.cotto.lndmanagej.model.Pubkey;
import de.cotto.lndmanagej.service.BalanceService;
import de.cotto.lndmanagej.service.ChannelService;
@@ -81,8 +82,7 @@ class NodeControllerTest {
@Test
void getNodeDetails_no_channels() {
when(onChainCostService.getOpenCostsWith(any())).thenReturn(Coins.NONE);
when(onChainCostService.getCloseCostsWith(any())).thenReturn(Coins.NONE);
when(onChainCostService.getOnChainCostsForPeer(any())).thenReturn(OnChainCosts.NONE);
when(offChainCostService.getRebalanceSourceCostsForPeer(any())).thenReturn(Coins.NONE);
when(offChainCostService.getRebalanceTargetCostsForPeer(any())).thenReturn(Coins.NONE);
when(balanceService.getBalanceInformationForPeer(any(Pubkey.class))).thenReturn(BalanceInformation.EMPTY);
@@ -94,7 +94,7 @@ class NodeControllerTest {
List.of(),
List.of(),
List.of(),
new OnChainCostsDto(Coins.NONE, Coins.NONE),
OnChainCostsDto.createFromModel(OnChainCosts.NONE),
new OffChainCostsDto(Coins.NONE, Coins.NONE),
BalanceInformationDto.createFromModel(BalanceInformation.EMPTY),
true,
@@ -116,12 +116,13 @@ class NodeControllerTest {
when(channelService.getForceClosingChannelsWith(PUBKEY_2)).thenReturn(
Set.of(FORCE_CLOSING_CHANNEL, FORCE_CLOSING_CHANNEL_2, FORCE_CLOSING_CHANNEL_3)
);
Coins openCosts = Coins.ofSatoshis(123);
Coins closeCosts = Coins.ofSatoshis(456);
OnChainCosts onChainCosts = new OnChainCosts(
Coins.ofSatoshis(123),
Coins.ofSatoshis(456)
);
Coins rebalanceSourceCosts = Coins.ofMilliSatoshis(1);
Coins rebalanceTargetCosts = Coins.ofMilliSatoshis(2);
when(onChainCostService.getOpenCostsWith(PUBKEY_2)).thenReturn(openCosts);
when(onChainCostService.getCloseCostsWith(PUBKEY_2)).thenReturn(closeCosts);
when(onChainCostService.getOnChainCostsForPeer(PUBKEY_2)).thenReturn(onChainCosts);
when(offChainCostService.getRebalanceSourceCostsForPeer(PUBKEY_2)).thenReturn(rebalanceSourceCosts);
when(offChainCostService.getRebalanceTargetCostsForPeer(PUBKEY_2)).thenReturn(rebalanceTargetCosts);
when(balanceService.getBalanceInformationForPeer(PUBKEY_2)).thenReturn(BALANCE_INFORMATION);
@@ -133,7 +134,7 @@ class NodeControllerTest {
List.of(CHANNEL_ID_2, CHANNEL_ID_3),
List.of(CHANNEL_ID, CHANNEL_ID_2),
List.of(CHANNEL_ID, CHANNEL_ID_2, CHANNEL_ID_3),
new OnChainCostsDto(openCosts, closeCosts),
OnChainCostsDto.createFromModel(onChainCosts),
new OffChainCostsDto(rebalanceSourceCosts, rebalanceTargetCosts),
BalanceInformationDto.createFromModel(BALANCE_INFORMATION),
false,