int falsePositives = 0;
for(int i=0;i<TEST_COUNT;i++) {
String test = "test" + i;
ClientCHKBlock block = encodeBlockCHK(test);
ClientCHK key = block.getClientKey();
byte[] routingKey = key.getRoutingKey();
if(saltStore.probablyInStore(routingKey))
falsePositives++;
store.put(block.getBlock(), false);
assertTrue(saltStore.probablyInStore(routingKey));
CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
String data = decodeBlockCHK(verify, key);
assertEquals(test, data);
}
assertTrue(falsePositives <= ACCEPTABLE_FALSE_POSITIVES);
try {
Thread.sleep(2*delay);
} catch (InterruptedException e) {
// Ignore
}
// Abrupt abort. The slots should have been written by now.
saltStore.close(true);
store = new CHKStore();
saltStore = SaltedHashFreenetStore.construct(f, "testCachingFreenetStoreCHK", store, weakPRNG, STORE_SIZE, true, SemiOrderedShutdownHook.get(), true, true, ticker, null);
saltStore.start(null, true);
for(int i=0;i<TEST_COUNT;i++) {
String test = "test" + i;
ClientCHKBlock block = encodeBlockCHK(test);
ClientCHK key = block.getClientKey();
byte[] routingKey = key.getRoutingKey();
assertTrue(saltStore.probablyInStore(routingKey));
CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
String data = decodeBlockCHK(verify, key);
assertEquals(test, data);