nus-yam/ex-repair huggingface dataset:
Program: 85631
Project: 85631
Buggy source:
@Test public void fourPeers() throws Exception {
  InboundMessageQueuer[] channels={connectPeer(1),connectPeer(2),connectPeer(3),connectPeer(4)};
  Transaction tx=new Transaction(params);
  TransactionBroadcast broadcast=new TransactionBroadcast(peerGroup,tx);
  final AtomicDouble lastProgress=new AtomicDouble();
  broadcast.setProgressCallback(new TransactionBroadcast.ProgressCallback(){
    @Override public void onBroadcastProgress(    double progress){
      lastProgress.set(progress);
    }
  }
);
  ListenableFuture<Transaction> future=broadcast.broadcast();
  assertFalse(future.isDone());
  assertEquals(0.0,lastProgress.get(),0.0);
  Message[] messages={(Message)outbound(channels[0]),(Message)outbound(channels[1]),(Message)outbound(channels[2]),(Message)outbound(channels[3])};
  assertEquals(tx,messages[0]);
  assertEquals(tx,messages[3]);
  assertNull(messages[1]);
  assertNull(messages[2]);
  Threading.waitForUserCode();
  assertFalse(future.isDone());
  assertEquals(0.0,lastProgress.get(),0.0);
  inbound(channels[1],InventoryMessage.with(tx));
  pingAndWait(channels[1]);
  future.get();
  Threading.waitForUserCode();
  assertEquals(1.0,lastProgress.get(),0.0);
}

Fixed version (ground truth):
@Test public void fourPeers() throws Exception {
  InboundMessageQueuer[] channels={connectPeer(1),connectPeer(2),connectPeer(3),connectPeer(4)};
  Transaction tx=new Transaction(params);
  tx.getConfidence().setSource(TransactionConfidence.Source.SELF);
  TransactionBroadcast broadcast=new TransactionBroadcast(peerGroup,tx);
  final AtomicDouble lastProgress=new AtomicDouble();
  broadcast.setProgressCallback(new TransactionBroadcast.ProgressCallback(){
    @Override public void onBroadcastProgress(    double progress){
      lastProgress.set(progress);
    }
  }
);
  ListenableFuture<Transaction> future=broadcast.broadcast();
  assertFalse(future.isDone());
  assertEquals(0.0,lastProgress.get(),0.0);
  Message[] messages={(Message)outbound(channels[0]),(Message)outbound(channels[1]),(Message)outbound(channels[2]),(Message)outbound(channels[3])};
  assertEquals(tx,messages[0]);
  assertEquals(tx,messages[3]);
  assertNull(messages[1]);
  assertNull(messages[2]);
  Threading.waitForUserCode();
  assertFalse(future.isDone());
  assertEquals(0.0,lastProgress.get(),0.0);
  inbound(channels[1],InventoryMessage.with(tx));
  future.get();
  Threading.waitForUserCode();
  assertEquals(1.0,lastProgress.get(),0.0);
  assertNull(outbound(channels[1]));
}
Program: 85634
Project: 85634
Buggy source:
/** 
 * When downloading the block chain, the bodies will be skipped for blocks created before the given date. Any transactions relevant to the wallet will therefore not be found, but if you know your wallet has no such transactions it doesn't matter and can save a lot of bandwidth and processing time. Note that the times of blocks isn't known until their headers are available and they are requested in chunks, so some headers may be downloaded twice using this scheme, but this optimization can still be a large win for newly created wallets.
 * @param secondsSinceEpoch Time in seconds since the epoch or 0 to reset to always downloading block bodies.
 */
