### Question:
BranchGroup { void addBlock(ConsensusBlock block) { addBlock(block, true); }  void addBranch(BlockChain blockChain); BlockChain getBranch(BranchId branchId); boolean isFullSynced(BranchId branchId); int verify(BranchId branchId, String contractVersion); Collection<BlockChain> getAllBranch(); Map<String, List<String>> addTransaction(Transaction tx); long getLastIndex(BranchId branchId); boolean isBranchExist(BranchId branchId); Collection<Transaction> getRecentTxs(BranchId branchId); Transaction getTxByHash(BranchId branchId, String id); void addBlock(ConsensusBlock block, boolean broadcast); ConsensusBlock getBlockByIndex(BranchId branchId, long index); ConsensusBlock getBlockByHash(BranchId branchId, String hash); Receipt getReceipt(BranchId branchId, String key); List<Transaction> getUnconfirmedTxs(BranchId branchId); Object query(BranchId branchId, String contractVersion, String method, JsonObject params);  }### Answer:
@Test public void addBlock() { ContractManager contractManager = branchGroup.getBranch(tx.getBranchId()).getContractManager(); Map<String, List<String>> errLogs = branchGroup.addTransaction(tx); branchGroup.addBlock(block); ConsensusBlock newBlock = BlockChainTestUtils.createNextBlock(Collections.singletonList(tx), block, contractManager); branchGroup.addBlock(newBlock); assertThat(branchGroup.getLastIndex(newBlock.getBranchId())).isEqualTo(2); assertThat(branchGroup.getBlockByIndex(newBlock.getBranchId(), 2).getHash()) .isEqualTo(newBlock.getHash()); Receipt receipt = branchGroup.getBranch(tx.getBranchId()).getBlockChainManager() .getReceipt(tx.getHash().toString()); if (getBalance(tx.getAddress().toString()).equals(BigInteger.ZERO)) { assertThat(receipt.getStatus()).isEqualTo(ExecuteStatus.ERROR); Assert.assertEquals(1, errLogs.size()); } else { assertThat(receipt.getStatus()).isNotEqualTo(ExecuteStatus.ERROR); Assert.assertEquals(0, errLogs.size()); Transaction foundTx = branchGroup.getTxByHash(tx.getBranchId(), tx.getHash()); assertThat(foundTx.getHash()).isEqualTo(tx.getHash()); } }