Search in sources :

Example 1 with PreflightCheckException

use of co.rsk.util.PreflightCheckException in project rskj by rsksmart.

the class StartTest method nodeIsNotRunning_WhenRunNodeAndPreflightCheckFails_ThenNodeRunnerShouldNotRun.

@Test
public void nodeIsNotRunning_WhenRunNodeAndPreflightCheckFails_ThenNodeRunnerShouldNotRun() throws Exception {
    Runtime runtime = mock(Runtime.class);
    NodeRunner runner = mock(NodeRunner.class);
    RskContext ctx = mock(RskContext.class);
    doReturn(runner).when(ctx).getNodeRunner();
    PreflightChecksUtils preflightChecks = mock(PreflightChecksUtils.class);
    doThrow(new PreflightCheckException("test")).when(preflightChecks).runChecks();
    try {
        Start.runNode(runtime, preflightChecks, ctx);
        fail("runNode should throw an exception");
    } catch (PreflightCheckException e) {
        assertEquals("test", e.getMessage());
        verify(preflightChecks, times(1)).runChecks();
        verify(runner, never()).run();
        verify(runtime, never()).addShutdownHook(any());
    }
}
Also used : PreflightCheckException(co.rsk.util.PreflightCheckException) PreflightChecksUtils(co.rsk.util.PreflightChecksUtils) Test(org.junit.Test)

Aggregations

PreflightCheckException (co.rsk.util.PreflightCheckException)1 PreflightChecksUtils (co.rsk.util.PreflightChecksUtils)1 Test (org.junit.Test)1