Program: 85878
Project: 85878
Buggy source:
@Test public void transactionConfidence() throws Exception {
  final Transaction[] event=new Transaction[2];
  peerGroup.addEventListener(new AbstractPeerEventListener(){
    @Override public void onTransaction(    Peer peer,    Transaction t){
      event[0]=t;
    }
  }
);
  FakeChannel p1=connectPeer(1);
  FakeChannel p2=connectPeer(2);
  FakeChannel p3=connectPeer(3);
  Transaction tx=TestUtils.createFakeTx(params,Utils.toNanoCoins(20,0),address);
  InventoryMessage inv=new InventoryMessage(params);
  inv.addTransaction(tx);
  inbound(p2,inv);
  assertTrue(outbound(p2) instanceof BloomFilter);
  assertTrue(outbound(p2) instanceof GetDataMessage);
  assertEquals(0,tx.getConfidence().numBroadcastPeers());
  assertTrue(peerGroup.getMemoryPool().maybeWasSeen(tx.getHash()));
  assertNull(event[0]);
  inbound(p1,inv);
  assertTrue(outbound(p1) instanceof BloomFilter);
  assertNull(outbound(p1));
  inbound(p2,tx);
  assertNull(outbound(p2));
  tx=event[0];
  assertNotNull(tx);
  event[0]=null;
  inbound(p1,inv);
  inbound(p1,tx);
  assertEquals(2,tx.getConfidence().numBroadcastPeers());
  assertTrue(tx.getConfidence().wasBroadcastBy(peerOf(p1).getAddress()));
  assertTrue(tx.getConfidence().wasBroadcastBy(peerOf(p2).getAddress()));
  tx.getConfidence().addEventListener(new TransactionConfidence.Listener(){
    public void onConfidenceChanged(    Transaction tx){
      event[1]=tx;
    }
  }
);
  inbound(p3,inv);
  assertEquals(tx,event[1]);
  assertEquals(3,tx.getConfidence().numBroadcastPeers());
  assertTrue(tx.getConfidence().wasBroadcastBy(peerOf(p3).getAddress()));
}

Fixed version (ground truth):
@Test public void transactionConfidence() throws Exception {
  final Transaction[] event=new Transaction[2];
  peerGroup.addEventListener(new AbstractPeerEventListener(){
    @Override public void onTransaction(    Peer peer,    Transaction t){
      event[0]=t;
    }
  }
);
  FakeChannel p1=connectPeer(1);
  FakeChannel p2=connectPeer(2);
  FakeChannel p3=connectPeer(3);
  Transaction tx=TestUtils.createFakeTx(params,Utils.toNanoCoins(20,0),address);
  InventoryMessage inv=new InventoryMessage(params);
  inv.addTransaction(tx);
  inbound(p2,inv);
  assertTrue(outbound(p2) instanceof BloomFilter);
  assertTrue(outbound(p2) instanceof GetDataMessage);
  assertEquals(0,tx.getConfidence().numBroadcastPeers());
  assertTrue(peerGroup.getMemoryPool().maybeWasSeen(tx.getHash()));
  assertNull(event[0]);
  inbound(p1,inv);
  assertTrue(outbound(p1) instanceof BloomFilter);
  assertNull(outbound(p1));
  inbound(p2,tx);
  assertTrue(outbound(p2) instanceof GetDataMessage);
  tx=event[0];
  assertNotNull(tx);
  event[0]=null;
  inbound(p1,inv);
  inbound(p1,tx);
  assertEquals(2,tx.getConfidence().numBroadcastPeers());
  assertTrue(tx.getConfidence().wasBroadcastBy(peerOf(p1).getAddress()));
  assertTrue(tx.getConfidence().wasBroadcastBy(peerOf(p2).getAddress()));
  tx.getConfidence().addEventListener(new TransactionConfidence.Listener(){
    public void onConfidenceChanged(    Transaction tx){
      event[1]=tx;
    }
  }
);
  inbound(p3,inv);
  assertEquals(tx,event[1]);
  assertEquals(3,tx.getConfidence().numBroadcastPeers());
  assertTrue(tx.getConfidence().wasBroadcastBy(peerOf(p3).getAddress()));
}