### Question:
DefaultBlockchain implements MutableBlockchain { @VisibleForTesting Set<Hash> getForks() { return new HashSet<>(blockchainStorage.getForkHeads()); } private  DefaultBlockchain(
      final Optional<Block> genesisBlock,
      final BlockchainStorage blockchainStorage,
      final MetricsSystem metricsSystem,
      final long reorgLoggingThreshold); static MutableBlockchain createMutable(
      final Block genesisBlock,
      final BlockchainStorage blockchainStorage,
      final MetricsSystem metricsSystem,
      final long reorgLoggingThreshold); static Blockchain create(
      final BlockchainStorage blockchainStorage,
      final MetricsSystem metricsSystem,
      final long reorgLoggingThreshold); @Override ChainHead getChainHead(); @Override Hash getChainHeadHash(); @Override long getChainHeadBlockNumber(); @Override BlockHeader getChainHeadHeader(); @Override Block getChainHeadBlock(); @Override Optional<BlockHeader> getBlockHeader(final long blockNumber); @Override Optional<BlockHeader> getBlockHeader(final Hash blockHeaderHash); @Override Optional<BlockBody> getBlockBody(final Hash blockHeaderHash); @Override Optional<List<TransactionReceipt>> getTxReceipts(final Hash blockHeaderHash); @Override Optional<Hash> getBlockHashByNumber(final long number); @Override Optional<Difficulty> getTotalDifficultyByHash(final Hash blockHeaderHash); @Override Optional<Transaction> getTransactionByHash(final Hash transactionHash); @Override Optional<TransactionLocation> getTransactionLocation(final Hash transactionHash); @Override synchronized void appendBlock(final Block block, final List<TransactionReceipt> receipts); @Override boolean rewindToBlock(final long blockNumber); @Override long observeBlockAdded(final BlockAddedObserver observer); @Override boolean removeObserver(final long observerId); @Override long observeChainReorg(final ChainReorgObserver observer); @Override boolean removeChainReorgObserver(final long observerId);  }### Answer:
@Test public void initializeNew() { final BlockDataGenerator gen = new BlockDataGenerator(); final KeyValueStorage kvStore = new InMemoryKeyValueStorage(); final Block genesisBlock = gen.genesisBlock(); final DefaultBlockchain blockchain = createMutableBlockchain(kvStore, genesisBlock); assertBlockDataIsStored(blockchain, genesisBlock, Collections.emptyList()); assertBlockIsHead(blockchain, genesisBlock); assertTotalDifficultiesAreConsistent(blockchain, genesisBlock); assertThat(blockchain.getForks()).isEmpty(); }
@Test public void initializeExisting() { final BlockDataGenerator gen = new BlockDataGenerator(); final KeyValueStorage kvStore = new InMemoryKeyValueStorage(); final Block genesisBlock = gen.genesisBlock(); createMutableBlockchain(kvStore, genesisBlock); final DefaultBlockchain blockchain = createMutableBlockchain(kvStore, genesisBlock); assertBlockDataIsStored(blockchain, genesisBlock, Collections.emptyList()); assertBlockIsHead(blockchain, genesisBlock); assertTotalDifficultiesAreConsistent(blockchain, genesisBlock); assertThat(blockchain.getForks()).isEmpty(); }