compute sweep costs

This commit is contained in:
Carsten Otto
2021-12-10 16:23:05 +01:00
parent 3c0fca7d5c
commit df38fdf3e1
27 changed files with 311 additions and 46 deletions

View File

@@ -149,6 +149,7 @@ class ChannelControllerIT {
.andExpect(jsonPath("$.status.openClosed", is("OPEN")))
.andExpect(jsonPath("$.onChainCosts.openCosts", is("1000")))
.andExpect(jsonPath("$.onChainCosts.closeCosts", is("2000")))
.andExpect(jsonPath("$.onChainCosts.sweepCosts", is("3000")))
.andExpect(jsonPath("$.offChainCosts.rebalanceSource", is("1")))
.andExpect(jsonPath("$.offChainCosts.rebalanceTarget", is("2")))
.andExpect(jsonPath("$.balance.localBalance", is("2000")))

View File

@@ -111,6 +111,7 @@ class NodeControllerIT {
.andExpect(jsonPath("$.feeReport.sourced", is("567")))
.andExpect(jsonPath("$.onChainCosts.openCosts", is("1000")))
.andExpect(jsonPath("$.onChainCosts.closeCosts", is("2000")))
.andExpect(jsonPath("$.onChainCosts.sweepCosts", is("3000")))
.andExpect(jsonPath("$.online", is(true)));
}

View File

@@ -41,7 +41,8 @@ class OnChainCostsControllerIT {
when(onChainCostService.getOnChainCostsForPeer(PUBKEY)).thenReturn(ON_CHAIN_COSTS);
mockMvc.perform(get(PEER_PREFIX + "/on-chain-costs"))
.andExpect(jsonPath("$.openCosts", is("1000")))
.andExpect(jsonPath("$.closeCosts", is("2000")));
.andExpect(jsonPath("$.closeCosts", is("2000")))
.andExpect(jsonPath("$.sweepCosts", is("3000")));
}
@Test
@@ -65,10 +66,24 @@ class OnChainCostsControllerIT {
.andExpect(content().string("123"));
}
@Test
void sweep_costs_for_channel() throws Exception {
when(onChainCostService.getSweepCostsForChannelId(CHANNEL_ID)).thenReturn(Optional.of(Coins.ofSatoshis(123)));
mockMvc.perform(get(CHANNEL_PREFIX + "/sweep-costs"))
.andExpect(content().string("123"));
}
@Test
void close_costs_for_channel_unknown() throws Exception {
mockMvc.perform(get(CHANNEL_PREFIX + "/close-costs"))
.andExpect(status().isBadRequest())
.andExpect(content().string("Unable to get close costs for channel with ID " + CHANNEL_ID));
}
@Test
void sweep_costs_channel_unknown() throws Exception {
mockMvc.perform(get(CHANNEL_PREFIX + "/sweep-costs"))
.andExpect(status().isBadRequest())
.andExpect(content().string("Unable to get sweep costs for channel with ID " + CHANNEL_ID));
}
}