do not return duplicate pubkeys

This commit is contained in:
Carsten Otto
2021-11-12 13:38:06 +01:00
parent 2ec2ecce9a
commit b8f9af1d72
2 changed files with 15 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_2;
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_3;
import static de.cotto.lndmanagej.model.LocalChannelFixtures.LOCAL_CHANNEL;
import static de.cotto.lndmanagej.model.LocalChannelFixtures.LOCAL_CHANNEL_2;
import static de.cotto.lndmanagej.model.LocalChannelFixtures.LOCAL_CHANNEL_3;
import static de.cotto.lndmanagej.model.NodeFixtures.ALIAS;
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
@@ -79,4 +80,17 @@ class LegacyControllerTest {
when(channelService.getOpenChannels()).thenReturn(Set.of(LOCAL_CHANNEL, channel2));
assertThat(legacyController.getPeerPubkeys()).isEqualTo(PUBKEY_2 + "\n" + PUBKEY_3);
}
@Test
void getPeerPubkeys_sorted() {
LocalChannel channel2 = new LocalChannel(ChannelFixtures.create(PUBKEY, PUBKEY_3, CHANNEL_ID_2), PUBKEY);
when(channelService.getOpenChannels()).thenReturn(Set.of(channel2, LOCAL_CHANNEL));
assertThat(legacyController.getPeerPubkeys()).isEqualTo(PUBKEY_2 + "\n" + PUBKEY_3);
}
@Test
void getPeerPubkeys_without_duplicates() {
when(channelService.getOpenChannels()).thenReturn(Set.of(LOCAL_CHANNEL, LOCAL_CHANNEL_2));
assertThat(legacyController.getPeerPubkeys()).isEqualTo(PUBKEY_2.toString());
}
}