@Test
public void testBasicChaining() throws Exception {

    // Check that we can plug a few blocks together and the futures work.
    ListenableFuture<StoredBlock> future = testNetChain.getHeightFuture(2);
    // Block 1 from the testnet.
    Block b1 = getBlock1();
    assertTrue(testNetChain.add(b1));
    assertFalse(future.isDone());
    // Block 2 from the testnet.
    Block b2 = getBlock2();
    // Let's try adding an invalid block.
    long n = b2.getNonce();
    try {
        b2.setNonce(12345);
        testNetChain.add(b2);
        fail();
    } catch (VerificationException e) {
        b2.setNonce(n);
    }
    // Now it works because we reset the nonce.
    assertTrue(testNetChain.add(b2));
    assertTrue(future.isDone());
    assertEquals(2, future.get().getHeight());
}