### Question:
PbftBlockStore extends AbstractBlockStore<PbftProto.PbftBlock> { @Override public PbftBlock get(Sha3Hash key) { try { return new PbftBlock(db.get(key.getBytes())); } catch (Exception e) { log.debug("get() is failed. {}", e.getMessage()); return null; } } PbftBlockStore(DbSource<byte[], byte[]> dbSource); @Override PbftBlock get(Sha3Hash key);  }### Answer:
@Test public void putGetTest() { byte[] newHash = blockKeyStore.get(this.pbftBlock.getIndex()); PbftBlock newBlock = blockStore.get(Sha3Hash.createByHashed(newHash)); assertEquals(newBlock, this.pbftBlock); assertTrue(blockStore.contains(this.pbftBlock.getHash())); assertFalse(blockStore.contains(Sha3Hash.createByHashed(Constants.EMPTY_HASH))); }
@Test public void closeTest() { blockStore.close(); assertEquals(null, blockStore.get(this.pbftBlock.getHash())); }
@Test public void memoryTest() throws InterruptedException { TestConstants.PerformanceTest.apply(); long testNumber = 1000; PbftBlock result; List<PbftBlock> resultList = new ArrayList<>(); log.debug("Before free memory: " + Runtime.getRuntime().freeMemory()); for (long l = 0L; l < testNumber; l++) { Sha3Hash key = Sha3Hash.createByHashed(HashUtil.sha3(ByteUtil.longToBytes(l))); this.blockStore.put(key, this.pbftBlock); result = this.blockStore.get(key); resultList.add(result); } for (PbftBlock pbftBlock : resultList) { pbftBlock.clear(); } resultList.clear(); log.debug("After free memory: " + Runtime.getRuntime().freeMemory()); System.gc(); Thread.sleep(5000); }
@Test public void memoryTest2() throws InterruptedException { TestConstants.PerformanceTest.apply(); long testNumber = 1000; for (long l = 1; l < testNumber; l++) { Block newBlock = new TestUtils(wallet).sampleBlock(l, block.getHash()); PbftBlock newPbftBlock = new PbftBlock(newBlock, this.pbftMessageSet); this.blockKeyStore.put(l, newPbftBlock.getHash().getBytes()); this.blockStore.put(newPbftBlock.getHash(), newPbftBlock); } for (long l = 0; l < testNumber; l++) { log.debug("blockKeyStore: " + l + " " + Hex.toHexString(this.blockKeyStore.get(l))); log.debug("blockStore: " + this.blockStore.get(Sha3Hash.createByHashed(blockKeyStore.get(l))).getIndex()); } System.gc(); Thread.sleep(5000); }