From 87a3e6ac30563160486a7fb9c6b732c64784ab58 Mon Sep 17 00:00:00 2001 From: Angel Soto Date: Mon, 5 Feb 2024 18:05:57 +0100 Subject: [PATCH] adding extra tests --- .../rsk/config/RskSystemPropertiesTest.java | 37 +++++++++++++++++++ ...DiscoveredPeersPersistenceServiceTest.java | 3 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/rskj-core/src/test/java/co/rsk/config/RskSystemPropertiesTest.java b/rskj-core/src/test/java/co/rsk/config/RskSystemPropertiesTest.java index ea11a101fab..737d20e9d5e 100644 --- a/rskj-core/src/test/java/co/rsk/config/RskSystemPropertiesTest.java +++ b/rskj-core/src/test/java/co/rsk/config/RskSystemPropertiesTest.java @@ -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()); + } + } diff --git a/rskj-core/src/test/java/co/rsk/net/discovery/DiscoveredPeersPersistenceServiceTest.java b/rskj-core/src/test/java/co/rsk/net/discovery/DiscoveredPeersPersistenceServiceTest.java index 02ad6364601..7f331899454 100644 --- a/rskj-core/src/test/java/co/rsk/net/discovery/DiscoveredPeersPersistenceServiceTest.java +++ b/rskj-core/src/test/java/co/rsk/net/discovery/DiscoveredPeersPersistenceServiceTest.java @@ -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)); + } } \ No newline at end of file