public void setDownloadParameters(long secondsSinceEpoch,boolean useFilteredBlocks){
  lock.lock();
  try {
    Preconditions.checkNotNull(blockChain);
    if (secondsSinceEpoch == 0) {
      fastCatchupTimeSecs=params.getGenesisBlock().getTimeSeconds();
      downloadBlockBodies=true;
    }
 else {
      fastCatchupTimeSecs=secondsSinceEpoch;
      if (fastCatchupTimeSecs > blockChain.getChainHead().getHeader().getTimeSeconds()) {
        downloadBlockBodies=false;
      }
    }
    this.useFilteredBlocks=useFilteredBlocks;
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * When downloading the block chain, the bodies will be skipped for blocks created before the given date. Any transactions relevant to the wallet will therefore not be found, but if you know your wallet has no such transactions it doesn't matter and can save a lot of bandwidth and processing time. Note that the times of blocks isn't known until their headers are available and they are requested in chunks, so some headers may be downloaded twice using this scheme, but this optimization can still be a large win for newly created wallets.
 * @param secondsSinceEpoch Time in seconds since the epoch or 0 to reset to always downloading block bodies.
 */
public void setDownloadParameters(long secondsSinceEpoch,boolean useFilteredBlocks){
  lock.lock();
  try {
    if (secondsSinceEpoch == 0) {
      fastCatchupTimeSecs=params.getGenesisBlock().getTimeSeconds();
      downloadBlockBodies=true;
    }
 else {
      fastCatchupTimeSecs=secondsSinceEpoch;
      if (blockChain != null && fastCatchupTimeSecs > blockChain.getChainHead().getHeader().getTimeSeconds())       downloadBlockBodies=false;
    }
    this.useFilteredBlocks=useFilteredBlocks;
  }
  finally {
    lock.unlock();
  }
}
Program: 85635
Project: 85635
Buggy source:
private Sha256Hash recursiveExtractHashes(int height,int pos,ValuesUsed used,List<Sha256Hash> matchedHashes) throws VerificationException {
  if (used.bitsUsed >= matchedChildBits.length * 8) {
    throw new VerificationException("String_Node_Str");
  }
  boolean parentOfMatch=checkBitLE(matchedChildBits,used.bitsUsed++);
  if (height == 0 || !parentOfMatch) {
    if (used.hashesUsed >= hashes.size()) {
      throw new VerificationException("String_Node_Str");
    }
    Sha256Hash hash=hashes.get(used.hashesUsed++);
    if (height == 0 && parentOfMatch)     matchedHashes.add(hash);
    return hash;
  }
 else {
    byte[] left=recursiveExtractHashes(height - 1,pos * 2,used,matchedHashes).getBytes(), right;
    if (pos * 2 + 1 < getTreeWidth(transactionCount,height - 1))     right=recursiveExtractHashes(height - 1,pos * 2 + 1,used,matchedHashes).getBytes();
 else     right=left;
    return combineLeftRight(left,right);
  }
}

Fixed version (ground truth):
private Sha256Hash recursiveExtractHashes(int height,int pos,ValuesUsed used,List<Sha256Hash> matchedHashes) throws VerificationException {
  if (used.bitsUsed >= matchedChildBits.length * 8) {
    throw new VerificationException("String_Node_Str");
  }
  boolean parentOfMatch=checkBitLE(matchedChildBits,used.bitsUsed++);
  if (height == 0 || !parentOfMatch) {
    if (used.hashesUsed >= hashes.size()) {
      throw new VerificationException("String_Node_Str");
    }
    Sha256Hash hash=hashes.get(used.hashesUsed++);
    if (height == 0 && parentOfMatch)     matchedHashes.add(hash);
    return hash;
  }
 else {
    byte[] left=recursiveExtractHashes(height - 1,pos * 2,used,matchedHashes).getBytes(), right;
    if (pos * 2 + 1 < getTreeWidth(transactionCount,height - 1)) {
      right=recursiveExtractHashes(height - 1,pos * 2 + 1,used,matchedHashes).getBytes();
      if (Arrays.equals(right,left))       throw new VerificationException("String_Node_Str");
    }
 else {
      right=left;
    }
    return combineLeftRight(left,right);
  }
}
Program: 85636
Project: 85636
Buggy source:
/** 
 * Extracts tx hashes that are in this merkle tree and returns the merkle root of this tree. The returned root should be checked against the merkle root contained in the block header for security.
 * @param matchedHashes A list which will contain the matched txn (will be cleared)Required to be a LinkedHashSet in order to retain order or transactions in the block
 * @return the merkle root of this merkle tree
 * @throws ProtocolException if this partial merkle tree is invalid
 */
public Sha256Hash getTxnHashAndMerkleRoot(List<Sha256Hash> matchedHashes) throws VerificationException {
  matchedHashes.clear();
  if (transactionCount == 0)   throw new VerificationException("String_Node_Str");
  if (transactionCount > Block.MAX_BLOCK_SIZE / 60)   throw new VerificationException("String_Node_Str");
  if (hashes.size() > transactionCount)   throw new VerificationException("String_Node_Str");
  if (matchedChildBits.length * 8 < hashes.size())   throw new VerificationException("String_Node_Str");
  int height=0;
  while (getTreeWidth(transactionCount,height) > 1)   height++;
  ValuesUsed used=new ValuesUsed();
  Sha256Hash merkleRoot=recursiveExtractHashes(height,0,used,matchedHashes);
  if ((used.bitsUsed + 7) / 8 != matchedChildBits.length || used.hashesUsed != hashes.size())   throw new VerificationException("String_Node_Str");
  return merkleRoot;
}

Fixed version (ground truth):
/** 
 * Extracts tx hashes that are in this merkle tree and returns the merkle root of this tree. The returned root should be checked against the merkle root contained in the block header for security.
 * @param matchedHashesOut A list which will contain the matched txn (will be cleared).
 * @return the merkle root of this merkle tree
 * @throws ProtocolException if this partial merkle tree is invalid
 */
public Sha256Hash getTxnHashAndMerkleRoot(List<Sha256Hash> matchedHashesOut) throws VerificationException {
  matchedHashesOut.clear();
  if (transactionCount == 0)   throw new VerificationException("String_Node_Str");
  if (transactionCount > Block.MAX_BLOCK_SIZE / 60)   throw new VerificationException("String_Node_Str");
  if (hashes.size() > transactionCount)   throw new VerificationException("String_Node_Str");
  if (matchedChildBits.length * 8 < hashes.size())   throw new VerificationException("String_Node_Str");
  int height=0;
  while (getTreeWidth(transactionCount,height) > 1)   height++;
  ValuesUsed used=new ValuesUsed();
  Sha256Hash merkleRoot=recursiveExtractHashes(height,0,used,matchedHashesOut);
  if ((used.bitsUsed + 7) / 8 != matchedChildBits.length || used.hashesUsed != hashes.size())   throw new VerificationException("String_Node_Str");
  return merkleRoot;
}
Program: 85638
Project: 85638
Buggy source:
@Test public void replayWhilstPending() throws Exception {
  Coin value=COIN;
  Transaction tx1=createFakeTx(params,value,myAddress);
  Transaction tx2=new Transaction(params);
  tx2.addInput(tx1.getOutput(0));
  tx2.addOutput(valueOf(0,9),new ECKey());
  tx2.addOutput(CENT,wallet.getChangeAddress());
  wallet.receivePending(tx2,null);
  BlockPair bp=createFakeBlock(blockStore,tx1);
  wallet.receiveFromBlock(tx1,bp.storedBlock,AbstractBlockChain.NewBlockType.BEST_CHAIN,0);
  wallet.notifyNewBestBlock(bp.storedBlock);
  assertEquals(ZERO,wallet.getBalance());
  assertEquals(1,wallet.getPoolSize(Pool.SPENT));
  assertEquals(1,wallet.getPoolSize(Pool.PENDING));
  assertEquals(0,wallet.getPoolSize(Pool.UNSPENT));
}

Fixed version (ground truth):
@Test public void replayWhilstPending() throws Exception {
  Coin value=COIN;
  Transaction tx1=createFakeTx(params,value,myAddress);
  Transaction tx2=new Transaction(params);
  tx2.addInput(tx1.getOutput(0));
  tx2.addOutput(valueOf(0,9),someOtherAddress);
  tx2.addOutput(CENT,wallet.getChangeAddress());
  wallet.receivePending(tx2,null);
  BlockPair bp=createFakeBlock(blockStore,tx1);
  wallet.receiveFromBlock(tx1,bp.storedBlock,AbstractBlockChain.NewBlockType.BEST_CHAIN,0);
  wallet.notifyNewBestBlock(bp.storedBlock);
  assertEquals(ZERO,wallet.getBalance());
  assertEquals(1,wallet.getPoolSize(Pool.SPENT));
  assertEquals(1,wallet.getPoolSize(Pool.PENDING));
  assertEquals(0,wallet.getPoolSize(Pool.UNSPENT));
}
Program: 85639
Project: 85639
Buggy source:
private void askForPasswordAndRetry(){
  Main.OverlayUI<WalletPasswordController> pwd=Main.instance.overlayUI("String_Node_Str");
  final String addressStr=address.getText();
  pwd.controller.aesKeyProperty().addListener((observable,old,cur) -> {
    checkGuiThread();
    Main.OverlayUI<SendMoneyController> screen=Main.instance.overlayUI("String_Node_Str");
    screen.controller.aesKey=cur;
    screen.controller.address.setText(addressStr);
    screen.controller.send(null);
  }
);
}

Fixed version (ground truth):
private void askForPasswordAndRetry(){
  Main.OverlayUI<WalletPasswordController> pwd=Main.instance.overlayUI("String_Node_Str");
  final String addressStr=address.getText();
  final String amountStr=amountEdit.getText();
  pwd.controller.aesKeyProperty().addListener((observable,old,cur) -> {
    checkGuiThread();
    Main.OverlayUI<SendMoneyController> screen=Main.instance.overlayUI("String_Node_Str");
    screen.controller.aesKey=cur;
    screen.controller.address.setText(addressStr);
    screen.controller.amountEdit.setText(amountStr);
    screen.controller.send(null);
  }
);
}
Program: 85641
Project: 85641
Buggy source:
@Test public void replayWhilstPending() throws Exception {
  Coin value=COIN;
  Transaction tx1=createFakeTx(params,value,myAddress);
  Transaction tx2=new Transaction(params);
  tx2.addInput(tx1.getOutput(0));
  tx2.addOutput(valueOf(0,9),new ECKey());
  tx2.addOutput(CENT,wallet.getChangeAddress());
  wallet.receivePending(tx2,null);
  BlockPair bp=createFakeBlock(blockStore,tx1);
  wallet.receiveFromBlock(tx1,bp.storedBlock,AbstractBlockChain.NewBlockType.BEST_CHAIN,0);
  wallet.notifyNewBestBlock(bp.storedBlock);
  assertEquals(ZERO,wallet.getBalance());
  assertEquals(1,wallet.getPoolSize(Pool.SPENT));
  assertEquals(1,wallet.getPoolSize(Pool.PENDING));
  assertEquals(0,wallet.getPoolSize(Pool.UNSPENT));
}

Fixed version (ground truth):
@Test public void replayWhilstPending() throws Exception {
  Coin value=COIN;
  Transaction tx1=createFakeTx(params,value,myAddress);
  Transaction tx2=new Transaction(params);
  tx2.addInput(tx1.getOutput(0));
  tx2.addOutput(valueOf(0,9),someOtherAddress);
  tx2.addOutput(CENT,wallet.getChangeAddress());
  wallet.receivePending(tx2,null);
  BlockPair bp=createFakeBlock(blockStore,tx1);
  wallet.receiveFromBlock(tx1,bp.storedBlock,AbstractBlockChain.NewBlockType.BEST_CHAIN,0);
  wallet.notifyNewBestBlock(bp.storedBlock);
  assertEquals(ZERO,wallet.getBalance());
  assertEquals(1,wallet.getPoolSize(Pool.SPENT));
  assertEquals(1,wallet.getPoolSize(Pool.PENDING));
  assertEquals(0,wallet.getPoolSize(Pool.UNSPENT));
}
Program: 85644
Project: 85644
Buggy source:
private Sha256Hash recursiveExtractHashes(int height,int pos,ValuesUsed used,List<Sha256Hash> matchedHashes) throws VerificationException {
  if (used.bitsUsed >= matchedChildBits.length * 8) {
    throw new VerificationException("String_Node_Str");
  }
  boolean parentOfMatch=checkBitLE(matchedChildBits,used.bitsUsed++);
  if (height == 0 || !parentOfMatch) {
    if (used.hashesUsed >= hashes.size()) {
      throw new VerificationException("String_Node_Str");
    }
    Sha256Hash hash=hashes.get(used.hashesUsed++);
    if (height == 0 && parentOfMatch)     matchedHashes.add(hash);
    return hash;
  }
 else {
    byte[] left=recursiveExtractHashes(height - 1,pos * 2,used,matchedHashes).getBytes(), right;
    if (pos * 2 + 1 < getTreeWidth(transactionCount,height - 1))     right=recursiveExtractHashes(height - 1,pos * 2 + 1,used,matchedHashes).getBytes();
 else     right=left;
    return combineLeftRight(left,right);
  }
}

Fixed version (ground truth):
private Sha256Hash recursiveExtractHashes(int height,int pos,ValuesUsed used,List<Sha256Hash> matchedHashes) throws VerificationException {
  if (used.bitsUsed >= matchedChildBits.length * 8) {
    throw new VerificationException("String_Node_Str");
  }
  boolean parentOfMatch=checkBitLE(matchedChildBits,used.bitsUsed++);
  if (height == 0 || !parentOfMatch) {
    if (used.hashesUsed >= hashes.size()) {
      throw new VerificationException("String_Node_Str");
    }
    Sha256Hash hash=hashes.get(used.hashesUsed++);
    if (height == 0 && parentOfMatch)     matchedHashes.add(hash);
    return hash;
  }
 else {
    byte[] left=recursiveExtractHashes(height - 1,pos * 2,used,matchedHashes).getBytes(), right;
    if (pos * 2 + 1 < getTreeWidth(transactionCount,height - 1)) {
      right=recursiveExtractHashes(height - 1,pos * 2 + 1,used,matchedHashes).getBytes();
      if (Arrays.equals(right,left))       throw new VerificationException("String_Node_Str");
    }
 else {
      right=left;
    }
    return combineLeftRight(left,right);
  }
}
Program: 85645
Project: 85645
Buggy source:
/** 
 * Extracts tx hashes that are in this merkle tree and returns the merkle root of this tree. The returned root should be checked against the merkle root contained in the block header for security.
 * @param matchedHashes A list which will contain the matched txn (will be cleared)Required to be a LinkedHashSet in order to retain order or transactions in the block
 * @return the merkle root of this merkle tree
 * @throws ProtocolException if this partial merkle tree is invalid
 */
public Sha256Hash getTxnHashAndMerkleRoot(List<Sha256Hash> matchedHashes) throws VerificationException {
  matchedHashes.clear();
  if (transactionCount == 0)   throw new VerificationException("String_Node_Str");
  if (transactionCount > Block.MAX_BLOCK_SIZE / 60)   throw new VerificationException("String_Node_Str");
  if (hashes.size() > transactionCount)   throw new VerificationException("String_Node_Str");
  if (matchedChildBits.length * 8 < hashes.size())   throw new VerificationException("String_Node_Str");
  int height=0;
  while (getTreeWidth(transactionCount,height) > 1)   height++;
  ValuesUsed used=new ValuesUsed();
  Sha256Hash merkleRoot=recursiveExtractHashes(height,0,used,matchedHashes);
  if ((used.bitsUsed + 7) / 8 != matchedChildBits.length || used.hashesUsed != hashes.size())   throw new VerificationException("String_Node_Str");
  return merkleRoot;
}

Fixed version (ground truth):
/** 
 * Extracts tx hashes that are in this merkle tree and returns the merkle root of this tree. The returned root should be checked against the merkle root contained in the block header for security.
 * @param matchedHashesOut A list which will contain the matched txn (will be cleared).
 * @return the merkle root of this merkle tree
 * @throws ProtocolException if this partial merkle tree is invalid
 */
public Sha256Hash getTxnHashAndMerkleRoot(List<Sha256Hash> matchedHashesOut) throws VerificationException {
  matchedHashesOut.clear();
  if (transactionCount == 0)   throw new VerificationException("String_Node_Str");
  if (transactionCount > Block.MAX_BLOCK_SIZE / 60)   throw new VerificationException("String_Node_Str");
  if (hashes.size() > transactionCount)   throw new VerificationException("String_Node_Str");
  if (matchedChildBits.length * 8 < hashes.size())   throw new VerificationException("String_Node_Str");
  int height=0;
  while (getTreeWidth(transactionCount,height) > 1)   height++;
  ValuesUsed used=new ValuesUsed();
  Sha256Hash merkleRoot=recursiveExtractHashes(height,0,used,matchedHashesOut);
  if ((used.bitsUsed + 7) / 8 != matchedChildBits.length || used.hashesUsed != hashes.size())   throw new VerificationException("String_Node_Str");
  return merkleRoot;
}
Program: 85646
Project: 85646
Buggy source:
/** 
 * Helper for forcing a connection to localhost. Useful when using regtest mode. Returns the peer object.
 */
@Nullable public Peer connectToLocalHost(){
  final PeerAddress localhost=PeerAddress.localhost(params);
  backoffMap.put(localhost,new ExponentialBackoff(peerBackoffParams));
  return connectTo(localhost,true,vConnectTimeoutMillis);
}

Fixed version (ground truth):
/** 
 * Helper for forcing a connection to localhost. Useful when using regtest mode. Returns the peer object.
 */
@Nullable public Peer connectToLocalHost(){
  lock.lock();
  try {
    final PeerAddress localhost=PeerAddress.localhost(params);
    backoffMap.put(localhost,new ExponentialBackoff(peerBackoffParams));
    return connectTo(localhost,true,vConnectTimeoutMillis);
  }
  finally {
    lock.unlock();
  }
}
Program: 85648
Project: 85648
Buggy source:
/** 
 * Creates a version message to send, constructs a Peer object and attempts to connect it. Returns the peer on success or null on failure.
 * @param address Remote network address
 * @param incrementMaxConnections Whether to consider this connection an attempt to fill our quota, or somethingexplicitly requested.
 * @return Peer or null.
 */
@Nullable protected Peer connectTo(PeerAddress address,boolean incrementMaxConnections,int connectTimeoutMillis){
  VersionMessage ver=getVersionMessage().duplicate();
  ver.bestHeight=chain == null ? 0 : chain.getBestChainHeight();
  ver.time=Utils.currentTimeSeconds();
  Peer peer=new Peer(params,ver,address,chain,memoryPool,downloadTxDependencies);
  peer.addEventListener(startupListener,Threading.SAME_THREAD);
  peer.setMinProtocolVersion(vMinRequiredProtocolVersion);
  pendingPeers.add(peer);
  try {
    channels.openConnection(address.toSocketAddress(),peer);
  }
 catch (  Exception e) {
    log.warn("String_Node_Str" + address + "String_Node_Str"+ e.getMessage());
    handlePeerDeath(peer,e);
    return null;
  }
  peer.setSocketTimeout(connectTimeoutMillis);
  if (incrementMaxConnections) {
    lock.lock();
    try {
      maxConnections++;
    }
  finally {
      lock.unlock();
    }
  }
  return peer;
}

Fixed version (ground truth):
/** 
 * Creates a version message to send, constructs a Peer object and attempts to connect it. Returns the peer on success or null on failure.
 * @param address Remote network address
 * @param incrementMaxConnections Whether to consider this connection an attempt to fill our quota, or somethingexplicitly requested.
 * @return Peer or null.
 */
@Nullable @GuardedBy("String_Node_Str") protected Peer connectTo(PeerAddress address,boolean incrementMaxConnections,int connectTimeoutMillis){
  checkState(lock.isHeldByCurrentThread());
  VersionMessage ver=getVersionMessage().duplicate();
  ver.bestHeight=chain == null ? 0 : chain.getBestChainHeight();
  ver.time=Utils.currentTimeSeconds();
  Peer peer=new Peer(params,ver,address,chain,memoryPool,downloadTxDependencies);
  peer.addEventListener(startupListener,Threading.SAME_THREAD);
  peer.setMinProtocolVersion(vMinRequiredProtocolVersion);
  pendingPeers.add(peer);
  try {
    channels.openConnection(address.toSocketAddress(),peer);
  }
 catch (  Exception e) {
    log.warn("String_Node_Str" + address + "String_Node_Str"+ e.getMessage());
    handlePeerDeath(peer,e);
    return null;
  }
  peer.setSocketTimeout(connectTimeoutMillis);
  if (incrementMaxConnections) {
    maxConnections++;
  }
  return peer;
}
Program: 85651
Project: 85651
Buggy source:
/** 
 * Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
 */
public boolean isShortestPossiblePushData(){
  checkState(isPushData());
  if (data.length == 0)   return opcode == OP_0;
  if (data.length == 1) {
    byte b=data[0];
    if (b >= 0x01 && b <= 0x10)     return opcode == OP_1 + b - 1;
    if ((b & 0xFF) == 0x81)     return opcode == OP_1NEGATE;
  }
  if (data.length < OP_PUSHDATA1)   return opcode == data.length;
  if (data.length < 256)   return opcode == OP_PUSHDATA1;
  if (data.length < 65536)   return opcode == OP_PUSHDATA2;
  return opcode == OP_PUSHDATA4;
}

Fixed version (ground truth):
/** 
 * Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
 */
public boolean isShortestPossiblePushData(){
  checkState(isPushData());
  if (data == null)   return true;
  if (data.length == 0)   return opcode == OP_0;
  if (data.length == 1) {
    byte b=data[0];
    if (b >= 0x01 && b <= 0x10)     return opcode == OP_1 + b - 1;
    if ((b & 0xFF) == 0x81)     return opcode == OP_1NEGATE;
  }
  if (data.length < OP_PUSHDATA1)   return opcode == data.length;
  if (data.length < 256)   return opcode == OP_PUSHDATA1;
  if (data.length < 65536)   return opcode == OP_PUSHDATA2;
  return opcode == OP_PUSHDATA4;
}
Program: 85652
Project: 85652
Buggy source:
@Before public void setup(){
  wallet=new Wallet(params){
    @Override public int getLastBlockSeenHeight(){
      return 1000;
    }
    @Override public long getLastBlockSeenTimeSecs(){
      return TIMESTAMP;
    }
  }
;
  key1=new ECKey();
}

Fixed version (ground truth):
@Before public void setup(){
  wallet=new Wallet(params){
    @Override public int getLastBlockSeenHeight(){
      return 1000;
    }
    @Override public long getLastBlockSeenTimeSecs(){
      return TIMESTAMP;
    }
  }
;
}
Program: 85654
Project: 85654
Buggy source:
/** 
 * Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
 */
public boolean isShortestPossiblePushData(){
  checkState(isPushData());
  if (data.length == 0)   return opcode == OP_0;
  if (data.length == 1) {
    byte b=data[0];
    if (b >= 0x01 && b <= 0x10)     return opcode == OP_1 + b - 1;
    if ((b & 0xFF) == 0x81)     return opcode == OP_1NEGATE;
  }
  if (data.length < OP_PUSHDATA1)   return opcode == data.length;
  if (data.length < 256)   return opcode == OP_PUSHDATA1;
  if (data.length < 65536)   return opcode == OP_PUSHDATA2;
  return opcode == OP_PUSHDATA4;
}

Fixed version (ground truth):
/** 
 * Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
 */
public boolean isShortestPossiblePushData(){
  checkState(isPushData());
  if (data == null)   return true;
  if (data.length == 0)   return opcode == OP_0;
  if (data.length == 1) {
    byte b=data[0];
    if (b >= 0x01 && b <= 0x10)     return opcode == OP_1 + b - 1;
    if ((b & 0xFF) == 0x81)     return opcode == OP_1NEGATE;
  }
  if (data.length < OP_PUSHDATA1)   return opcode == data.length;
  if (data.length < 256)   return opcode == OP_PUSHDATA1;
  if (data.length < 65536)   return opcode == OP_PUSHDATA2;
  return opcode == OP_PUSHDATA4;
}
Program: 85655
Project: 85655
Buggy source:
@Before public void setup(){
  wallet=new Wallet(params){
    @Override public int getLastBlockSeenHeight(){
      return 1000;
    }
    @Override public long getLastBlockSeenTimeSecs(){
      return TIMESTAMP;
    }
  }
;
  key1=new ECKey();
}

Fixed version (ground truth):
@Before public void setup(){
  wallet=new Wallet(params){
    @Override public int getLastBlockSeenHeight(){
      return 1000;
    }
    @Override public long getLastBlockSeenTimeSecs(){
      return TIMESTAMP;
    }
  }
;
}
Program: 85657
Project: 85657
Buggy source:
/** 
 * Returns the minimum value for this output to be considered "not dust", i.e. the transaction will be relayable and mined by default miners. For normal pay to address outputs, this is 5460 satoshis, the same as  {@link Transaction#MIN_NONDUST_OUTPUT}.
 */
public Coin getMinNonDustValue(){
  return getMinNonDustValue(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(3));
}

Fixed version (ground truth):
/** 
 * Returns the minimum value for this output to be considered "not dust", i.e. the transaction will be relayable and mined by default miners. For normal pay to address outputs, this is 546 satoshis, the same as  {@link Transaction#MIN_NONDUST_OUTPUT}.
 */
public Coin getMinNonDustValue(){
  return getMinNonDustValue(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(3));
}
Program: 85659
Project: 85659
Buggy source:
private void receiveATransaction(Wallet wallet,Address toAddress) throws Exception {
  Coin v1=COIN;
  final ListenableFuture<Coin> availFuture=wallet.getBalanceFuture(v1,Wallet.BalanceType.AVAILABLE);
  final ListenableFuture<Coin> estimatedFuture=wallet.getBalanceFuture(v1,Wallet.BalanceType.ESTIMATED);
  assertFalse(availFuture.isDone());
  assertFalse(estimatedFuture.isDone());
  Transaction t1=sendMoneyToWallet(wallet,v1,toAddress,null);
  Threading.waitForUserCode();
  final ListenableFuture<Transaction> depthFuture=t1.getConfidence().getDepthFuture(1);
  assertFalse(depthFuture.isDone());
  assertEquals(ZERO,wallet.getBalance());
  assertEquals(v1,wallet.getBalance(Wallet.BalanceType.ESTIMATED));
  assertFalse(availFuture.isDone());
  assertTrue(estimatedFuture.isDone());
  assertEquals(1,wallet.getPoolSize(Pool.PENDING));
  assertEquals(0,wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
  sendMoneyToWallet(wallet,t1,AbstractBlockChain.NewBlockType.BEST_CHAIN);
  assertEquals("String_Node_Str",v1,wallet.getBalance());
  assertEquals("String_Node_Str",0,wallet.getPoolSize(WalletTransaction.Pool.PENDING));
  assertEquals("String_Node_Str",1,wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
  assertEquals("String_Node_Str",1,wallet.getTransactions(true).size());
  Threading.waitForUserCode();
  assertTrue(availFuture.isDone());
  assertTrue(estimatedFuture.isDone());
  assertTrue(depthFuture.isDone());
}

Fixed version (ground truth):
private void receiveATransaction(Wallet wallet,Address toAddress) throws Exception {
  receiveATransactionAmount(wallet,toAddress,COIN);
}
Program: 85660
Project: 85660
Buggy source:
protected void initPeerGroup(){
  if (clientType == ClientType.NIO_CLIENT_MANAGER)   peerGroup=new PeerGroup(unitTestParams,blockChain,new NioClientManager());
 else   peerGroup=new PeerGroup(unitTestParams,blockChain,new BlockingClientManager());
  peerGroup.setPingIntervalMsec(0);
  peerGroup.addWallet(wallet);
}

Fixed version (ground truth):
protected void initPeerGroup(){
  if (clientType == ClientType.NIO_CLIENT_MANAGER)   peerGroup=new PeerGroup(unitTestParams,blockChain,new NioClientManager());
 else   peerGroup=new PeerGroup(unitTestParams,blockChain,new BlockingClientManager());
  peerGroup.setPingIntervalMsec(0);
  peerGroup.addWallet(wallet);
  peerGroup.setUseLocalhostPeerWhenPossible(false);
}
Program: 85662
Project: 85662
Buggy source:
@Test public void preferLocalPeer() throws IOException {
  ServerSocket local=new ServerSocket(params.getPort(),100,InetAddresses.forString("String_Node_Str"));
  try {
    peerGroup.startAsync();
    peerGroup.awaitRunning();
    local.accept().close();
    local.accept();
    assertEquals(1,peerGroup.getMaxConnections());
    assertEquals(PeerAddress.localhost(params),peerGroup.getPendingPeers().get(0).getAddress());
  }
  finally {
    local.close();
  }
}

Fixed version (ground truth):
@Test public void preferLocalPeer() throws IOException {
  ServerSocket local=null;
  try {
    local=new ServerSocket(params.getPort(),100,InetAddresses.forString("String_Node_Str"));
  }
 catch (  BindException e) {
    return;
  }
  try {
    peerGroup.setUseLocalhostPeerWhenPossible(true);
    peerGroup.startAsync();
    peerGroup.awaitRunning();
    local.accept().close();
    local.accept();
    assertEquals(1,peerGroup.getMaxConnections());
    assertEquals(PeerAddress.localhost(params),peerGroup.getPendingPeers().get(0).getAddress());
  }
  finally {
    local.close();
  }
}
Program: 85663
Project: 85663
Buggy source:
/** 
 * Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
 */
public boolean isShortestPossiblePushData(){
  checkState(isPushData());
  if (data.length == 0)   return opcode == OP_0;
  if (data.length == 1) {
    byte b=data[0];
    if (b >= 0x01 && b <= 0x10)     return opcode == OP_1 + b - 1;
    if (b == 0x81)     return opcode == OP_1NEGATE;
  }
  if (data.length < OP_PUSHDATA1)   return opcode == data.length;
  if (data.length < 256)   return opcode == OP_PUSHDATA1;
  if (data.length < 65536)   return opcode == OP_PUSHDATA2;
  return opcode == OP_PUSHDATA4;
}

Fixed version (ground truth):
/** 
 * Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
 */
public boolean isShortestPossiblePushData(){
  checkState(isPushData());
  if (data.length == 0)   return opcode == OP_0;
  if (data.length == 1) {
    byte b=data[0];
    if (b >= 0x01 && b <= 0x10)     return opcode == OP_1 + b - 1;
    if ((b & 0xFF) == 0x81)     return opcode == OP_1NEGATE;
  }
  if (data.length < OP_PUSHDATA1)   return opcode == data.length;
  if (data.length < 256)   return opcode == OP_PUSHDATA1;
  if (data.length < 65536)   return opcode == OP_PUSHDATA2;
  return opcode == OP_PUSHDATA4;
}
Program: 85664
Project: 85664
Buggy source:
public void write(OutputStream stream) throws IOException {
  if (isOpCode()) {
    checkState(data == null);
    stream.write(opcode);
  }
 else   if (data != null) {
    checkNotNull(data);
    if (opcode < OP_PUSHDATA1) {
      checkState(data.length == opcode);
      stream.write(opcode);
    }
 else     if (opcode == OP_PUSHDATA1) {
      checkState(data.length <= 0xFF);
      stream.write(OP_PUSHDATA1);
      stream.write(data.length);
    }
 else     if (opcode == OP_PUSHDATA2) {
      checkState(data.length <= 0xFFFF);
      stream.write(OP_PUSHDATA2);
      stream.write(0xFF & data.length);
      stream.write(0xFF & (data.length >> 8));
    }
 else     if (opcode == OP_PUSHDATA4) {
      checkState(data.length <= Script.MAX_SCRIPT_ELEMENT_SIZE);
      stream.write(OP_PUSHDATA4);
      Utils.uint32ToByteStreamLE(data.length,stream);
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    stream.write(data);
  }
 else {
    stream.write(opcode);
  }
}

Fixed version (ground truth):
public void write(OutputStream stream) throws IOException {
  if (isOpCode()) {
    checkState(data == null);
    stream.write(opcode);
  }
 else   if (data != null) {
    if (opcode < OP_PUSHDATA1) {
      checkState(data.length == opcode);
      stream.write(opcode);
    }
 else     if (opcode == OP_PUSHDATA1) {
      checkState(data.length <= 0xFF);
      stream.write(OP_PUSHDATA1);
      stream.write(data.length);
    }
 else     if (opcode == OP_PUSHDATA2) {
      checkState(data.length <= 0xFFFF);
      stream.write(OP_PUSHDATA2);
      stream.write(0xFF & data.length);
      stream.write(0xFF & (data.length >> 8));
    }
 else     if (opcode == OP_PUSHDATA4) {
      checkState(data.length <= Script.MAX_SCRIPT_ELEMENT_SIZE);
      stream.write(OP_PUSHDATA4);
      Utils.uint32ToByteStreamLE(data.length,stream);
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    stream.write(data);
  }
 else {
    stream.write(opcode);
  }
}
Program: 85665
Project: 85665
Buggy source:
/** 
 * Returns the minimum value for this output to be considered "not dust", i.e. the transaction will be relayable and mined by default miners. For normal pay to address outputs, this is 5460 satoshis, the same as  {@link Transaction#MIN_NONDUST_OUTPUT}.
 */
public Coin getMinNonDustValue(){
  return getMinNonDustValue(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(3));
}

Fixed version (ground truth):
/** 
 * Returns the minimum value for this output to be considered "not dust", i.e. the transaction will be relayable and mined by default miners. For normal pay to address outputs, this is 546 satoshis, the same as  {@link Transaction#MIN_NONDUST_OUTPUT}.
 */
public Coin getMinNonDustValue(){
  return getMinNonDustValue(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(3));
}
Program: 85667
Project: 85667
Buggy source:
private void receiveATransaction(Wallet wallet,Address toAddress) throws Exception {
  Coin v1=COIN;
  final ListenableFuture<Coin> availFuture=wallet.getBalanceFuture(v1,Wallet.BalanceType.AVAILABLE);
  final ListenableFuture<Coin> estimatedFuture=wallet.getBalanceFuture(v1,Wallet.BalanceType.ESTIMATED);
  assertFalse(availFuture.isDone());
  assertFalse(estimatedFuture.isDone());
  Transaction t1=sendMoneyToWallet(wallet,v1,toAddress,null);
  Threading.waitForUserCode();
  final ListenableFuture<Transaction> depthFuture=t1.getConfidence().getDepthFuture(1);
  assertFalse(depthFuture.isDone());
  assertEquals(ZERO,wallet.getBalance());
  assertEquals(v1,wallet.getBalance(Wallet.BalanceType.ESTIMATED));
  assertFalse(availFuture.isDone());
  assertTrue(estimatedFuture.isDone());
  assertEquals(1,wallet.getPoolSize(Pool.PENDING));
  assertEquals(0,wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
  sendMoneyToWallet(wallet,t1,AbstractBlockChain.NewBlockType.BEST_CHAIN);
  assertEquals("String_Node_Str",v1,wallet.getBalance());
  assertEquals("String_Node_Str",0,wallet.getPoolSize(WalletTransaction.Pool.PENDING));
  assertEquals("String_Node_Str",1,wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
  assertEquals("String_Node_Str",1,wallet.getTransactions(true).size());
  Threading.waitForUserCode();
  assertTrue(availFuture.isDone());
  assertTrue(estimatedFuture.isDone());
  assertTrue(depthFuture.isDone());
}

Fixed version (ground truth):
private void receiveATransaction(Wallet wallet,Address toAddress) throws Exception {
  receiveATransactionAmount(wallet,toAddress,COIN);
}
Program: 85668
Project: 85668
Buggy source:
protected void initPeerGroup(){
  if (clientType == ClientType.NIO_CLIENT_MANAGER)   peerGroup=new PeerGroup(unitTestParams,blockChain,new NioClientManager());
 else   peerGroup=new PeerGroup(unitTestParams,blockChain,new BlockingClientManager());
  peerGroup.setPingIntervalMsec(0);
  peerGroup.addWallet(wallet);
}

Fixed version (ground truth):
protected void initPeerGroup(){
  if (clientType == ClientType.NIO_CLIENT_MANAGER)   peerGroup=new PeerGroup(unitTestParams,blockChain,new NioClientManager());
 else   peerGroup=new PeerGroup(unitTestParams,blockChain,new BlockingClientManager());
  peerGroup.setPingIntervalMsec(0);
  peerGroup.addWallet(wallet);
  peerGroup.setUseLocalhostPeerWhenPossible(false);
}
Program: 85670
Project: 85670
Buggy source:
@Test public void preferLocalPeer() throws IOException {
  ServerSocket local=new ServerSocket(params.getPort(),100,InetAddresses.forString("String_Node_Str"));
  try {
    peerGroup.startAsync();
    peerGroup.awaitRunning();
    local.accept().close();
    local.accept();
    assertEquals(1,peerGroup.getMaxConnections());
    assertEquals(PeerAddress.localhost(params),peerGroup.getPendingPeers().get(0).getAddress());
  }
  finally {
    local.close();
  }
}

Fixed version (ground truth):
@Test public void preferLocalPeer() throws IOException {
  ServerSocket local=null;
  try {
    local=new ServerSocket(params.getPort(),100,InetAddresses.forString("String_Node_Str"));
  }
 catch (  BindException e) {
    return;
  }
  try {
    peerGroup.setUseLocalhostPeerWhenPossible(true);
    peerGroup.startAsync();
    peerGroup.awaitRunning();
    local.accept().close();
    local.accept();
    assertEquals(1,peerGroup.getMaxConnections());
    assertEquals(PeerAddress.localhost(params),peerGroup.getPendingPeers().get(0).getAddress());
  }
  finally {
    local.close();
  }
}
Program: 85671
Project: 85671
Buggy source:
private List<Transaction> maybeRotateKeys(@Nullable KeyParameter aesKey,boolean sign) throws DeterministicUpgradeRequiresPassword {
  checkState(lock.isHeldByCurrentThread());
  List<Transaction> results=Lists.newLinkedList();
  long keyRotationTimestamp=vKeyRotationTimestamp;
  if (keyRotationTimestamp == 0)   return results;
  boolean allChainsRotating=true;
  for (  DeterministicKeyChain chain : keychain.getDeterministicKeyChains()) {
    if (chain.getEarliestKeyCreationTime() > vKeyRotationTimestamp) {
      allChainsRotating=false;
      break;
    }
  }
  if (allChainsRotating) {
    try {
      if (keychain.getImportedKeys().isEmpty()) {
        log.info("String_Node_Str");
        keychain.createAndActivateNewHDChain();
      }
 else {
        log.info("String_Node_Str");
        keychain.upgradeToDeterministic(keyRotationTimestamp,aesKey);
        log.info("String_Node_Str");
      }
    }
 catch (    AllRandomKeysRotating rotating) {
      log.info("String_Node_Str");
      keychain.createAndActivateNewHDChain();
    }
    saveNow();
  }
  Transaction tx;
  do {
    tx=rekeyOneBatch(keyRotationTimestamp,aesKey,results,sign);
    if (tx != null)     results.add(tx);
  }
 while (tx != null && tx.getInputs().size() == KeyTimeCoinSelector.MAX_SIMULTANEOUS_INPUTS);
  return results;
}

Fixed version (ground truth):
private List<Transaction> maybeRotateKeys(@Nullable KeyParameter aesKey,boolean sign) throws DeterministicUpgradeRequiresPassword {
  checkState(lock.isHeldByCurrentThread());
  List<Transaction> results=Lists.newLinkedList();
  long keyRotationTimestamp=vKeyRotationTimestamp;
  if (keyRotationTimestamp == 0)   return results;
  boolean allChainsRotating=true;
  for (  DeterministicKeyChain chain : keychain.getDeterministicKeyChains()) {
    if (chain.getEarliestKeyCreationTime() >= vKeyRotationTimestamp) {
      allChainsRotating=false;
      break;
    }
  }
  if (allChainsRotating) {
    try {
      if (keychain.getImportedKeys().isEmpty()) {
        log.info("String_Node_Str");
        keychain.createAndActivateNewHDChain();
      }
 else {
        log.info("String_Node_Str");
        keychain.upgradeToDeterministic(keyRotationTimestamp,aesKey);
        log.info("String_Node_Str");
      }
    }
 catch (    AllRandomKeysRotating rotating) {
      log.info("String_Node_Str");
      keychain.createAndActivateNewHDChain();
    }
    saveNow();
  }
  Transaction tx;
  do {
    tx=rekeyOneBatch(keyRotationTimestamp,aesKey,results,sign);
    if (tx != null)     results.add(tx);
  }
 while (tx != null && tx.getInputs().size() == KeyTimeCoinSelector.MAX_SIMULTANEOUS_INPUTS);
  return results;
}
Program: 85673
Project: 85673
Buggy source:
private List<Transaction> maybeRotateKeys(@Nullable KeyParameter aesKey,boolean sign) throws DeterministicUpgradeRequiresPassword {
  checkState(lock.isHeldByCurrentThread());
  List<Transaction> results=Lists.newLinkedList();
  long keyRotationTimestamp=vKeyRotationTimestamp;
  if (keyRotationTimestamp == 0)   return results;
  boolean allChainsRotating=true;
  for (  DeterministicKeyChain chain : keychain.getDeterministicKeyChains()) {
    if (chain.getEarliestKeyCreationTime() > vKeyRotationTimestamp) {
      allChainsRotating=false;
      break;
    }
  }
  if (allChainsRotating) {
    try {
      if (keychain.getImportedKeys().isEmpty()) {
        log.info("String_Node_Str");
        keychain.createAndActivateNewHDChain();
      }
 else {
        log.info("String_Node_Str");
        keychain.upgradeToDeterministic(keyRotationTimestamp,aesKey);
        log.info("String_Node_Str");
      }
    }
 catch (    AllRandomKeysRotating rotating) {
      log.info("String_Node_Str");
      keychain.createAndActivateNewHDChain();
    }
    saveNow();
  }
  Transaction tx;
  do {
    tx=rekeyOneBatch(keyRotationTimestamp,aesKey,results,sign);
    if (tx != null)     results.add(tx);
  }
 while (tx != null && tx.getInputs().size() == KeyTimeCoinSelector.MAX_SIMULTANEOUS_INPUTS);
  return results;
}

Fixed version (ground truth):
private List<Transaction> maybeRotateKeys(@Nullable KeyParameter aesKey,boolean sign) throws DeterministicUpgradeRequiresPassword {
  checkState(lock.isHeldByCurrentThread());
  List<Transaction> results=Lists.newLinkedList();
  long keyRotationTimestamp=vKeyRotationTimestamp;
  if (keyRotationTimestamp == 0)   return results;
  boolean allChainsRotating=true;
  for (  DeterministicKeyChain chain : keychain.getDeterministicKeyChains()) {
    if (chain.getEarliestKeyCreationTime() >= vKeyRotationTimestamp) {
      allChainsRotating=false;
      break;
    }
  }
  if (allChainsRotating) {
    try {
      if (keychain.getImportedKeys().isEmpty()) {
        log.info("String_Node_Str");
        keychain.createAndActivateNewHDChain();
      }
 else {
        log.info("String_Node_Str");
        keychain.upgradeToDeterministic(keyRotationTimestamp,aesKey);
        log.info("String_Node_Str");
      }
    }
 catch (    AllRandomKeysRotating rotating) {
      log.info("String_Node_Str");
      keychain.createAndActivateNewHDChain();
    }
    saveNow();
  }
  Transaction tx;
  do {
    tx=rekeyOneBatch(keyRotationTimestamp,aesKey,results,sign);
    if (tx != null)     results.add(tx);
  }
 while (tx != null && tx.getInputs().size() == KeyTimeCoinSelector.MAX_SIMULTANEOUS_INPUTS);
  return results;
}
Program: 85675
Project: 85675
Buggy source:
/** 
 * Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
 */
public boolean isShortestPossiblePushData(){
  checkState(isPushData());
  if (data.length == 0)   return opcode == OP_0;
  if (data.length == 1) {
    byte b=data[0];
    if (b >= 0x01 && b <= 0x10)     return opcode == OP_1 + b - 1;
    if (b == 0x81)     return opcode == OP_1NEGATE;
  }
  if (data.length < OP_PUSHDATA1)   return opcode == data.length;
  if (data.length < 256)   return opcode == OP_PUSHDATA1;
  if (data.length < 65536)   return opcode == OP_PUSHDATA2;
  return opcode == OP_PUSHDATA4;
}

Fixed version (ground truth):
/** 
 * Called on a pushdata chunk, returns true if it uses the smallest possible way (according to BIP62) to push the data.
 */
public boolean isShortestPossiblePushData(){
  checkState(isPushData());
  if (data.length == 0)   return opcode == OP_0;
  if (data.length == 1) {
    byte b=data[0];
    if (b >= 0x01 && b <= 0x10)     return opcode == OP_1 + b - 1;
    if ((b & 0xFF) == 0x81)     return opcode == OP_1NEGATE;
  }
  if (data.length < OP_PUSHDATA1)   return opcode == data.length;
  if (data.length < 256)   return opcode == OP_PUSHDATA1;
  if (data.length < 65536)   return opcode == OP_PUSHDATA2;
  return opcode == OP_PUSHDATA4;
}
Program: 85676
Project: 85676
Buggy source:
public void write(OutputStream stream) throws IOException {
  if (isOpCode()) {
    checkState(data == null);
    stream.write(opcode);
  }
 else   if (data != null) {
    checkNotNull(data);
    if (opcode < OP_PUSHDATA1) {
      checkState(data.length == opcode);
      stream.write(opcode);
    }
 else     if (opcode == OP_PUSHDATA1) {
      checkState(data.length <= 0xFF);
      stream.write(OP_PUSHDATA1);
      stream.write(data.length);
    }
 else     if (opcode == OP_PUSHDATA2) {
      checkState(data.length <= 0xFFFF);
      stream.write(OP_PUSHDATA2);
      stream.write(0xFF & data.length);
      stream.write(0xFF & (data.length >> 8));
    }
 else     if (opcode == OP_PUSHDATA4) {
      checkState(data.length <= Script.MAX_SCRIPT_ELEMENT_SIZE);
      stream.write(OP_PUSHDATA4);
      Utils.uint32ToByteStreamLE(data.length,stream);
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    stream.write(data);
  }
 else {
    stream.write(opcode);
  }
}

Fixed version (ground truth):
public void write(OutputStream stream) throws IOException {
  if (isOpCode()) {
    checkState(data == null);
    stream.write(opcode);
  }
 else   if (data != null) {
    if (opcode < OP_PUSHDATA1) {
      checkState(data.length == opcode);
      stream.write(opcode);
    }
 else     if (opcode == OP_PUSHDATA1) {
      checkState(data.length <= 0xFF);
      stream.write(OP_PUSHDATA1);
      stream.write(data.length);
    }
 else     if (opcode == OP_PUSHDATA2) {
      checkState(data.length <= 0xFFFF);
      stream.write(OP_PUSHDATA2);
      stream.write(0xFF & data.length);
      stream.write(0xFF & (data.length >> 8));
    }
 else     if (opcode == OP_PUSHDATA4) {
      checkState(data.length <= Script.MAX_SCRIPT_ELEMENT_SIZE);
      stream.write(OP_PUSHDATA4);
      Utils.uint32ToByteStreamLE(data.length,stream);
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    stream.write(data);
  }
 else {
    stream.write(opcode);
  }
}
Program: 85677
Project: 85677
Buggy source:
/** 
 * Checks the output to see if the script violates a standardness rule. Not complete.
 */
public static RuleViolation isOutputStandard(TransactionOutput output){
  if (MIN_ANALYSIS_NONDUST_OUTPUT.compareTo(output.getValue()) > 0)   return RuleViolation.DUST;
  for (  ScriptChunk chunk : output.getScriptPubKey().getChunks()) {
    if (chunk.isPushData() && !chunk.isShortestPossiblePushData())     return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA;
  }
  return RuleViolation.NONE;
}

Fixed version (ground truth):
/** 
 * Checks the output to see if the script violates a standardness rule. Not complete.
 */
public static RuleViolation isOutputStandard(TransactionOutput output){
  if (output.getValue().compareTo(MIN_ANALYSIS_NONDUST_OUTPUT) < 0)   return RuleViolation.DUST;
  for (  ScriptChunk chunk : output.getScriptPubKey().getChunks()) {
    if (chunk.isPushData() && !chunk.isShortestPossiblePushData())     return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA;
  }
  return RuleViolation.NONE;
}