@Test
public void difference() throws InterruptedException {

    IdGeneratorService service = new IdGeneratorService();
    List<Block> originalBlocks = new ArrayList<>();
    long min = 0, max = 0;
    int offset = 0;
    for (int i = 0; i < 10000; i++) {
        long id = service.generate(1);
        int length = random.nextInt(65536);
        originalBlocks.add(new Block(id, Arrays.asList(new BlockElt(id, 0, offset, length, 42))));
        offset += length;
        if (min == 0) {
            min = id;
        }
        max = id;
        Thread.sleep(1);
    }
    SortedMap<Long, Block> blocks = originalBlocks.stream()
            .collect(toMap(Block::getId, Function.<Block>identity(), Utils.throwingMerger(), TreeMap::new));
    SortedMap<Long, Block> blocks2 = originalBlocks.stream()
            .limit(9500)
            .collect(toMap(Block::getId, Function.<Block>identity(), Utils.throwingMerger(), TreeMap::new));
    Range<Long> ranges = Range.openClosed(min - 1, max);
    MerkleTree tree = new MerkleTree(ranges, 64);
    MerkleTree.fillTree(tree, blocks);
    MerkleTree tree2 = new MerkleTree(ranges, 64);
    MerkleTree.fillTree(tree2, blocks2);
    assertEquals(
            MerkleTree.difference(tree, tree2)
                    .stream()
                    .count(),
            4);
}