Skip to content

Commit

Permalink
remove "num_updates" channel warning
Browse files Browse the repository at this point in the history
this should not be an issue anymore starting with lnd 0.15.1 (released in August 2022)

fixes #92
  • Loading branch information
C-Otto committed Feb 14, 2024
1 parent c7c8401 commit 1049eed
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 282 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL;
import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL_TO_NODE_3;
import static de.cotto.lndmanagej.model.warnings.ChannelWarningFixtures.CHANNEL_BALANCE_FLUCTUATION_WARNING;
import static de.cotto.lndmanagej.model.warnings.ChannelWarningFixtures.CHANNEL_NUM_UPDATES_WARNING;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -47,9 +46,9 @@ void getChannelWarnings_for_one_channel_no_warning() {
@Test
void getChannelWarnings_for_one_channel() {
when(provider1.getChannelWarnings(CHANNEL_ID))
.thenReturn(Stream.of(CHANNEL_NUM_UPDATES_WARNING));
.thenReturn(Stream.of(CHANNEL_BALANCE_FLUCTUATION_WARNING));
ChannelWarnings expected = new ChannelWarnings(
CHANNEL_NUM_UPDATES_WARNING
CHANNEL_BALANCE_FLUCTUATION_WARNING
);
assertThat(channelWarningsService.getChannelWarnings(CHANNEL_ID)).isEqualTo(expected);
}
Expand All @@ -69,22 +68,10 @@ void getNodeWarnings_no_warnings() {
@Test
void getChannelWarnings() {
when(channelService.getOpenChannels()).thenReturn(Set.of(LOCAL_OPEN_CHANNEL, LOCAL_OPEN_CHANNEL_TO_NODE_3));
when(provider1.getChannelWarnings(CHANNEL_ID)).thenReturn(Stream.of(CHANNEL_NUM_UPDATES_WARNING));
when(provider1.getChannelWarnings(CHANNEL_ID)).thenReturn(Stream.of(CHANNEL_BALANCE_FLUCTUATION_WARNING));
when(provider1.getChannelWarnings(CHANNEL_ID_4)).thenReturn(Stream.of());
assertThat(channelWarningsService.getChannelWarnings()).containsExactlyInAnyOrderEntriesOf(Map.of(
LOCAL_OPEN_CHANNEL, new ChannelWarnings(CHANNEL_NUM_UPDATES_WARNING)
LOCAL_OPEN_CHANNEL, new ChannelWarnings(CHANNEL_BALANCE_FLUCTUATION_WARNING)
));
}

@Test
void getChannelWarnings_two_different_warnings_for_same_channel() {
when(channelService.getOpenChannels()).thenReturn(Set.of(LOCAL_OPEN_CHANNEL));
when(provider1.getChannelWarnings(CHANNEL_ID)).thenReturn(Stream.of(CHANNEL_NUM_UPDATES_WARNING));
when(provider2.getChannelWarnings(CHANNEL_ID)).thenReturn(Stream.of(CHANNEL_BALANCE_FLUCTUATION_WARNING));
ChannelWarnings expectedWarnings =
new ChannelWarnings(CHANNEL_NUM_UPDATES_WARNING, CHANNEL_BALANCE_FLUCTUATION_WARNING);
assertThat(channelWarningsService.getChannelWarnings()).containsEntry(
LOCAL_OPEN_CHANNEL, expectedWarnings
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ public enum WarningsConfigurationSettings implements ConfigurationSetting {
NODE_FLOW_WARNING_IGNORE_NODE("node_flow_warning_ignore_node"),

NODE_RATING_THRESHOLD("node_rating_threshold"),
NODE_RATING_WARNING_IGNORE_NODE("node_rating_warning_ignore_node"),

MAX_NUM_UPDATES("max_num_updates"),
MAX_NUM_UPDATES_IGNORE_CHANNEL("max_num_updates_warning_ignore_channel");
NODE_RATING_WARNING_IGNORE_NODE("node_rating_warning_ignore_node");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.Set;

import static de.cotto.lndmanagej.configuration.PickhardtPaymentsConfigurationSettings.USE_MISSION_CONTROL;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.MAX_NUM_UPDATES_IGNORE_CHANNEL;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.CHANNEL_FLUCTUATION_WARNING_IGNORE_CHANNEL;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.ONLINE_CHANGES_THRESHOLD;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.ONLINE_WARNING_IGNORE_NODE;
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
Expand Down Expand Up @@ -131,8 +131,9 @@ void getPubkeys_forWarningConfig_twoInConfig() {

@Test
void getChannelIds_not_known_empty() {
Set<ChannelId> channelIds =
configurationService.getChannelIds(MAX_NUM_UPDATES_IGNORE_CHANNEL, channelIdParser::parseFromString);
Set<ChannelId> channelIds = configurationService.getChannelIds(
CHANNEL_FLUCTUATION_WARNING_IGNORE_CHANNEL, channelIdParser::parseFromString
);
assertThat(channelIds).isEmpty();
}

Expand All @@ -143,7 +144,7 @@ void getChannelIds_forWarningConfig_fourInConfig() {
when(channelIdParser.parseFromString(String.valueOf(CHANNEL_ID_3.getShortChannelId())))
.thenReturn(CHANNEL_ID_3);
when(channelIdParser.parseFromString(CHANNEL_POINT.toString())).thenReturn(CHANNEL_ID_4);
WarningsConfigurationSettings config = MAX_NUM_UPDATES_IGNORE_CHANNEL;
WarningsConfigurationSettings config = CHANNEL_FLUCTUATION_WARNING_IGNORE_CHANNEL;
when(iniFileReader.getValues(config.getSection()))
.thenReturn(Map.of(config.getName(),
Set.of(
Expand All @@ -159,7 +160,7 @@ void getChannelIds_forWarningConfig_fourInConfig() {
@Test()
void getChannelIds_forInvalidWarningConfig_error() {
when(channelIdParser.parseFromString("invalid_chan")).thenThrow(new IllegalArgumentException());
WarningsConfigurationSettings config = MAX_NUM_UPDATES_IGNORE_CHANNEL;
WarningsConfigurationSettings config = CHANNEL_FLUCTUATION_WARNING_IGNORE_CHANNEL;
when(iniFileReader.getValues(config.getSection())).thenReturn(Map.of(config.getName(), Set.of("invalid_chan")));
assertThatIllegalArgumentException().isThrownBy(
() -> configurationService.getChannelIds(config, channelIdParser::parseFromString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.CHANNEL_FLUCTUATION_LOWER_THRESHOLD;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.CHANNEL_FLUCTUATION_UPPER_THRESHOLD;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.CHANNEL_FLUCTUATION_WARNING_IGNORE_CHANNEL;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.MAX_NUM_UPDATES;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.MAX_NUM_UPDATES_IGNORE_CHANNEL;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.NODE_FLOW_MAXIMUM_DAYS_TO_CONSIDER;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.NODE_FLOW_MINIMUM_DAYS_FOR_WARNING;
import static de.cotto.lndmanagej.configuration.WarningsConfigurationSettings.NODE_FLOW_WARNING_IGNORE_NODE;
Expand Down Expand Up @@ -39,18 +37,6 @@ void channelFluctuationIgnoreWarning() {
.isEqualTo("channel_fluctuation_warning_ignore_channel");
}

@Test
void maxNumUpdates() {
assertThat(MAX_NUM_UPDATES.getSection()).isEqualTo(SECTION_NAME);
assertThat(MAX_NUM_UPDATES.getName()).isEqualTo("max_num_updates");
}

@Test
void maxNumUpdatesIgnoreChannel() {
assertThat(MAX_NUM_UPDATES_IGNORE_CHANNEL.getSection()).isEqualTo(SECTION_NAME);
assertThat(MAX_NUM_UPDATES_IGNORE_CHANNEL.getName()).isEqualTo("max_num_updates_warning_ignore_channel");
}

@Test
void nodeFlowMinimumDaysForWarning() {
assertThat(NODE_FLOW_MINIMUM_DAYS_FOR_WARNING.getSection()).isEqualTo(SECTION_NAME);
Expand Down
2 changes: 0 additions & 2 deletions example-lnd-manageJ.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ channel_fluctuation_upper_threshold=90
# use this to ignore warnings for one (or more) channel
channel_fluctuation_warning_ignore_channel=732759x1405x0
channel_fluctuation_warning_ignore_channel=123x456:1
max_num_updates=100000
max_num_updates_warning_ignore_channel=732759:1405:0
node_flow_minimum_days_for_warning=30
node_flow_maximum_days_to_consider=90
# use this to ignore warnings for one (or more) peer
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@

import java.util.Set;

import static de.cotto.lndmanagej.model.warnings.ChannelWarningFixtures.CHANNEL_NUM_UPDATES_WARNING;
import static de.cotto.lndmanagej.model.warnings.ChannelWarningFixtures.CHANNEL_BALANCE_FLUCTUATION_WARNING;
import static de.cotto.lndmanagej.model.warnings.ChannelWarningsFixtures.CHANNEL_WARNINGS;
import static org.assertj.core.api.Assertions.assertThat;

class ChannelWarningsTest {
@Test
void warnings() {
assertThat(CHANNEL_WARNINGS.warnings()).containsExactlyInAnyOrder(
CHANNEL_NUM_UPDATES_WARNING
CHANNEL_BALANCE_FLUCTUATION_WARNING
);
}

@Test
void descriptions() {
assertThat(CHANNEL_WARNINGS.descriptions()).containsExactlyInAnyOrder(
CHANNEL_NUM_UPDATES_WARNING.description()
CHANNEL_BALANCE_FLUCTUATION_WARNING.description()
);
}

@Test
void none() {
assertThat(ChannelWarnings.NONE).isEqualTo(new ChannelWarnings(Set.of()));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.cotto.lndmanagej.model.warnings;

public class ChannelWarningFixtures {
public static final ChannelNumUpdatesWarning CHANNEL_NUM_UPDATES_WARNING = new ChannelNumUpdatesWarning(101_000L);
public static final ChannelBalanceFluctuationWarning CHANNEL_BALANCE_FLUCTUATION_WARNING =
new ChannelBalanceFluctuationWarning(2, 97, 7);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.cotto.lndmanagej.model.warnings;

import static de.cotto.lndmanagej.model.warnings.ChannelWarningFixtures.CHANNEL_NUM_UPDATES_WARNING;
import static de.cotto.lndmanagej.model.warnings.ChannelWarningFixtures.CHANNEL_BALANCE_FLUCTUATION_WARNING;

public class ChannelWarningsFixtures {
public static final ChannelWarnings CHANNEL_WARNINGS = new ChannelWarnings(
CHANNEL_NUM_UPDATES_WARNING
CHANNEL_BALANCE_FLUCTUATION_WARNING
);
}
Loading

0 comments on commit 1049eed

Please sign in to comment.