@Test
@Ignore("Ignored due to a missing feature. "
    + "A feature to buffer blocks that come out of order should be implemented on neow3j lib.")
public void testCatchUpToLatestAndSubscribeToNewBlockObservable_NotContinuousBlocks()
    throws Exception {

    List<NeoGetBlock> expected = Arrays.asList(
        createBlock(0),
        createBlock(1),
        createBlock(2),
        createBlock(3),
        createBlock(4),
        createBlock(5),
        createBlock(6)
    );
    NeoGetBlock block7 = createBlock(7);
    List<NeoGetBlock> neoGetBlocks = Arrays.asList(
        // past blocks:
        expected.get(0),
        expected.get(1),
        expected.get(2),
        expected.get(3),
        // later blocks:
        expected.get(4),
        // missing expected.get(5)
        expected.get(6),
        block7
    );
    OngoingStubbing<NeoGetBlock> stubbingNeoGetBlock =
        when(neow3jService.send(any(Request.class), eq(NeoGetBlock.class)));
    for (int i = 0; i < 7; i++) {
        stubbingNeoGetBlock = stubbingNeoGetBlock.thenReturn(neoGetBlocks.get(i));
    }
    OngoingStubbing<NeoBlockCount> stubbingNeoBlockCount =
        when(neow3jService.send(any(Request.class), eq(NeoBlockCount.class)));
    NeoBlockCount neoBlockCount = new NeoBlockCount();
    BigInteger currentBlock = BigInteger.valueOf(4);
    neoBlockCount.setResult(currentBlock);
    stubbingNeoBlockCount.thenReturn(neoBlockCount);
    Observable<NeoGetBlock> observable = neow3j
        .catchUpToLatestAndSubscribeToNewBlocksObservable(
            new BlockParameterIndex(BigInteger.ZERO),
            false);
    CountDownLatch transactionLatch = new CountDownLatch(expected.size());
    CountDownLatch completedLatch = new CountDownLatch(1);
    List<NeoGetBlock> results = new ArrayList<>(expected.size());
    Disposable disposable = observable.subscribe(
        result -> {
            results.add(result);
            transactionLatch.countDown();
            System.out.println("TransactionLatch countDown");
            System.out.println(result.getBlock());
        },
        throwable -> fail(throwable.getMessage()),
        () -> {
            System.out.println("Completed");
            completedLatch.countDown();
        });
    for (int i = 4; i < 7; i++) {
        Thread.sleep(2000);
        BigInteger added = BigInteger.valueOf(neoGetBlocks.get(i).getBlock().getIndex());
        neoBlockCount.setResult(added);
        stubbingNeoBlockCount = stubbingNeoBlockCount.thenReturn(neoBlockCount);
    }
    transactionLatch.await(15250, TimeUnit.MILLISECONDS);
    assertThat(results.size(), equalTo(expected.size()));
    assertThat(results, new ReflectionEquals(expected));
    disposable.dispose();
    completedLatch.await(1, TimeUnit.SECONDS);
    assertTrue(disposable.isDisposed());
}