warn if peer has no flow for >= 14 days

This commit is contained in:
Carsten Otto
2022-01-14 13:20:22 +01:00
parent 053bda5cba
commit 4e865d5c6f
35 changed files with 545 additions and 161 deletions

View File

@@ -9,10 +9,10 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.MockMvc;
import static de.cotto.lndmanagej.model.NodeWarningsFixtures.NODE_WARNINGS;
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
import static de.cotto.lndmanagej.model.warnings.NodeWarningsFixtures.NODE_WARNINGS;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasSize;
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.jsonPath;
@@ -35,7 +35,11 @@ class WarningsControllerIT {
void getWarningsForNode() throws Exception {
when(nodeWarningsService.getNodeWarnings(PUBKEY)).thenReturn(NODE_WARNINGS);
mockMvc.perform(get(NODE_PREFIX + "/warnings"))
.andExpect(jsonPath("$.nodeWarnings[0].onlinePercentage", is(51)));
.andExpect(jsonPath("$.nodeWarnings", containsInAnyOrder(
"No flow in the past 16 days",
"Node has been online 51% in the last week",
"Node changed between online and offline 123 times"
)));
}
@Test