### Question:
Peer extends PeerSocketHandler { public ListenableFuture<Block> getBlock(Sha256Hash blockHash) { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash); return sendSingleGetData(getdata); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress);  Peer(NetworkParameters params, VersionMessage ver, PeerAddress remoteAddress,
				@Nullable AbstractBlockChain chain, @Nullable MemoryPool mempool);  Peer(NetworkParameters params, AbstractBlockChain blockChain, PeerAddress peerAddress, String thisSoftwareName, String thisSoftwareVersion); void addEventListener(PeerEventListener listener); void addEventListener(PeerEventListener listener, Executor executor); boolean removeEventListener(PeerEventListener listener); @Override String toString(); @Override void connectionClosed(); @Override void connectionOpened(); ListenableFuture<Peer> getConnectionOpenFuture(); ListenableFuture<List<Transaction>> downloadDependencies(Transaction tx); ListenableFuture<Block> getBlock(Sha256Hash blockHash); ListenableFuture<Transaction> getPeerMempoolTransaction(Sha256Hash hash); void setDownloadParameters(long secondsSinceEpoch, boolean useFilteredBlocks); void addWallet(Wallet wallet); void removeWallet(Wallet wallet); void startBlockChainDownload(); ListenableFuture<Long> ping(); long getLastPingTime(); long getPingTime(); int getPeerBlockHeightDifference(); boolean getDownloadData(); void setDownloadData(boolean downloadData); VersionMessage getPeerVersionMessage(); VersionMessage getVersionMessage(); long getBestHeight(); boolean setMinProtocolVersion(int minProtocolVersion); void setBloomFilter(BloomFilter filter); BloomFilter getBloomFilter();  }### Answer:
@Test public void getBlock() throws Exception { connect(); Block b1 = createFakeBlock(blockStore).block; blockChain.add(b1); Block b2 = makeSolvedTestBlock(b1); Block b3 = makeSolvedTestBlock(b2); Future<Block> resultFuture = peer.getBlock(b3.getHash()); assertFalse(resultFuture.isDone()); GetDataMessage message = (GetDataMessage) outbound(writeTarget); assertEquals(message.getItems().get(0).hash, b3.getHash()); assertFalse(resultFuture.isDone()); inbound(writeTarget, b3); Block b = resultFuture.get(); assertEquals(b, b3); }
@Test public void getLargeBlock() throws Exception { connect(); Block b1 = createFakeBlock(blockStore).block; blockChain.add(b1); Block b2 = makeSolvedTestBlock(b1); Transaction t = new Transaction(unitTestParams); t.addInput(b1.getTransactions().get(0).getOutput(0)); t.addOutput(new TransactionOutput(unitTestParams, t, BigInteger.ZERO, new byte[Block.MAX_BLOCK_SIZE - 1000])); b2.addTransaction(t); Future<Block> resultFuture = peer.getBlock(b2.getHash()); assertFalse(resultFuture.isDone()); GetDataMessage message = (GetDataMessage) outbound(writeTarget); assertEquals(message.getItems().get(0).hash, b2.getHash()); assertFalse(resultFuture.isDone()); inbound(writeTarget, b2); Block b = resultFuture.get(); assertEquals(b, b2); }