-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1874 from rsksmart/fix-rocksdb-startup
Fix node startup when database dir folder is empty
- Loading branch information
Showing
6 changed files
with
49 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
rskj-core/src/test/java/org/ethereum/datasource/NotParameterizedKeyValueDataSourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.ethereum.datasource; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
|
||
public class NotParameterizedKeyValueDataSourceTest { | ||
|
||
@Rule | ||
public TemporaryFolder tempFolder = new TemporaryFolder(); | ||
|
||
@Test | ||
public void testShouldValidateKindWithEmptyDbDirAndResetDbFalseSuccessfully() { | ||
KeyValueDataSource.validateDbKind(DbKind.ROCKS_DB, tempFolder.getRoot().getPath(), false); | ||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void testShouldThrowErrorWhenValidatingDifferentKinds() throws IOException { | ||
FileWriter fileWriter = new FileWriter(new File(tempFolder.getRoot(), KeyValueDataSource.DB_KIND_PROPERTIES_FILE)); | ||
fileWriter.write("keyvalue.datasource=ROCKS_DB\n"); | ||
fileWriter.close(); | ||
KeyValueDataSource.validateDbKind(DbKind.LEVEL_DB, tempFolder.getRoot().getPath(), false); | ||
} | ||
|
||
@Test(expected = IllegalStateException.class) | ||
public void testShouldThrowErrorWhenDbDirIsAFile() throws IOException { | ||
File file = new File(tempFolder.getRoot(), KeyValueDataSource.DB_KIND_PROPERTIES_FILE); | ||
FileWriter fileWriter = new FileWriter(file); | ||
fileWriter.write("keyvalue.datasource=ROCKS_DB\n"); | ||
fileWriter.close(); | ||
KeyValueDataSource.validateDbKind(DbKind.LEVEL_DB, file.getPath(), false); | ||
} | ||
} |