@Test
public void startBlockChainDownload() throws Exception {

    Block b1 = createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS).block;
    blockChain.add(b1);
    Block b2 = makeSolvedTestBlock(b1);
    blockChain.add(b2);
    connect();
    fail.set(true);
    peer.addChainDownloadStartedEventListener(Threading.SAME_THREAD, new ChainDownloadStartedEventListener() {
        @Override
        public void onChainDownloadStarted(Peer p, int blocksLeft) {
            if (p == peer && blocksLeft == 108)
                fail.set(false);
        }
    });
    peer.startBlockChainDownload();
    List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
    expectedLocator.add(b2.getHash());
    expectedLocator.add(b1.getHash());
    expectedLocator.add(PARAMS.getGenesisBlock().getHash());
    GetBlocksMessage message = (GetBlocksMessage) outbound(writeTarget);
    assertEquals(message.getLocator(), expectedLocator);
    assertEquals(Sha256Hash.ZERO_HASH, message.getStopHash());
}