### Question:
SPVBlockStore implements BlockStore { @Override public void close() throws BlockStoreException { try { buffer.force(); buffer = null; blockCache.clear(); randomAccessFile.close(); blockCache.clear(); } catch (IOException e) { throw new BlockStoreException(e); } } SPVBlockStore(NetworkParameters params, File file);  SPVBlockStore(NetworkParameters params, File file, int capacity, boolean grow); static final int getFileSize(int capacity); @Override void put(StoredBlock block); @Override @Nullable StoredBlock get(Sha256Hash hash); @Override StoredBlock getChainHead(); @Override void setChainHead(StoredBlock chainHead); @Override void close(); @Override NetworkParameters getParams(); @Nullable StoredBlock get(int blockHeight); static final int DEFAULT_CAPACITY; static final String HEADER_MAGIC; }### Answer:
@Test public void twoStores_butSequentially() throws Exception { SPVBlockStore store = new SPVBlockStore(UNITTEST, blockStoreFile); store.close(); store = new SPVBlockStore(UNITTEST, blockStoreFile); }
@Test(expected = BlockStoreException.class) public void twoStores_sequentially_butMismatchingCapacity() throws Exception { SPVBlockStore store = new SPVBlockStore(UNITTEST, blockStoreFile, 10, false); store.close(); store = new SPVBlockStore(UNITTEST, blockStoreFile, 20, false); }
@Test(expected = BlockStoreException.class) public void twoStores_sequentially_shrink() throws Exception { SPVBlockStore store = new SPVBlockStore(UNITTEST, blockStoreFile, 20, true); store.close(); store = new SPVBlockStore(UNITTEST, blockStoreFile, 10, true); }