### Question:
TimelinessValidator { public boolean validateBlockHash(byte[] blockHash,long ancestorBlockNum,byte[] ancestorBlockHash){ if(maxAncestorBlockNum == 0 && blockHash != null && ancestorBlockNum == 0 && ancestorBlockHash == null){ return true; } ValidateBlock ancestorBlock = ancestorBlockCache.get(ancestorBlockNum); if(ancestorBlock == null||ancestorBlock.getBlockHash().length==0 || !Arrays.equals(ancestorBlock.getBlockHash(),ancestorBlockHash)){ return false; } for(long i = ancestorBlockNum;i <= maxAncestorBlockNum;i++){ if(Arrays.equals(ancestorBlockCache.get(i).getBlockHash(),blockHash)){ return false; } } ValidateBlock pendingBlock = pendingBlockCache.get(new ByteArrayWrapper(blockHash)); if(pendingBlock != null){ return false; } return true; } TimelinessValidator();  TimelinessValidator(Map<Long,ValidateBlock> map, long maxAncestorBlockNum); boolean validateBlockHash(byte[] blockHash,long ancestorBlockNum,byte[] ancestorBlockHash); boolean addBlockHash(byte[] blockHash, long ancestorBlockNum, byte[] ancestorBlockHash, HashSet<ByteArrayWrapper> txSet); boolean addAncestorBlockHash(byte[] blockHash,long blockNum,byte[] ancestorBlockHash,long ancestorBlockNum,HashSet<ByteArrayWrapper> txSet); boolean validateTxHash(byte[] txHash,long ancestorBlockNum,byte[] ancestorBlockHash); boolean addTxHash(byte[] txHash,long ancestorBlockNum,byte[] ancestorBlockHash);  }### Answer:
@Test public void validateBlockHash() { TimelinessValidator timelinessValidator = this.addHash(); Assert.assertTrue(timelinessValidator.validateBlockHash(blockHash,ancestorBlockNum,ancestorBlockHash)); Assert.assertFalse(timelinessValidator.validateBlockHash(blockHash,ancestorBlockNum+1,ancestorBlockHash)); }