add remote pubkey and alias to channel details

This commit is contained in:
Carsten Otto
2021-11-19 17:12:08 +01:00
parent 854786c1e2
commit 840938676e
4 changed files with 37 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ package de.cotto.lndmanagej.controller;
import de.cotto.lndmanagej.metrics.Metrics;
import de.cotto.lndmanagej.service.ChannelService;
import de.cotto.lndmanagej.service.NodeService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
@@ -12,9 +13,12 @@ import java.util.Optional;
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL;
import static de.cotto.lndmanagej.model.NodeFixtures.ALIAS_2;
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(controllers = ChannelDetailsController.class)
@@ -27,6 +31,9 @@ class ChannelDetailsControllerIT {
@MockBean
private ChannelService channelService;
@MockBean
private NodeService nodeService;
@MockBean
@SuppressWarnings("unused")
private Metrics metrics;
@@ -38,9 +45,12 @@ class ChannelDetailsControllerIT {
}
@Test
void details() throws Exception {
void getChannelDetails() throws Exception {
when(nodeService.getAlias(PUBKEY_2)).thenReturn(ALIAS_2);
when(channelService.getLocalChannel(CHANNEL_ID)).thenReturn(Optional.of(LOCAL_OPEN_CHANNEL));
mockMvc.perform(get(CHANNEL_PREFIX + "/details"))
.andExpect(content().json("{\"channelId\":\"" + CHANNEL_ID.getShortChannelId() + "\"}"));
.andExpect(jsonPath("$.channelId", is(String.valueOf(CHANNEL_ID.getShortChannelId()))))
.andExpect(jsonPath("$.remotePubkey", is(PUBKEY_2.toString())))
.andExpect(jsonPath("$.remoteAlias", is(ALIAS_2)));
}
}