mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-22 15:35:10 +01:00
compute sweep costs
This commit is contained in:
@@ -47,9 +47,10 @@ import static org.mockito.Mockito.when;
|
||||
class ChannelControllerTest {
|
||||
private static final Coins OPEN_COSTS = Coins.ofSatoshis(1);
|
||||
private static final Coins CLOSE_COSTS = Coins.ofSatoshis(2);
|
||||
private static final Coins SWEEP_COSTS = Coins.ofSatoshis(3);
|
||||
private static final Coins SOURCE_COSTS = Coins.ofSatoshis(3);
|
||||
private static final Coins TARGET_COSTS = Coins.ofSatoshis(4);
|
||||
private static final OnChainCosts ON_CHAIN_COSTS = new OnChainCosts(OPEN_COSTS, CLOSE_COSTS);
|
||||
private static final OnChainCosts ON_CHAIN_COSTS = new OnChainCosts(OPEN_COSTS, CLOSE_COSTS, SWEEP_COSTS);
|
||||
private static final OffChainCostsDto OFF_CHAIN_COSTS = new OffChainCostsDto(SOURCE_COSTS, TARGET_COSTS);
|
||||
private static final PoliciesDto FEE_CONFIGURATION_DTO = PoliciesDto.createFromModel(POLICIES);
|
||||
private static final ClosedChannelDetailsDto CLOSED_CHANNEL_DETAILS_DTO =
|
||||
|
||||
@@ -118,7 +118,8 @@ class NodeControllerTest {
|
||||
);
|
||||
OnChainCosts onChainCosts = new OnChainCosts(
|
||||
Coins.ofSatoshis(123),
|
||||
Coins.ofSatoshis(456)
|
||||
Coins.ofSatoshis(456),
|
||||
Coins.ofSatoshis(789)
|
||||
);
|
||||
Coins rebalanceSourceCosts = Coins.ofMilliSatoshis(1);
|
||||
Coins rebalanceTargetCosts = Coins.ofMilliSatoshis(2);
|
||||
|
||||
@@ -60,4 +60,18 @@ class OnChainCostsControllerTest {
|
||||
() -> onChainCostsController.getCloseCostsForChannel(CHANNEL_ID)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSweepCostsForChannel() throws CostException {
|
||||
Coins coins = Coins.ofSatoshis(123);
|
||||
when(onChainCostService.getSweepCostsForChannelId(CHANNEL_ID)).thenReturn(Optional.of(coins));
|
||||
assertThat(onChainCostsController.getSweepCostsForChannel(CHANNEL_ID)).isEqualTo(coins.satoshis());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSweepCostsForChannel_unknown() {
|
||||
assertThatExceptionOfType(CostException.class).isThrownBy(
|
||||
() -> onChainCostsController.getSweepCostsForChannel(CHANNEL_ID)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ChannelDetailsDtoTest {
|
||||
|
||||
private static final OnChainCosts ON_CHAIN_COSTS = new OnChainCosts(Coins.ofSatoshis(1), Coins.ofSatoshis(2));
|
||||
private static final OnChainCosts ON_CHAIN_COSTS =
|
||||
new OnChainCosts(Coins.ofSatoshis(1), Coins.ofSatoshis(2), Coins.ofSatoshis(3));
|
||||
private static final OffChainCostsDto OFF_CHAIN_COSTS =
|
||||
new OffChainCostsDto(Coins.ofSatoshis(3), Coins.ofSatoshis(4));
|
||||
private static final ClosedChannelDetailsDto CLOSE_DETAILS = new ClosedChannelDetailsDto("abc", 123);
|
||||
|
||||
@@ -9,6 +9,6 @@ class OnChainCostsDtoTest {
|
||||
@Test
|
||||
void createFromModel() {
|
||||
assertThat(OnChainCostsDto.createFromModel(ON_CHAIN_COSTS))
|
||||
.isEqualTo(new OnChainCostsDto("1000", "2000"));
|
||||
.isEqualTo(new OnChainCostsDto("1000", "2000", "3000"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user