Program: 85669
Project: 85669
Buggy source:
@Test public void serializeDownloadBlockWithWallet() throws Exception {
  unitTestParams=UnitTestParams.get();
  Block block=new Block(unitTestParams,HEX.decode("String_Node_Str"));
  FilteredBlock filteredBlock=new FilteredBlock(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(block.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertTrue(filteredBlock.getHash().equals(block.getHash()));
  List<Sha256Hash> txHashList=filteredBlock.getTransactionHashes();
  assertTrue(txHashList.size() == 4);
  Transaction tx0=new Transaction(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(tx0.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertEquals(tx0.getHash(),txHashList.get(0));
  Transaction tx1=new Transaction(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(tx1.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertEquals(tx1.getHash(),txHashList.get(1));
  Transaction tx2=new Transaction(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(tx2.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertEquals(tx2.getHash(),txHashList.get(2));
  Transaction tx3=new Transaction(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(tx3.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertEquals(tx3.getHash(),txHashList.get(3));
  KeyChainGroup group=new KeyChainGroup(unitTestParams);
  group.importKeys(ECKey.fromPublicOnly(HEX.decode("String_Node_Str")),ECKey.fromPublicOnly(HEX.decode("String_Node_Str")),ECKey.fromPublicOnly(HEX.decode("String_Node_Str")),ECKey.fromPublicOnly(HEX.decode("String_Node_Str")));
  Wallet wallet=new Wallet(unitTestParams,group);
  BloomFilter filter=wallet.getBloomFilter(wallet.getKeychainSize() * 2,0.001,0xDEADBEEF);
  assertTrue(Arrays.equals(filter.bitcoinSerialize(),HEX.decode("String_Node_Str")));
  blockStore=new MemoryBlockStore(UnitTestParams.get());
  blockStore.put(new StoredBlock(new Block(unitTestParams,HEX.decode("String_Node_Str")),BigInteger.valueOf(1),100000));
  blockStore.setChainHead(blockStore.get(new Sha256Hash("String_Node_Str")));
  super.setUp(blockStore);
  peerGroup.addWallet(wallet);
  blockChain.addWallet(wallet);
  peerGroup.startAsync();
  peerGroup.awaitRunning();
  InboundMessageQueuer p1=connectPeer(1);
  assertEquals(1,peerGroup.numConnectedPeers());
  InventoryMessage inv=new InventoryMessage(unitTestParams);
  inv.addBlock(block);
  inbound(p1,inv);
  Object getData=outbound(p1);
  assertTrue(getData instanceof GetDataMessage);
  assertTrue(((GetDataMessage)getData).getItems().size() == 1);
  assertTrue(((GetDataMessage)getData).getItems().get(0).hash.equals(block.getHash()));
  assertTrue(((GetDataMessage)getData).getItems().get(0).type == InventoryItem.Type.FilteredBlock);
  Object ping=outbound(p1);
  assertTrue(ping instanceof Ping);
  inbound(p1,filteredBlock);
  inbound(p1,tx0);
  inbound(p1,tx1);
  inbound(p1,tx2);
  inbound(p1,tx3);
  inbound(p1,new Pong(((Ping)ping).getNonce()));
  pingAndWait(p1);
  Set<Transaction> transactions=wallet.getTransactions(false);
  assertTrue(transactions.size() == 4);
  for (  Transaction tx : transactions) {
    assertTrue(tx.getConfidence().getConfidenceType() == ConfidenceType.BUILDING);
    assertTrue(tx.getConfidence().getDepthInBlocks() == 1);
    assertTrue(tx.getAppearsInHashes().keySet().contains(block.getHash()));
    assertTrue(tx.getAppearsInHashes().size() == 1);
  }
  closePeer(peerOf(p1));
  peerGroup.stopAsync();
  super.tearDown();
}

Fixed version (ground truth):
@Test public void serializeDownloadBlockWithWallet() throws Exception {
  unitTestParams=UnitTestParams.get();
  Block block=new Block(unitTestParams,HEX.decode("String_Node_Str"));
  FilteredBlock filteredBlock=new FilteredBlock(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(block.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertTrue(filteredBlock.getHash().equals(block.getHash()));
  List<Sha256Hash> txHashList=filteredBlock.getTransactionHashes();
  assertTrue(txHashList.size() == 4);
  Transaction tx0=new Transaction(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(tx0.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertEquals(tx0.getHash(),txHashList.get(0));
  Transaction tx1=new Transaction(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(tx1.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertEquals(tx1.getHash(),txHashList.get(1));
  Transaction tx2=new Transaction(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(tx2.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertEquals(tx2.getHash(),txHashList.get(2));
  Transaction tx3=new Transaction(unitTestParams,HEX.decode("String_Node_Str"));
  assertTrue(tx3.getHash().equals(new Sha256Hash("String_Node_Str")));
  assertEquals(tx3.getHash(),txHashList.get(3));
  KeyChainGroup group=new KeyChainGroup(unitTestParams);
  group.importKeys(ECKey.fromPublicOnly(HEX.decode("String_Node_Str")),ECKey.fromPublicOnly(HEX.decode("String_Node_Str")),ECKey.fromPublicOnly(HEX.decode("String_Node_Str")),ECKey.fromPublicOnly(HEX.decode("String_Node_Str")));
  Wallet wallet=new Wallet(unitTestParams,group);
  BloomFilter filter=wallet.getBloomFilter(wallet.getKeychainSize() * 2,0.001,0xDEADBEEF);
  assertTrue(Arrays.equals(filter.bitcoinSerialize(),HEX.decode("String_Node_Str")));
  blockStore=new MemoryBlockStore(UnitTestParams.get());
  blockStore.put(new StoredBlock(new Block(unitTestParams,HEX.decode("String_Node_Str")),BigInteger.valueOf(1),100000));
  blockStore.setChainHead(blockStore.get(new Sha256Hash("String_Node_Str")));
  super.setUp(blockStore);
  peerGroup.addWallet(wallet);
  peerGroup.setUseLocalhostPeerWhenPossible(false);
  blockChain.addWallet(wallet);
  peerGroup.startAsync();
  peerGroup.awaitRunning();
  InboundMessageQueuer p1=connectPeer(1);
  assertEquals(1,peerGroup.numConnectedPeers());
  InventoryMessage inv=new InventoryMessage(unitTestParams);
  inv.addBlock(block);
  inbound(p1,inv);
  Object getData=outbound(p1);
  assertTrue(getData instanceof GetDataMessage);
  assertTrue(((GetDataMessage)getData).getItems().size() == 1);
  assertTrue(((GetDataMessage)getData).getItems().get(0).hash.equals(block.getHash()));
  assertTrue(((GetDataMessage)getData).getItems().get(0).type == InventoryItem.Type.FilteredBlock);
  Object ping=outbound(p1);
  assertTrue(ping instanceof Ping);
  inbound(p1,filteredBlock);
  inbound(p1,tx0);
  inbound(p1,tx1);
  inbound(p1,tx2);
  inbound(p1,tx3);
  inbound(p1,new Pong(((Ping)ping).getNonce()));
  pingAndWait(p1);
  Set<Transaction> transactions=wallet.getTransactions(false);
  assertTrue(transactions.size() == 4);
  for (  Transaction tx : transactions) {
    assertTrue(tx.getConfidence().getConfidenceType() == ConfidenceType.BUILDING);
    assertTrue(tx.getConfidence().getDepthInBlocks() == 1);
    assertTrue(tx.getAppearsInHashes().keySet().contains(block.getHash()));
    assertTrue(tx.getAppearsInHashes().size() == 1);
  }
  closePeer(peerOf(p1));
  peerGroup.stopAsync();
  super.tearDown();
}