Skip to content

Commit

Permalink
adding extra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asoto-iov committed Feb 5, 2024
1 parent c9695c6 commit 87a3e6a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
37 changes: 37 additions & 0 deletions rskj-core/src/test/java/co/rsk/config/RskSystemPropertiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,41 @@ void testPeerLastSession() throws IOException {

assertEquals(expectedPeers, actualPeers);
}

@Test
void checkPeerLastSessionProperty(){
TestSystemProperties testSystemProperties = new TestSystemProperties(rawConfig ->
ConfigFactory.parseString("{" +
"peer {\n" +
" usePeersFromLastSession = true\n" +
"}" +
" }").withFallback(rawConfig));

assertTrue(testSystemProperties.usePeersFromLastSession());

testSystemProperties = new TestSystemProperties(rawConfig ->
ConfigFactory.parseString("{" +
"peer {\n" +
" usePeersFromLastSession = false\n" +
"}" +
" }").withFallback(rawConfig));
assertFalse(testSystemProperties.usePeersFromLastSession());

testSystemProperties = new TestSystemProperties();

assertFalse(testSystemProperties.usePeersFromLastSession());
}

@Test
void checkLastSessionPeersFilePathProperty(){
TestSystemProperties testSystemProperties = new TestSystemProperties(rawConfig ->
ConfigFactory.parseString("{" +
"database {\n" +
" dir = \"/dbdir\"\n" +
"}" +
" }").withFallback(rawConfig));

assertEquals("/dbdir/lastKnewPeers.txt", testSystemProperties.getLastKnewPeersFilePath().toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ void testStop() throws IOException {

service.stop();

verify(fileDataSaver, times(1)).saveDataIntoFile(anyString(), any(Path.class));
verify(fileDataSaver, times(1)).saveDataIntoFile(eq("peer1\npeer2\npeer3\n"), eq(filePath));

}

}

0 comments on commit 87a3e6a

Please sign in to comment.