Program: 85968
Project: 85968
Buggy source:
@Test public void fastCatchup() throws Exception {
  Block b1=TestUtils.createFakeBlock(unitTestParams,blockStore).block;
  blockChain.add(b1);
  Utils.rollMockClock(60 * 10);
  Block b2=TestUtils.makeSolvedTestBlock(unitTestParams,b1);
  Utils.rollMockClock(60 * 10);
  Block b3=TestUtils.makeSolvedTestBlock(unitTestParams,b2);
  Utils.rollMockClock(60 * 10);
  Block b4=TestUtils.makeSolvedTestBlock(unitTestParams,b3);
  conn.setVersionMessageForHeight(unitTestParams,4);
  peer.setFastCatchupTime((Utils.now().getTime() / 1000) - (600 * 2) + 1);
  runPeerAsync(peer,conn);
  peer.startBlockChainDownload();
  GetHeadersMessage getheaders=(GetHeadersMessage)conn.outbound();
  List<Sha256Hash> expectedLocator=new ArrayList<Sha256Hash>();
  expectedLocator.add(b1.getHash());
  expectedLocator.add(b1.getPrevBlockHash());
  expectedLocator.add(unitTestParams.genesisBlock.getHash());
  assertEquals(getheaders.getLocator(),expectedLocator);
  assertEquals(getheaders.getStopHash(),Sha256Hash.ZERO_HASH);
  HeadersMessage headers=new HeadersMessage(unitTestParams,b2.cloneAsHeader(),b3.cloneAsHeader(),b4.cloneAsHeader());
  expectedLocator.clear();
  expectedLocator.add(b2.getHash());
  expectedLocator.add(b1.getHash());
  expectedLocator.add(unitTestParams.genesisBlock.getHash());
  GetBlocksMessage getblocks=(GetBlocksMessage)conn.exchange(headers);
  assertEquals(expectedLocator,getblocks.getLocator());
  assertEquals(b3.getHash(),getblocks.getStopHash());
  InventoryMessage inv=new InventoryMessage(unitTestParams);
  inv.addItem(new InventoryItem(InventoryItem.Type.Block,b3.getHash()));
  GetDataMessage getdata=(GetDataMessage)conn.exchange(inv);
  assertEquals(b3.getHash(),getdata.getItems().get(0).hash);
  assertEquals(null,conn.exchange(b3));
}

Fixed version (ground truth):
@Test public void fastCatchup() throws Exception {
  Block b1=TestUtils.createFakeBlock(unitTestParams,blockStore).block;
  blockChain.add(b1);
  Utils.rollMockClock(60 * 10);
  Block b2=TestUtils.makeSolvedTestBlock(unitTestParams,b1);
  Utils.rollMockClock(60 * 10);
  Block b3=TestUtils.makeSolvedTestBlock(unitTestParams,b2);
  Utils.rollMockClock(60 * 10);
  Block b4=TestUtils.makeSolvedTestBlock(unitTestParams,b3);
  conn.setVersionMessageForHeight(unitTestParams,4);
  peer.setFastCatchupTime((Utils.now().getTime() / 1000) - (600 * 2) + 1);
  runPeerAsync(peer,conn);
  peer.startBlockChainDownload();
  GetHeadersMessage getheaders=(GetHeadersMessage)conn.outbound();
  List<Sha256Hash> expectedLocator=new ArrayList<Sha256Hash>();
  expectedLocator.add(b1.getHash());
  expectedLocator.add(unitTestParams.genesisBlock.getHash());
  assertEquals(getheaders.getLocator(),expectedLocator);
  assertEquals(getheaders.getStopHash(),Sha256Hash.ZERO_HASH);
  HeadersMessage headers=new HeadersMessage(unitTestParams,b2.cloneAsHeader(),b3.cloneAsHeader(),b4.cloneAsHeader());
  expectedLocator.clear();
  expectedLocator.add(b2.getHash());
  expectedLocator.add(b1.getHash());
  expectedLocator.add(unitTestParams.genesisBlock.getHash());
  GetBlocksMessage getblocks=(GetBlocksMessage)conn.exchange(headers);
  assertEquals(expectedLocator,getblocks.getLocator());
  assertEquals(b3.getHash(),getblocks.getStopHash());
  InventoryMessage inv=new InventoryMessage(unitTestParams);
  inv.addItem(new InventoryItem(InventoryItem.Type.Block,b3.getHash()));
  GetDataMessage getdata=(GetDataMessage)conn.exchange(inv);
  assertEquals(b3.getHash(),getdata.getItems().get(0).hash);
  assertEquals(null,conn.exchange(b3));
}