### Question:
ChainInventoryMsgHandler implements TronMsgHandler { @Override public void processMessage(PeerConnection peer, TronMessage msg) throws P2pException { ChainInventoryMessage chainInventoryMessage = (ChainInventoryMessage) msg; check(peer, chainInventoryMessage); peer.setNeedSyncFromPeer(true); peer.setSyncChainRequested(null); Deque<BlockId> blockIdWeGet = new LinkedList<>(chainInventoryMessage.getBlockIds()); if (blockIdWeGet.size() == 1 && tronNetDelegate.containBlock(blockIdWeGet.peek())) { peer.setNeedSyncFromPeer(false); return; } while (!peer.getSyncBlockToFetch().isEmpty()) { if (peer.getSyncBlockToFetch().peekLast().equals(blockIdWeGet.peekFirst())) { break; } peer.getSyncBlockToFetch().pollLast(); } blockIdWeGet.poll(); peer.setRemainNum(chainInventoryMessage.getRemainNum()); peer.getSyncBlockToFetch().addAll(blockIdWeGet); synchronized (tronNetDelegate.getBlockLock()) { while (!peer.getSyncBlockToFetch().isEmpty() && tronNetDelegate .containBlock(peer.getSyncBlockToFetch().peek())) { BlockId blockId = peer.getSyncBlockToFetch().pop(); peer.setBlockBothHave(blockId); logger.info("Block {} from {} is processed", blockId.getString(), peer.getNode().getHost()); } } if ((chainInventoryMessage.getRemainNum() == 0 && !peer.getSyncBlockToFetch().isEmpty()) || (chainInventoryMessage.getRemainNum() != 0 && peer.getSyncBlockToFetch().size() > NodeConstant.SYNC_FETCH_BATCH_NUM)) { syncService.setFetchFlag(true); } else { syncService.syncNext(peer); } }  @Override void processMessage(PeerConnection peer, TronMessage msg);  }### Answer:
@Test public void testProcessMessage() { try { handler.processMessage(peer, msg); } catch (P2pException e) { Assert.assertTrue(e.getMessage().equals("not send syncBlockChainMsg")); } peer.setSyncChainRequested(new Pair<>(new LinkedList<>(), System.currentTimeMillis())); try { handler.processMessage(peer, msg); } catch (P2pException e) { Assert.assertTrue(e.getMessage().equals("blockIds is empty")); } long size = NodeConstant.SYNC_FETCH_BATCH_NUM + 2; for (int i = 0; i < size; i++) { blockIds.add(new BlockId()); } msg = new ChainInventoryMessage(blockIds, 0L); try { handler.processMessage(peer, msg); } catch (P2pException e) { Assert.assertTrue(e.getMessage().equals("big blockIds size: " + size)); } blockIds.clear(); size = NodeConstant.SYNC_FETCH_BATCH_NUM / 100; for (int i = 0; i < size; i++) { blockIds.add(new BlockId()); } msg = new ChainInventoryMessage(blockIds, 100L); try { handler.processMessage(peer, msg); } catch (P2pException e) { Assert.assertTrue(e.getMessage().equals("remain: 100, blockIds size: " + size)); } }