### Question:
WitnessProductBlockService { public void validWitnessProductTwoBlock(BlockCapsule block) { try { BlockCapsule blockCapsule = historyBlockCapsuleCache.getIfPresent(block.getNum()); if (blockCapsule != null && Arrays.equals(blockCapsule.getWitnessAddress().toByteArray(), block.getWitnessAddress().toByteArray()) && !Arrays.equals(block.getBlockId().getBytes(), blockCapsule.getBlockId().getBytes())) { String key = ByteArray.toHexString(block.getWitnessAddress().toByteArray()); if (!cheatWitnessInfoMap.containsKey(key)) { CheatWitnessInfo cheatWitnessInfo = new CheatWitnessInfo(); cheatWitnessInfoMap.put(key, cheatWitnessInfo); } cheatWitnessInfoMap.get(key).clear().setTime(System.currentTimeMillis()) .setLatestBlockNum(block.getNum()).add(block).add(blockCapsule).increment(); } else { historyBlockCapsuleCache.put(block.getNum(), block); } } catch (Exception e) { logger.error("valid witness same time product two block fail! blockNum: {}, blockHash: {}", block.getNum(), block.getBlockId().toString(), e); } }  void validWitnessProductTwoBlock(BlockCapsule block); Map<String, CheatWitnessInfo> queryCheatWitnessInfo();  }### Answer:
@Test public void validWitnessProductTwoBlockTest() { WitnessProductBlockService witnessProductBlockService = new WitnessProductBlockService(); BlockCapsule blockCapsule1 = new BlockCapsule( 1, Sha256Hash.wrap(ByteString.copyFrom( ByteArray.fromHexString( "0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b81"))), 1, ByteString.copyFromUtf8("testAddress")); witnessProductBlockService.validWitnessProductTwoBlock(blockCapsule1); Assert.assertEquals(0, witnessProductBlockService.queryCheatWitnessInfo().size()); BlockCapsule blockCapsule2 = new BlockCapsule( 1, Sha256Hash.wrap(ByteString.copyFrom( ByteArray.fromHexString( "0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b82"))), 1, ByteString.copyFromUtf8("testAddress")); witnessProductBlockService.validWitnessProductTwoBlock(blockCapsule2); String key = ByteArray.toHexString(blockCapsule2.getWitnessAddress().toByteArray()); WitnessProductBlockService.CheatWitnessInfo block = witnessProductBlockService.queryCheatWitnessInfo().get(key); Assert.assertEquals(1, witnessProductBlockService.queryCheatWitnessInfo().size()); Assert.assertEquals(2, block.getBlockCapsuleSet().size()); Assert.assertEquals(blockCapsule2.getNum(), block.getLatestBlockNum()); Assert.assertEquals(block.getBlockCapsuleSet().contains(blockCapsule2), true); Assert.assertEquals(block.getBlockCapsuleSet().contains(blockCapsule1), true); }