Program: 85649
Project: 85649
Buggy source:
public static void main(String[] args) throws Exception {
  BriefLogFormatter.init();
  System.out.println("String_Node_Str");
  boolean runLargeReorgs=args.length > 1 && Integer.parseInt(args[1]) == 1;
  params=RegTestParams.get();
  File blockFile=File.createTempFile("String_Node_Str","String_Node_Str");
  blockFile.deleteOnExit();
  FullBlockTestGenerator generator=new FullBlockTestGenerator(params);
  final RuleList blockList=generator.getBlocksToTest(false,runLargeReorgs,blockFile);
  final Map<Sha256Hash,Block> preloadedBlocks=new HashMap<Sha256Hash,Block>();
  final Iterator<Block> blocks=new BlockFileLoader(params,Arrays.asList(blockFile));
  try {
    store=new H2FullPrunedBlockStore(params,args.length > 0 ? args[0] : "String_Node_Str",blockList.maximumReorgBlockCount);
    ((H2FullPrunedBlockStore)store).resetStore();
    chain=new FullPrunedBlockChain(params,store);
  }
 catch (  BlockStoreException e) {
    e.printStackTrace();
    System.exit(1);
  }
  peers=new PeerGroup(params,chain);
  peers.setUserAgent("String_Node_Str","String_Node_Str");
  peers.getVersionMessage().localServices=VersionMessage.NODE_NETWORK;
  Preconditions.checkState(peers.getVersionMessage().hasBlockChain());
  peers.addAddress(new PeerAddress(InetAddress.getByName("String_Node_Str"),args.length > 2 ? Integer.parseInt(args[2]) : params.getPort()));
  final BlockWrapper currentBlock=new BlockWrapper();
  final Set<Sha256Hash> blocksRequested=Collections.synchronizedSet(new HashSet<Sha256Hash>());
  final AtomicInteger unexpectedInvs=new AtomicInteger(0);
  peers.addEventListener(new AbstractPeerEventListener(){
    @Override public void onPeerConnected(    Peer peer,    int peerCount){
      super.onPeerConnected(peer,peerCount);
      log.info("String_Node_Str");
      bitcoind=peer;
    }
    @Override public void onPeerDisconnected(    Peer peer,    int peerCount){
      super.onPeerDisconnected(peer,peerCount);
      log.error("String_Node_Str");
      System.exit(1);
    }
    @Override public Message onPreMessageReceived(    Peer peer,    Message m){
      if (m instanceof HeadersMessage) {
        for (        Block block : ((HeadersMessage)m).getBlockHeaders())         bitcoindChainHead=block.getHash();
        return null;
      }
 else       if (m instanceof Block) {
        log.error("String_Node_Str");
        System.exit(1);
      }
 else       if (m instanceof GetDataMessage) {
        for (        InventoryItem item : ((GetDataMessage)m).items)         if (item.type == InventoryItem.Type.Block) {
          try {
            if (currentBlock.block.getHash().equals(item.hash))             bitcoind.sendMessage(currentBlock.block);
 else {
              Block nextBlock=preloadedBlocks.get(item.hash);
              while (nextBlock == null || !nextBlock.getHash().equals(item.hash)) {
                nextBlock=blocks.next();
                preloadedBlocks.put(nextBlock.getHash(),nextBlock);
              }
            }
          }
 catch (          IOException e) {
            throw new RuntimeException(e);
          }
          blocksRequested.add(item.hash);
        }
        return null;
      }
 else       if (m instanceof GetHeadersMessage) {
        try {
          LinkedList<Block> headers=new LinkedList<Block>();
          Block it=blockList.hashHeaderMap.get(currentBlock.block.getHash());
          while (it != null) {
            headers.addFirst(it);
            it=blockList.hashHeaderMap.get(it.getPrevBlockHash());
          }
          LinkedList<Block> sendHeaders=new LinkedList<Block>();
          for (          Sha256Hash hash : ((GetHeadersMessage)m).getLocator()) {
            boolean found=false;
            for (            Block b : headers) {
              if (found) {
                sendHeaders.addLast(b);
                if (b.getHash().equals(((GetHeadersMessage)m).getStopHash()))                 break;
              }
 else               if (b.getHash().equals(hash))               found=true;
            }
            if (found)             break;
          }
          bitcoind.sendMessage(new HeadersMessage(params,sendHeaders));
        }
 catch (        Exception e) {
          throw new RuntimeException(e);
        }
        return null;
      }
 else       if (m instanceof InventoryMessage) {
        if (mostRecentInv != null) {
          log.error("String_Node_Str");
          unexpectedInvs.incrementAndGet();
        }
        mostRecentInv=(InventoryMessage)m;
      }
      return m;
    }
  }
,Threading.SAME_THREAD);
  peers.addPeerFilterProvider(new PeerFilterProvider(){
    @Override public long getEarliestKeyCreationTime(){
      return Long.MAX_VALUE;
    }
    @Override public int getBloomFilterElementCount(){
      return 1;
    }
    @Override public boolean isRequiringUpdateAllBloomFilter(){
      return false;
    }
    @Override public void beginBloomFilterCalculation(){
    }
    @Override public void endBloomFilterCalculation(){
    }
    @Override public BloomFilter getBloomFilter(    int size,    double falsePositiveRate,    long nTweak){
      BloomFilter filter=new BloomFilter(1,0.99,0);
      filter.setMatchAll();
      return filter;
    }
  }
);
  bitcoindChainHead=params.getGenesisBlock().getHash();
  peers.startAsync();
  peers.setMaxConnections(1);
  peers.downloadBlockChain();
  while (bitcoind == null)   Thread.sleep(50);
  ArrayList<Sha256Hash> locator=new ArrayList<Sha256Hash>(1);
  locator.add(params.getGenesisBlock().getHash());
  Sha256Hash hashTo=new Sha256Hash("String_Node_Str");
  int differingBlocks=0;
  int invalidBlocks=0;
  int mempoolRulesFailed=0;
  int utxoRulesFailed=0;
  for (  Rule rule : blockList.list) {
    if (rule instanceof BlockAndValidity) {
      BlockAndValidity block=(BlockAndValidity)rule;
      boolean threw=false;
      Block nextBlock=preloadedBlocks.get(((BlockAndValidity)rule).blockHash);
      for (int i=0; i < 1 || nextBlock == null || !nextBlock.getHash().equals(((BlockAndValidity)rule).blockHash); i++) {
        Block b=blocks.next();
        preloadedBlocks.put(b.getHash(),b);
        nextBlock=preloadedBlocks.get(((BlockAndValidity)rule).blockHash);
      }
      currentBlock.block=nextBlock;
      log.info("String_Node_Str",currentBlock.block.getHash());
      try {
        if (chain.add(nextBlock) != block.connects) {
          log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
          invalidBlocks++;
        }
      }
 catch (      VerificationException e) {
        threw=true;
        if (!block.throwsException) {
          log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
          e.printStackTrace();
          invalidBlocks++;
        }
 else         if (block.connects) {
          log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
          e.printStackTrace();
          invalidBlocks++;
        }
      }
      if (!threw && block.throwsException) {
        log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
        invalidBlocks++;
      }
 else       if (!chain.getChainHead().getHeader().getHash().equals(block.hashChainTipAfterBlock)) {
        log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
        invalidBlocks++;
      }
 else       if (chain.getChainHead().getHeight() != block.heightAfterBlock) {
        log.error("String_Node_Str" + block.ruleName);
        invalidBlocks++;
      }
      boolean shouldntRequest=blocksRequested.contains(nextBlock.getHash());
      if (shouldntRequest)       blocksRequested.remove(nextBlock.getHash());
      InventoryMessage message=new InventoryMessage(params);
      message.addBlock(nextBlock);
      bitcoind.sendMessage(message);
      for (int i=0; !shouldntRequest && !blocksRequested.contains(nextBlock.getHash()); i++) {
        if (i % 20 == 19)         log.error("String_Node_Str" + block.ruleName + "String_Node_Str"+ nextBlock.getHash());
        Thread.sleep(50);
      }
      if (shouldntRequest) {
        Thread.sleep(100);
        if (blocksRequested.contains(nextBlock.getHash())) {
          log.error("String_Node_Str" + block.ruleName + "String_Node_Str"+ nextBlock.getHash());
          invalidBlocks++;
        }
      }
      if (block.throwsException)       blocksRequested.remove(nextBlock.getHash());
      locator.clear();
      locator.add(bitcoindChainHead);
      bitcoind.sendMessage(new GetHeadersMessage(params,locator,hashTo));
      bitcoind.ping().get();
      if (!chain.getChainHead().getHeader().getHash().equals(bitcoindChainHead)) {
        differingBlocks++;
        log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
      }
      log.info("String_Node_Str" + block.ruleName + "String_Node_Str");
    }
 else     if (rule instanceof MemoryPoolState) {
      MemoryPoolMessage message=new MemoryPoolMessage();
      bitcoind.sendMessage(message);
      bitcoind.ping().get();
      if (mostRecentInv == null && !((MemoryPoolState)rule).mempool.isEmpty()) {
        log.error("String_Node_Str" + rule.ruleName);
        mempoolRulesFailed++;
      }
 else       if (mostRecentInv != null && ((MemoryPoolState)rule).mempool.isEmpty()) {
        log.error("String_Node_Str" + rule.ruleName);
        mempoolRulesFailed++;
      }
 else       if (mostRecentInv != null) {
        Set<InventoryItem> originalRuleSet=new HashSet<InventoryItem>(((MemoryPoolState)rule).mempool);
        boolean matches=mostRecentInv.items.size() == ((MemoryPoolState)rule).mempool.size();
        for (        InventoryItem item : mostRecentInv.items)         if (!((MemoryPoolState)rule).mempool.remove(item))         matches=false;
        if (matches)         continue;
        log.error("String_Node_Str" + rule.ruleName);
        log.info("String_Node_Str");
        for (        InventoryItem item : mostRecentInv.items)         log.info("String_Node_Str" + item.hash);
        log.info("String_Node_Str");
        for (        InventoryItem item : originalRuleSet)         log.info("String_Node_Str" + item.hash);
        mempoolRulesFailed++;
      }
      mostRecentInv=null;
    }
 else     if (rule instanceof UTXORule) {
      UTXORule r=(UTXORule)rule;
      UTXOsMessage result=bitcoind.getUTXOs(r.query).get();
      if (!result.equals(r.result)) {
        log.error("String_Node_Str");
        log.error("String_Node_Str",r.result);
        log.error("String_Node_Str",result);
        utxoRulesFailed++;
      }
 else {
        log.info("String_Node_Str",r.ruleName,result);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
  }
  log.info("String_Node_Str" + "String_Node_Str" + differingBlocks + "String_Node_Str"+ "String_Node_Str"+ invalidBlocks+ "String_Node_Str"+ "String_Node_Str"+ mempoolRulesFailed+ "String_Node_Str"+ "String_Node_Str"+ utxoRulesFailed+ "String_Node_Str"+ "String_Node_Str"+ unexpectedInvs.get());
  System.exit(differingBlocks > 0 || invalidBlocks > 0 || mempoolRulesFailed > 0 || utxoRulesFailed > 0 || unexpectedInvs.get() > 0 ? 1 : 0);
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  BriefLogFormatter.init();
  System.out.println("String_Node_Str");
  boolean runLargeReorgs=args.length > 1 && Integer.parseInt(args[1]) == 1;
  params=RegTestParams.get();
  File blockFile=File.createTempFile("String_Node_Str","String_Node_Str");
  blockFile.deleteOnExit();
  FullBlockTestGenerator generator=new FullBlockTestGenerator(params);
  final RuleList blockList=generator.getBlocksToTest(false,runLargeReorgs,blockFile);
  final Map<Sha256Hash,Block> preloadedBlocks=new HashMap<Sha256Hash,Block>();
  final Iterator<Block> blocks=new BlockFileLoader(params,Arrays.asList(blockFile));
  try {
    store=new H2FullPrunedBlockStore(params,args.length > 0 ? args[0] : "String_Node_Str",blockList.maximumReorgBlockCount);
    ((H2FullPrunedBlockStore)store).resetStore();
    chain=new FullPrunedBlockChain(params,store);
  }
 catch (  BlockStoreException e) {
    e.printStackTrace();
    System.exit(1);
  }
  peers=new PeerGroup(params,chain);
  peers.setUserAgent("String_Node_Str","String_Node_Str");
  peers.getVersionMessage().localServices=VersionMessage.NODE_NETWORK;
  Preconditions.checkState(peers.getVersionMessage().hasBlockChain());
  peers.addAddress(new PeerAddress(InetAddress.getByName("String_Node_Str"),args.length > 2 ? Integer.parseInt(args[2]) : params.getPort()));
  final BlockWrapper currentBlock=new BlockWrapper();
  final Set<Sha256Hash> blocksRequested=Collections.synchronizedSet(new HashSet<Sha256Hash>());
  final AtomicInteger unexpectedInvs=new AtomicInteger(0);
  peers.addEventListener(new AbstractPeerEventListener(){
    @Override public void onPeerConnected(    Peer peer,    int peerCount){
      super.onPeerConnected(peer,peerCount);
      log.info("String_Node_Str");
      bitcoind=peer;
    }
    @Override public void onPeerDisconnected(    Peer peer,    int peerCount){
      super.onPeerDisconnected(peer,peerCount);
      log.error("String_Node_Str");
      System.exit(1);
    }
    @Override public Message onPreMessageReceived(    Peer peer,    Message m){
      if (m instanceof HeadersMessage) {
        for (        Block block : ((HeadersMessage)m).getBlockHeaders())         bitcoindChainHead=block.getHash();
        return null;
      }
 else       if (m instanceof Block) {
        log.error("String_Node_Str");
        System.exit(1);
      }
 else       if (m instanceof GetDataMessage) {
        for (        InventoryItem item : ((GetDataMessage)m).items)         if (item.type == InventoryItem.Type.Block) {
          try {
            if (currentBlock.block.getHash().equals(item.hash))             bitcoind.sendMessage(currentBlock.block);
 else {
              Block nextBlock=preloadedBlocks.get(item.hash);
              while (nextBlock == null || !nextBlock.getHash().equals(item.hash)) {
                nextBlock=blocks.next();
                preloadedBlocks.put(nextBlock.getHash(),nextBlock);
              }
            }
          }
 catch (          IOException e) {
            throw new RuntimeException(e);
          }
          blocksRequested.add(item.hash);
        }
        return null;
      }
 else       if (m instanceof GetHeadersMessage) {
        try {
          LinkedList<Block> headers=new LinkedList<Block>();
          Block it=blockList.hashHeaderMap.get(currentBlock.block.getHash());
          while (it != null) {
            headers.addFirst(it);
            it=blockList.hashHeaderMap.get(it.getPrevBlockHash());
          }
          LinkedList<Block> sendHeaders=new LinkedList<Block>();
          for (          Sha256Hash hash : ((GetHeadersMessage)m).getLocator()) {
            boolean found=false;
            for (            Block b : headers) {
              if (found) {
                sendHeaders.addLast(b);
                if (b.getHash().equals(((GetHeadersMessage)m).getStopHash()))                 break;
              }
 else               if (b.getHash().equals(hash))               found=true;
            }
            if (found)             break;
          }
          bitcoind.sendMessage(new HeadersMessage(params,sendHeaders));
        }
 catch (        Exception e) {
          throw new RuntimeException(e);
        }
        return null;
      }
 else       if (m instanceof InventoryMessage) {
        if (mostRecentInv != null) {
          log.error("String_Node_Str");
          unexpectedInvs.incrementAndGet();
        }
        mostRecentInv=(InventoryMessage)m;
      }
      return m;
    }
  }
,Threading.SAME_THREAD);
  peers.addPeerFilterProvider(new PeerFilterProvider(){
    @Override public long getEarliestKeyCreationTime(){
      return Long.MAX_VALUE;
    }
    @Override public int getBloomFilterElementCount(){
      return 1;
    }
    @Override public boolean isRequiringUpdateAllBloomFilter(){
      return false;
    }
    @Override public void beginBloomFilterCalculation(){
    }
    @Override public void endBloomFilterCalculation(){
    }
    @Override public BloomFilter getBloomFilter(    int size,    double falsePositiveRate,    long nTweak){
      BloomFilter filter=new BloomFilter(1,0.99,0);
      filter.setMatchAll();
      return filter;
    }
  }
);
  bitcoindChainHead=params.getGenesisBlock().getHash();
  peers.startAsync();
  peers.setMaxConnections(1);
  peers.downloadBlockChain();
  while (bitcoind == null)   Thread.sleep(50);
  ArrayList<Sha256Hash> locator=new ArrayList<Sha256Hash>(1);
  locator.add(params.getGenesisBlock().getHash());
  Sha256Hash hashTo=new Sha256Hash("String_Node_Str");
  int differingBlocks=0;
  int invalidBlocks=0;
  int mempoolRulesFailed=0;
  int utxoRulesFailed=0;
  for (  Rule rule : blockList.list) {
    if (rule instanceof BlockAndValidity) {
      BlockAndValidity block=(BlockAndValidity)rule;
      boolean threw=false;
      Block nextBlock=preloadedBlocks.get(((BlockAndValidity)rule).blockHash);
      for (int i=0; i < 1 || nextBlock == null || !nextBlock.getHash().equals(((BlockAndValidity)rule).blockHash); i++) {
        Block b=blocks.next();
        preloadedBlocks.put(b.getHash(),b);
        nextBlock=preloadedBlocks.get(((BlockAndValidity)rule).blockHash);
      }
      currentBlock.block=nextBlock;
      log.info("String_Node_Str",currentBlock.block.getHash());
      try {
        if (chain.add(nextBlock) != block.connects) {
          log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
          invalidBlocks++;
        }
      }
 catch (      VerificationException e) {
        threw=true;
        if (!block.throwsException) {
          log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
          e.printStackTrace();
          invalidBlocks++;
        }
 else         if (block.connects) {
          log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
          e.printStackTrace();
          invalidBlocks++;
        }
      }
      if (!threw && block.throwsException) {
        log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
        invalidBlocks++;
      }
 else       if (!chain.getChainHead().getHeader().getHash().equals(block.hashChainTipAfterBlock)) {
        log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
        invalidBlocks++;
      }
 else       if (chain.getChainHead().getHeight() != block.heightAfterBlock) {
        log.error("String_Node_Str" + block.ruleName);
        invalidBlocks++;
      }
      boolean shouldntRequest=blocksRequested.contains(nextBlock.getHash());
      if (shouldntRequest)       blocksRequested.remove(nextBlock.getHash());
      InventoryMessage message=new InventoryMessage(params);
      message.addBlock(nextBlock);
      bitcoind.sendMessage(message);
      for (int i=0; !shouldntRequest && !blocksRequested.contains(nextBlock.getHash()); i++) {
        if (i % 20 == 19)         log.error("String_Node_Str" + block.ruleName + "String_Node_Str"+ nextBlock.getHash());
        Thread.sleep(50);
      }
      if (shouldntRequest) {
        Thread.sleep(100);
        if (blocksRequested.contains(nextBlock.getHash())) {
          log.error("String_Node_Str" + block.ruleName + "String_Node_Str"+ nextBlock.getHash());
          invalidBlocks++;
        }
      }
      if (block.throwsException)       blocksRequested.remove(nextBlock.getHash());
      locator.clear();
      locator.add(bitcoindChainHead);
      bitcoind.sendMessage(new GetHeadersMessage(params,locator,hashTo));
      bitcoind.ping().get();
      if (!chain.getChainHead().getHeader().getHash().equals(bitcoindChainHead)) {
        differingBlocks++;
        log.error("String_Node_Str" + block.ruleName + "String_Node_Str");
      }
      if (block.sendOnce)       preloadedBlocks.remove(nextBlock.getHash());
      log.info("String_Node_Str" + block.ruleName + "String_Node_Str");
    }
 else     if (rule instanceof MemoryPoolState) {
      MemoryPoolMessage message=new MemoryPoolMessage();
      bitcoind.sendMessage(message);
      bitcoind.ping().get();
      if (mostRecentInv == null && !((MemoryPoolState)rule).mempool.isEmpty()) {
        log.error("String_Node_Str" + rule.ruleName);
        mempoolRulesFailed++;
      }
 else       if (mostRecentInv != null && ((MemoryPoolState)rule).mempool.isEmpty()) {
        log.error("String_Node_Str" + rule.ruleName);
        mempoolRulesFailed++;
      }
 else       if (mostRecentInv != null) {
        Set<InventoryItem> originalRuleSet=new HashSet<InventoryItem>(((MemoryPoolState)rule).mempool);
        boolean matches=mostRecentInv.items.size() == ((MemoryPoolState)rule).mempool.size();
        for (        InventoryItem item : mostRecentInv.items)         if (!((MemoryPoolState)rule).mempool.remove(item))         matches=false;
        if (matches)         continue;
        log.error("String_Node_Str" + rule.ruleName);
        log.info("String_Node_Str");
        for (        InventoryItem item : mostRecentInv.items)         log.info("String_Node_Str" + item.hash);
        log.info("String_Node_Str");
        for (        InventoryItem item : originalRuleSet)         log.info("String_Node_Str" + item.hash);
        mempoolRulesFailed++;
      }
      mostRecentInv=null;
    }
 else     if (rule instanceof UTXORule) {
      UTXORule r=(UTXORule)rule;
      UTXOsMessage result=bitcoind.getUTXOs(r.query).get();
      if (!result.equals(r.result)) {
        log.error("String_Node_Str");
        log.error("String_Node_Str",r.result);
        log.error("String_Node_Str",result);
        utxoRulesFailed++;
      }
 else {
        log.info("String_Node_Str",r.ruleName,result);
      }
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
  }
  log.info("String_Node_Str" + "String_Node_Str" + differingBlocks + "String_Node_Str"+ "String_Node_Str"+ invalidBlocks+ "String_Node_Str"+ "String_Node_Str"+ mempoolRulesFailed+ "String_Node_Str"+ "String_Node_Str"+ utxoRulesFailed+ "String_Node_Str"+ "String_Node_Str"+ unexpectedInvs.get());
  System.exit(differingBlocks > 0 || invalidBlocks > 0 || mempoolRulesFailed > 0 || utxoRulesFailed > 0 || unexpectedInvs.get() > 0 ? 1 : 0);
}