@Test
public void testCompact() throws FailedVerificationException {

	int i = 0;
	OpBlockChain opBlockChain = dbConsensusManager.init(metadataDb);
	generateOperations(formatter, opBlockChain);
	Deque<OpOperation> dequeOperations = opBlockChain.getQueueOperations();
	assertFalse(dequeOperations.isEmpty());
	Set<String> operationsToDelete = new HashSet<>();
	List<OpOperation> addOperation = new ArrayList<>();
	Iterator<OpOperation> iterator = dequeOperations.descendingIterator();
	while (i < 3) {
		OpOperation opOperation = iterator.next();
		operationsToDelete.add(opOperation.getRawHash());
		addOperation.add(opOperation);
		i++;
	}
	int amountLoadedOperations = opBlockChain.getQueueOperations().size();
	OpBlockChain blockchain = new OpBlockChain(opBlockChain.getParent(), opBlockChain.getRules());
	for (OpOperation o : opBlockChain.getQueueOperations()) {
		if (!operationsToDelete.contains(o.getRawHash())) {
			blockchain.addOperation(o);
		}
	}
	opBlockChain = blockchain;
	assertEquals(operationsToDelete.size(), amountLoadedOperations - opBlockChain.getQueueOperations().size());
	OpBlock opBlock = opBlockChain.createBlock(serverName, serverKeyPair);
	opBlock.getOperations().forEach(opOperation -> dbConsensusManager.insertOperation(opOperation));
	assertEquals(opBlock.getOperations().size(), getAmountFromDbByTable(OPERATIONS_TABLE));
	OpBlockChain newBlc = new OpBlockChain(opBlockChain, opBlockChain.getRules());
	addOperation.forEach(newBlc::addOperation);
	opBlock = newBlc.createBlock(serverName, serverKeyPair);
	opBlock.getOperations().forEach(opOperation -> dbConsensusManager.insertOperation(opOperation));
	newBlc = dbConsensusManager.compact(0, newBlc, true);
	assertNotNull(newBlc);
}