mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 23:03:04 +00:00
Test importing first 100K of blocks.
This commit is contained in:
parent
68e6228356
commit
f9ebf56047
@ -45,7 +45,7 @@ import java.util.NoSuchElementException;
|
||||
* try { chain.add(block); } catch (Exception e) { }<br>
|
||||
* }</p>
|
||||
*/
|
||||
public class BlockFileLoader implements Iterator<Block> {
|
||||
public class BlockFileLoader implements Iterable<Block>, Iterator<Block> {
|
||||
/**
|
||||
* Gets the list of files which contain blocks from the Satoshi client.
|
||||
*/
|
||||
@ -164,4 +164,9 @@ public class BlockFileLoader implements Iterator<Block> {
|
||||
public void remove() throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Block> iterator() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,10 @@ package com.google.bitcoin.core;
|
||||
|
||||
import com.google.bitcoin.core.Transaction.SigHash;
|
||||
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.After;
|
||||
import org.junit.Before;
|
||||
@ -29,9 +31,10 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@ -175,4 +178,16 @@ public class FullPrunedBlockChainTest {
|
||||
throw new RuntimeException(e); // Cannot happen.
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirst100KBlocks() throws BlockStoreException, VerificationException, PrunedException {
|
||||
NetworkParameters params = NetworkParameters.prodNet();
|
||||
File blockFile = new File(getClass().getResource("first-100k-blocks.dat").getFile());
|
||||
BlockFileLoader loader = new BlockFileLoader(params, Arrays.asList(new File[] {blockFile}));
|
||||
|
||||
store = new MemoryFullPrunedBlockStore(params, 10);
|
||||
chain = new FullPrunedBlockChain(params, store);
|
||||
for (Block block : loader)
|
||||
chain.add(block);
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user