package org.ethereum.db;

import org.junit.Before;
import org.junit.Test;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

/**
 * @author Mikhail Kalinin
 * @since 07.07.2015
 */
public class HashStoreTest {

    private List<byte[]> hashes = new ArrayList<>();

    @Before
    public void setup() {
        Random rnd = new Random(System.currentTimeMillis());
        for(int i = 0; i < 100; i++) {
            byte[] hash = new byte[32];
            rnd.nextBytes(hash);
            hashes.add(hash);
        }
    }

    @Test
    public void test() throws InstantiationException, IllegalAccessException {
        BigInteger bi = new BigInteger(32, new Random());
        String testDb = "test_db_" + bi;

        HashStore hashStore = new HashStore.Builder()
                .withName(testDb)
                .build();

        hashes.forEach(hashStore::add);

        assertArrayEquals(hashes.get(0), hashStore.peek());
        hashes.forEach((hash) -> assertArrayEquals(hash, hashStore.poll()));
        assertEquals(true, hashStore.isEmpty());
        assertNull(hashStore.peek());
        assertNull(hashStore.poll());

        hashStore.close();
    }
}

@@ -1023,31 +1023,56 @@
         
-hashes.forEach(
+for(byte%5B%5D hash : hashes) %7B%0A            
 hashStor
@@ -1076,16 +1076,29 @@
 tore
-::add);%0A
+.add(hash);%0A        %7D
 %0A   
@@ -1166,32 +1166,47 @@
     
-hashes.forEach((hash) -%3E
+for(byte%5B%5D hash : hashes) %7B%0A           
  ass
@@ -1243,18 +1243,27 @@
 .poll())
-)
 ;
+%0A        %7D
 %0A       

Downgrade from 1.8 to 1.7 in HashStoreTest