### Question:
RecentChainData implements StoreUpdateHandler { public SafeFuture<Optional<BeaconState>> retrieveStateInEffectAtSlot(final UInt64 slot) { Optional<Bytes32> rootAtSlot = getBlockRootBySlot(slot); if (rootAtSlot.isEmpty()) { return EmptyStoreResults.EMPTY_STATE_FUTURE; } return store.retrieveBlockState(rootAtSlot.get()); } RecentChainData(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final StoreConfig storeConfig,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateProvider,
      final StorageUpdateChannel storageUpdateChannel,
      final ProtoArrayStorageChannel protoArrayStorageChannel,
      final FinalizedCheckpointChannel finalizedCheckpointChannel,
      final ChainHeadChannel chainHeadChannel,
      final EventBus eventBus); void subscribeStoreInitialized(Runnable runnable); void subscribeBestBlockInitialized(Runnable runnable); SafeFuture<Void> initializeFromGenesis(final BeaconState genesisState); UInt64 getGenesisTime(); boolean isPreGenesis(); boolean isPreForkChoice(); UpdatableStore getStore(); NavigableMap<UInt64, Bytes32> getAncestorRootsOnHeadChain(
      final UInt64 startSlot, final UInt64 step, final UInt64 count); NavigableMap<UInt64, Bytes32> getAncestorsOnFork(final UInt64 startSlot, Bytes32 root); Optional<ForkChoiceStrategy> getForkChoiceStrategy(); StoreTransaction startStoreTransaction(); void updateHead(Bytes32 root, UInt64 currentSlot); void updateHead(Bytes32 root, UInt64 currentSlot, boolean syncing); Optional<UInt64> getCurrentSlot(); Optional<ForkInfo> getHeadForkInfo(); Optional<Fork> getNextFork(); Optional<ForkInfo> getForkInfoAtCurrentTime(); Optional<Bytes32> getBestBlockRoot(); Optional<BeaconBlockAndState> getHeadBlockAndState(); Optional<SignedBeaconBlock> getHeadBlock(); Optional<BeaconState> getBestState(); UInt64 getHeadSlot(); boolean containsBlock(final Bytes32 root); SafeFuture<Optional<BeaconBlock>> retrieveBlockByRoot(final Bytes32 root); SafeFuture<Optional<SignedBeaconBlock>> retrieveSignedBlockByRoot(final Bytes32 root); SafeFuture<Optional<BeaconState>> retrieveBlockState(final Bytes32 blockRoot); SafeFuture<Optional<BeaconState>> retrieveStateInEffectAtSlot(final UInt64 slot); Optional<Bytes32> getBlockRootBySlot(final UInt64 slot); Optional<Bytes32> getBlockRootBySlot(final UInt64 slot, final Bytes32 headBlockRoot); UInt64 getFinalizedEpoch(); Optional<Checkpoint> getFinalizedCheckpoint(); Optional<Checkpoint> getJustifiedCheckpoint(); @Override void onNewFinalizedCheckpoint(Checkpoint finalizedCheckpoint); SafeFuture<Optional<BeaconState>> retrieveCheckpointState(final Checkpoint checkpoint);  }### Answer:
@Test void retrieveStateInEffectAtSlot_returnEmptyWhenStoreNotSet() { final SafeFuture<Optional<BeaconState>> result = preGenesisStorageClient.retrieveStateInEffectAtSlot(UInt64.ZERO); assertThatSafeFuture(result).isCompletedWithEmptyOptional(); }
@Test public void retrieveStateInEffectAtSlot_returnGenesisStateWhenItIsTheBestState() { assertThat(recentChainData.retrieveStateInEffectAtSlot(genesis.getSlot())) .isCompletedWithValue(Optional.of(genesisState)); }
@Test public void retrieveStateInEffectAtSlot_returnStateFromLastBlockWhenHeadSlotIsEmpty() { assertThat(recentChainData.retrieveStateInEffectAtSlot(ONE)) .isCompletedWithValue(Optional.of(genesisState)); }
@Test public void retrieveStateInEffectAtSlot_returnHeadState() throws Exception { final SignedBlockAndState bestBlock = addNewBestBlock(recentChainData); assertThat(recentChainData.retrieveStateInEffectAtSlot(bestBlock.getSlot())) .isCompletedWithValue(Optional.of(bestBlock.getState())); }