add /balance endpoint for nodes

This commit is contained in:
Carsten Otto
2021-11-24 12:52:43 +01:00
parent 30aae170fe
commit 09a57923a5
3 changed files with 28 additions and 3 deletions

View File

@@ -98,7 +98,7 @@ class NodeControllerIT {
}
@Test
void getOpenChannelIds_for_peer() throws Exception {
void getOpenChannelIds() throws Exception {
when(channelService.getOpenChannelsWith(PUBKEY_2)).thenReturn(Set.of(LOCAL_OPEN_CHANNEL, LOCAL_OPEN_CHANNEL_3));
List<String> channelIds = List.of(CHANNEL_ID.toString(), CHANNEL_ID_3.toString());
mockMvc.perform(get(NODE_PREFIX + "/open-channels"))
@@ -106,4 +106,16 @@ class NodeControllerIT {
.andExpect(jsonPath("$.channels", is(channelIds)));
}
@Test
void getBalance() throws Exception {
when(balanceService.getBalanceInformation(PUBKEY_2)).thenReturn(BALANCE_INFORMATION);
mockMvc.perform(get(NODE_PREFIX + "/balance"))
.andExpect(jsonPath("$.localBalance", is("1000")))
.andExpect(jsonPath("$.localReserve", is("100")))
.andExpect(jsonPath("$.localAvailable", is("900")))
.andExpect(jsonPath("$.remoteBalance", is("123")))
.andExpect(jsonPath("$.remoteReserve", is("10")))
.andExpect(jsonPath("$.remoteAvailable", is("113")));
}
}