Delete temp database after unit test
This commit is contained in:
parent
48d8ca9de2
commit
c82a929d30
|
@ -27,6 +27,7 @@ public class SystemProperties {
|
||||||
private static String DEFAULT_SAMPLES_DIR = "samples";
|
private static String DEFAULT_SAMPLES_DIR = "samples";
|
||||||
private static String DEFAULT_COINBASE_SECRET = "monkey";
|
private static String DEFAULT_COINBASE_SECRET = "monkey";
|
||||||
private static int DEFAULT_ACTIVE_PEER_CHANNEL_TIMEOUT = 5;
|
private static int DEFAULT_ACTIVE_PEER_CHANNEL_TIMEOUT = 5;
|
||||||
|
private static Boolean DEFAULT_DB_RESET = false;
|
||||||
private static Boolean DEFAULT_DUMP_FULL = false;
|
private static Boolean DEFAULT_DUMP_FULL = false;
|
||||||
private static String DEFAULT_DUMP_DIR = "dmp";
|
private static String DEFAULT_DUMP_DIR = "dmp";
|
||||||
private static Boolean DEFAULT_DUMP_CLEAN_ON_RESTART = true;
|
private static Boolean DEFAULT_DUMP_CLEAN_ON_RESTART = true;
|
||||||
|
@ -38,14 +39,14 @@ public class SystemProperties {
|
||||||
public SystemProperties() {
|
public SystemProperties() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File file = null;
|
String userDir = System.getProperty("user.dir");
|
||||||
String dir = System.getProperty("user.dir");
|
System.out.println(userDir);
|
||||||
String fileName = dir + "/config/system.properties";
|
String fileName = userDir + "/config/system.properties";
|
||||||
file = new File(fileName);
|
File file = new File(fileName);
|
||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
input = new FileInputStream(file);
|
input = new FileInputStream(file);
|
||||||
} else{
|
} else {
|
||||||
fileName = "system.properties";
|
fileName = "system.properties";
|
||||||
input = SystemProperties.class.getClassLoader().getResourceAsStream(fileName);
|
input = SystemProperties.class.getClassLoader().getResourceAsStream(fileName);
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
|
@ -101,9 +102,9 @@ public class SystemProperties {
|
||||||
if(prop.isEmpty()) return DEFAULT_DISCOVERY_PORT;
|
if(prop.isEmpty()) return DEFAULT_DISCOVERY_PORT;
|
||||||
return Integer.parseInt(prop.getProperty("peer.discovery.port"));
|
return Integer.parseInt(prop.getProperty("peer.discovery.port"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean databaseReset() {
|
public boolean databaseReset() {
|
||||||
if(prop.isEmpty()) return false;
|
if(prop.isEmpty()) return DEFAULT_DB_RESET;
|
||||||
return Boolean.parseBoolean(prop.getProperty("database.reset"));
|
return Boolean.parseBoolean(prop.getProperty("database.reset"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ public class DatabaseImpl implements Database {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(DatabaseImpl.class);
|
private static Logger logger = LoggerFactory.getLogger(DatabaseImpl.class);
|
||||||
private DB db;
|
private DB db;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public DatabaseImpl(String name) {
|
public DatabaseImpl(String name) {
|
||||||
// Initialize Database
|
// Initialize Database
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
|
@ -22,7 +22,6 @@ import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -156,6 +155,7 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog {
|
||||||
gasInput.setText("1000");
|
gasInput.setText("1000");
|
||||||
|
|
||||||
JComboBox<AccountWrapper> creatorAddressCombo = new JComboBox<AccountWrapper>() {
|
JComboBox<AccountWrapper> creatorAddressCombo = new JComboBox<AccountWrapper>() {
|
||||||
|
private static final long serialVersionUID = -3748305421049121671L;
|
||||||
@Override
|
@Override
|
||||||
public ComboBoxUI getUI() {
|
public ComboBoxUI getUI() {
|
||||||
return super.getUI();
|
return super.getUI();
|
||||||
|
|
|
@ -23,11 +23,11 @@ peer.discovery.port = 30303
|
||||||
#peer.active.ip = 131.104.247.135
|
#peer.active.ip = 131.104.247.135
|
||||||
#peer.active.port = 30303
|
#peer.active.port = 30303
|
||||||
|
|
||||||
# RomanJ general
|
# RomanJ
|
||||||
#peer.active.ip = 54.211.14.10
|
#peer.active.ip = 54.211.14.10
|
||||||
#peer.active.port = 30303
|
#peer.active.port = 30303
|
||||||
|
|
||||||
#poc5.testnet.ethereum.org
|
# PoC-5 testnet
|
||||||
peer.active.ip = 54.72.69.180
|
peer.active.ip = 54.72.69.180
|
||||||
peer.active.port = 30303
|
peer.active.port = 30303
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ samples.dir = samples
|
||||||
# the existing database will be
|
# the existing database will be
|
||||||
# destroyed and all the data will be
|
# destroyed and all the data will be
|
||||||
# downloaded from peers again
|
# downloaded from peers again
|
||||||
database.reset = true
|
database.reset = false
|
||||||
|
|
||||||
# this string is computed
|
# this string is computed
|
||||||
# to be eventually the address
|
# to be eventually the address
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
package org.ethereum.db;
|
package org.ethereum.db;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import static org.iq80.leveldb.impl.Iq80DBFactory.factory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.iq80.leveldb.Options;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
|
|
||||||
|
@ -11,7 +20,7 @@ import org.spongycastle.util.encoders.Hex;
|
||||||
* Created on: 11/06/2014 14:54
|
* Created on: 11/06/2014 14:54
|
||||||
*/
|
*/
|
||||||
public class TrackDatabaseTest {
|
public class TrackDatabaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test1() {
|
public void test1() {
|
||||||
|
|
||||||
|
@ -20,23 +29,33 @@ public class TrackDatabaseTest {
|
||||||
|
|
||||||
trackDatabase1.put(Hex.decode("abcdef"), Hex.decode("abcdef"));
|
trackDatabase1.put(Hex.decode("abcdef"), Hex.decode("abcdef"));
|
||||||
byte[] value = trackDatabase1.get(Hex.decode("abcdef"));
|
byte[] value = trackDatabase1.get(Hex.decode("abcdef"));
|
||||||
Assert.assertEquals("abcdef", Hex.toHexString(value));
|
assertEquals("abcdef", Hex.toHexString(value));
|
||||||
|
|
||||||
trackDatabase1.startTrack();
|
trackDatabase1.startTrack();
|
||||||
trackDatabase1.put(Hex.decode("abcdef"), Hex.decode("ffffff"));
|
trackDatabase1.put(Hex.decode("abcdef"), Hex.decode("ffffff"));
|
||||||
value = trackDatabase1.get(Hex.decode("abcdef"));
|
value = trackDatabase1.get(Hex.decode("abcdef"));
|
||||||
Assert.assertEquals("ffffff", Hex.toHexString(value));
|
assertEquals("ffffff", Hex.toHexString(value));
|
||||||
|
|
||||||
trackDatabase1.rollbackTrack();
|
trackDatabase1.rollbackTrack();
|
||||||
value = trackDatabase1.get(Hex.decode("abcdef"));
|
value = trackDatabase1.get(Hex.decode("abcdef"));
|
||||||
Assert.assertEquals("abcdef", Hex.toHexString(value));
|
assertEquals("abcdef", Hex.toHexString(value));
|
||||||
|
|
||||||
trackDatabase1.startTrack();
|
trackDatabase1.startTrack();
|
||||||
trackDatabase1.put(Hex.decode("abcdef"), Hex.decode("ffffff"));
|
trackDatabase1.put(Hex.decode("abcdef"), Hex.decode("ffffff"));
|
||||||
trackDatabase1.commitTrack();
|
trackDatabase1.commitTrack();
|
||||||
value = trackDatabase1.get(Hex.decode("abcdef"));
|
value = trackDatabase1.get(Hex.decode("abcdef"));
|
||||||
Assert.assertEquals("ffffff", Hex.toHexString(value));
|
assertEquals("ffffff", Hex.toHexString(value));
|
||||||
|
|
||||||
db1.close();
|
db1.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void destroyDB() {
|
||||||
|
try {
|
||||||
|
Options options = new Options();
|
||||||
|
factory.destroy(new File("temp"), options);
|
||||||
|
} catch (IOException e) {
|
||||||
|
fail("Destroying temp-db failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,26 +19,14 @@ peer.discovery.port = 30303
|
||||||
#peer.active.ip = 54.204.10.41
|
#peer.active.ip = 54.204.10.41
|
||||||
#peer.active.port = 30303
|
#peer.active.port = 30303
|
||||||
|
|
||||||
# Some dude in Canada
|
# RomanJ
|
||||||
#peer.active.ip = 131.104.247.135
|
|
||||||
#peer.active.port = 30303
|
|
||||||
|
|
||||||
# Nick
|
|
||||||
#peer.active.ip = 82.217.72.169
|
|
||||||
#peer.active.port = 30303
|
|
||||||
|
|
||||||
|
|
||||||
# RomanJ general
|
|
||||||
peer.active.ip = 54.211.14.10
|
peer.active.ip = 54.211.14.10
|
||||||
peer.active.port = 50505
|
peer.active.port = 50505
|
||||||
|
|
||||||
#poc5.testnet.ethereum.org
|
# PoC-5 testnet
|
||||||
#peer.active.ip = 54.72.69.180
|
#peer.active.ip = 54.72.69.180
|
||||||
#peer.active.port = 30303
|
#peer.active.port = 30303
|
||||||
|
|
||||||
#peer.active.ip = 151.64.223.120
|
|
||||||
#peer.active.port = 30304
|
|
||||||
|
|
||||||
# specify if the mechanism
|
# specify if the mechanism
|
||||||
# to discover more and more
|
# to discover more and more
|
||||||
# peers and check the already
|
# peers and check the already
|
||||||
|
@ -82,7 +70,6 @@ samples.dir = samples
|
||||||
# downloaded from peers again
|
# downloaded from peers again
|
||||||
database.reset = true
|
database.reset = true
|
||||||
|
|
||||||
|
|
||||||
# this string is computed
|
# this string is computed
|
||||||
# to be eventually the address
|
# to be eventually the address
|
||||||
# that get the miner reward
|
# that get the miner reward
|
||||||
|
|
Loading…
Reference in New Issue