@Test
public void testReplayBlocksDescendingObservable() throws Exception {

    List<NeoGetBlock> neoGetBlocks = Arrays
        .asList(createBlock(2), createBlock(1), createBlock(0));
    OngoingStubbing<NeoGetBlock> stubbing =
        when(neow3jService.send(any(Request.class), eq(NeoGetBlock.class)));
    for (NeoGetBlock neoGetBlock : neoGetBlocks) {
        stubbing = stubbing.thenReturn(neoGetBlock);
    }
    Observable<NeoGetBlock> observable = neow3j.replayBlocksObservable(
        new BlockParameterIndex(BigInteger.ZERO),
        new BlockParameterIndex(BigInteger.valueOf(2)),
        false,
        false);
    CountDownLatch transactionLatch = new CountDownLatch(neoGetBlocks.size());
    CountDownLatch completedLatch = new CountDownLatch(1);
    List<NeoGetBlock> results = new ArrayList<>(neoGetBlocks.size());
    Disposable disposable = observable.subscribe(
        result -> {
            results.add(result);
            transactionLatch.countDown();
        },
        throwable -> fail(throwable.getMessage()),
        () -> completedLatch.countDown());
    // just to be in the safe side, we add a timeout
    completedLatch.await(5, TimeUnit.SECONDS);
    assertThat(results, equalTo(neoGetBlocks));
    disposable.dispose();
    assertTrue(disposable.isDisposed());
    assertThat(transactionLatch.getCount(), is(0L));
}