mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 15:22:16 +00:00
H2 is now being exercised more thoroughly and was leaving test db files hanging around that would cause the next run to fail, fix.
Rename method/clean up a bit.
This commit is contained in:
parent
f46dc809e4
commit
f4def39f40
@ -22,7 +22,6 @@ import com.google.bitcoin.params.UnitTestParams;
|
||||
import com.google.bitcoin.script.Script;
|
||||
import com.google.bitcoin.store.BlockStoreException;
|
||||
import com.google.bitcoin.store.FullPrunedBlockStore;
|
||||
import com.google.bitcoin.store.MemoryFullPrunedBlockStore;
|
||||
import com.google.bitcoin.utils.BlockFileLoader;
|
||||
import com.google.bitcoin.utils.BriefLogFormatter;
|
||||
import org.junit.Before;
|
||||
@ -58,7 +57,7 @@ public abstract class AbstractFullPrunedBlockChainTest
|
||||
};
|
||||
}
|
||||
|
||||
public abstract FullPrunedBlockStore createStoreFromParamsAndBlockCount(NetworkParameters params, int blockCount)
|
||||
public abstract FullPrunedBlockStore createStore(NetworkParameters params, int blockCount)
|
||||
throws BlockStoreException;
|
||||
|
||||
public abstract void resetStore(FullPrunedBlockStore store) throws BlockStoreException;
|
||||
@ -69,7 +68,7 @@ public abstract class AbstractFullPrunedBlockChainTest
|
||||
FullBlockTestGenerator generator = new FullBlockTestGenerator(params);
|
||||
RuleList blockList = generator.getBlocksToTest(false, false, null);
|
||||
|
||||
store = createStoreFromParamsAndBlockCount(params, blockList.maximumReorgBlockCount);
|
||||
store = createStore(params, blockList.maximumReorgBlockCount);
|
||||
resetStore(store);
|
||||
chain = new FullPrunedBlockChain(params, store);
|
||||
|
||||
@ -112,7 +111,7 @@ public abstract class AbstractFullPrunedBlockChainTest
|
||||
|
||||
@Test
|
||||
public void skipScripts() throws Exception {
|
||||
store = createStoreFromParamsAndBlockCount(params, 10);
|
||||
store = createStore(params, 10);
|
||||
resetStore(store);
|
||||
chain = new FullPrunedBlockChain(params, store);
|
||||
|
||||
@ -149,7 +148,7 @@ public abstract class AbstractFullPrunedBlockChainTest
|
||||
@Test
|
||||
public void testFinalizedBlocks() throws Exception {
|
||||
final int UNDOABLE_BLOCKS_STORED = 10;
|
||||
store = createStoreFromParamsAndBlockCount(params, UNDOABLE_BLOCKS_STORED);
|
||||
store = createStore(params, UNDOABLE_BLOCKS_STORED);
|
||||
resetStore(store);
|
||||
chain = new FullPrunedBlockChain(params, store);
|
||||
|
||||
@ -207,7 +206,7 @@ public abstract class AbstractFullPrunedBlockChainTest
|
||||
File blockFile = new File(getClass().getResource("first-100k-blocks.dat").getFile());
|
||||
BlockFileLoader loader = new BlockFileLoader(params, Arrays.asList(blockFile));
|
||||
|
||||
store = createStoreFromParamsAndBlockCount(params, 10);
|
||||
store = createStore(params, 10);
|
||||
resetStore(store);
|
||||
chain = new FullPrunedBlockChain(params, store);
|
||||
for (Block block : loader)
|
||||
|
@ -3,21 +3,36 @@ package com.google.bitcoin.core;
|
||||
import com.google.bitcoin.store.BlockStoreException;
|
||||
import com.google.bitcoin.store.FullPrunedBlockStore;
|
||||
import com.google.bitcoin.store.H2FullPrunedBlockStore;
|
||||
import org.junit.After;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* An H2 implementation of the FullPrunedBlockStoreTest
|
||||
*/
|
||||
public class H2FullPrunedBlockChainTest extends AbstractFullPrunedBlockChainTest
|
||||
{
|
||||
@Override
|
||||
public FullPrunedBlockStore createStoreFromParamsAndBlockCount(NetworkParameters params, int blockCount) throws BlockStoreException
|
||||
{
|
||||
return new H2FullPrunedBlockStore(params, "test.h2", blockCount);
|
||||
public class H2FullPrunedBlockChainTest extends AbstractFullPrunedBlockChainTest {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
deleteFiles();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetStore(FullPrunedBlockStore store) throws BlockStoreException
|
||||
{
|
||||
public FullPrunedBlockStore createStore(NetworkParameters params, int blockCount) throws BlockStoreException {
|
||||
deleteFiles();
|
||||
return new H2FullPrunedBlockStore(params, "test", blockCount);
|
||||
}
|
||||
|
||||
private void deleteFiles() {
|
||||
maybeDelete("test.h2.db");
|
||||
maybeDelete("test.trace.db");
|
||||
}
|
||||
|
||||
private void maybeDelete(String s) {
|
||||
new File(s).delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetStore(FullPrunedBlockStore store) throws BlockStoreException {
|
||||
((H2FullPrunedBlockStore)store).resetStore();
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import com.google.bitcoin.store.MemoryFullPrunedBlockStore;
|
||||
public class MemoryFullPrunedBlockChainTest extends AbstractFullPrunedBlockChainTest
|
||||
{
|
||||
@Override
|
||||
public FullPrunedBlockStore createStoreFromParamsAndBlockCount(NetworkParameters params, int blockCount) throws BlockStoreException
|
||||
public FullPrunedBlockStore createStore(NetworkParameters params, int blockCount) throws BlockStoreException
|
||||
{
|
||||
return new MemoryFullPrunedBlockStore(params, blockCount);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class PostgresFullPrunedBlockChainTest extends AbstractFullPrunedBlockCha
|
||||
private static final String DB_PASSWORD = "password";
|
||||
|
||||
@Override
|
||||
public FullPrunedBlockStore createStoreFromParamsAndBlockCount(NetworkParameters params, int blockCount)
|
||||
public FullPrunedBlockStore createStore(NetworkParameters params, int blockCount)
|
||||
throws BlockStoreException {
|
||||
return new PostgresFullPrunedBlockStore(params, blockCount, DB_HOSTNAME, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user