Program: 31013
Project: 31013
Buggy source:
@Test public void submitPledgeViaHTTP() throws Exception {
  backend=new LighthouseBackend(SERVER,peerGroup,blockChain,pledgingWallet,diskManager,executor);
  backend.setMinPeersForUTXOQuery(1);
  backend.setMaxJitterSeconds(0);
  peerGroup.setMinBroadcastConnections(2);
  peerGroup.startAsync();
  peerGroup.awaitRunning();
  Triplet<Transaction,Transaction,LHProtos.Pledge> data=TestUtils.makePledge(project,to,project.getGoalAmount());
  Transaction stubTx=data.getValue0();
  Transaction pledgeTx=data.getValue1();
  LHProtos.Pledge pledge=data.getValue2();
  writeProjectToDisk();
  ObservableSet<LHProtos.Pledge> pledges=backend.mirrorOpenPledges(project,gate);
  Transaction depTx=FakeTxBuilder.createFakeTx(params,Coin.COIN,address);
  pledge=pledge.toBuilder().setTransactions(0,ByteString.copyFrom(depTx.bitcoinSerialize())).addTransactions(ByteString.copyFrom(pledgeTx.bitcoinSerialize())).build();
  InboundMessageQueuer p1=connectPeer(1);
  InboundMessageQueuer p2=connectPeer(2,supportingVer);
  CompletableFuture<LHProtos.Pledge> future=backend.submitPledge(project,pledge);
  assertFalse(future.isDone());
  Transaction broadcast=(Transaction)waitForOutbound(p1);
  assertEquals(depTx,broadcast);
  assertNull(outbound(p2));
  InventoryMessage inv=new InventoryMessage(params);
  inv.addTransaction(depTx);
  inbound(p2,inv);
  GetUTXOsMessage getutxos=(GetUTXOsMessage)waitForOutbound(p2);
  assertNotNull(getutxos);
  assertEquals(pledgeTx.getInput(0).getOutpoint(),getutxos.getOutPoints().get(0));
  inbound(p2,new UTXOsMessage(params,ImmutableList.of(stubTx.getOutput(0)),new long[]{UTXOsMessage.MEMPOOL_HEIGHT},blockStore.getChainHead().getHeader().getHash(),blockStore.getChainHead().getHeight()));
  AtomicBoolean flag=new AtomicBoolean(false);
  pledges.addListener((SetChangeListener<LHProtos.Pledge>)c -> {
    flag.set(c.wasAdded());
  }
);
  gate.waitAndRun();
  assertTrue(flag.get());
  assertEquals(1,pledges.size());
  final LHProtos.Pledge pledge2=pledges.iterator().next();
  assertEquals(Coin.COIN.value / 2,pledge2.getTotalInputValue());
  future.get();
  final Sha256Hash pledgeHash=Sha256Hash.create(pledge.toByteArray());
  final List<Path> dirFiles=mapList(listDir(AppDirectory.dir()),Path::getFileName);
  assertTrue(dirFiles.contains(Paths.get(pledgeHash.toString() + DiskManager.PLEDGE_FILE_EXTENSION)));
  peerGroup.stopAsync();
  peerGroup.awaitTerminated();
}

Fixed version (ground truth):
@Test public void submitPledgeViaHTTP() throws Exception {
  backend.shutdown();
  backend=new LighthouseBackend(SERVER,peerGroup,blockChain,pledgingWallet,diskManager,executor);
  backend.setMinPeersForUTXOQuery(1);
  backend.setMaxJitterSeconds(0);
  peerGroup.setMinBroadcastConnections(2);
  peerGroup.startAsync();
  peerGroup.awaitRunning();
  Triplet<Transaction,Transaction,LHProtos.Pledge> data=TestUtils.makePledge(project,to,project.getGoalAmount());
  Transaction stubTx=data.getValue0();
  Transaction pledgeTx=data.getValue1();
  LHProtos.Pledge pledge=data.getValue2();
  writeProjectToDisk();
  ObservableSet<LHProtos.Pledge> pledges=backend.mirrorOpenPledges(project,gate);
  Transaction depTx=FakeTxBuilder.createFakeTx(params,Coin.COIN,address);
  pledge=pledge.toBuilder().setTransactions(0,ByteString.copyFrom(depTx.bitcoinSerialize())).addTransactions(ByteString.copyFrom(pledgeTx.bitcoinSerialize())).build();
  InboundMessageQueuer p1=connectPeer(1);
  InboundMessageQueuer p2=connectPeer(2,supportingVer);
  CompletableFuture<LHProtos.Pledge> future=backend.submitPledge(project,pledge);
  assertFalse(future.isDone());
  Transaction broadcast=(Transaction)waitForOutbound(p1);
  assertEquals(depTx,broadcast);
  assertNull(outbound(p2));
  InventoryMessage inv=new InventoryMessage(params);
  inv.addTransaction(depTx);
  inbound(p2,inv);
  GetUTXOsMessage getutxos=(GetUTXOsMessage)waitForOutbound(p2);
  assertNotNull(getutxos);
  assertEquals(pledgeTx.getInput(0).getOutpoint(),getutxos.getOutPoints().get(0));
  inbound(p2,new UTXOsMessage(params,ImmutableList.of(stubTx.getOutput(0)),new long[]{UTXOsMessage.MEMPOOL_HEIGHT},blockStore.getChainHead().getHeader().getHash(),blockStore.getChainHead().getHeight()));
  AtomicBoolean flag=new AtomicBoolean(false);
  pledges.addListener((SetChangeListener<LHProtos.Pledge>)c -> {
    flag.set(c.wasAdded());
  }
);
  gate.waitAndRun();
  assertTrue(flag.get());
  assertEquals(1,pledges.size());
  final LHProtos.Pledge pledge2=pledges.iterator().next();
  assertEquals(Coin.COIN.value / 2,pledge2.getTotalInputValue());
  future.get();
  final Sha256Hash pledgeHash=Sha256Hash.create(pledge.toByteArray());
  final List<Path> dirFiles=mapList(listDir(AppDirectory.dir()),Path::getFileName);
  assertTrue(dirFiles.contains(Paths.get(pledgeHash.toString() + DiskManager.PLEDGE_FILE_EXTENSION)));
  peerGroup.stopAsync();
  peerGroup.awaitTerminated();
}