### Question:
ForkChoice { public SafeFuture<BlockImportResult> onBlock( final SignedBeaconBlock block, Optional<BeaconState> preState) { return onForkChoiceThread( () -> { final ForkChoiceStrategy forkChoiceStrategy = getForkChoiceStrategy(); final StoreTransaction transaction = recentChainData.startStoreTransaction(); final CapturingIndexedAttestationProvider indexedAttestationProvider = new CapturingIndexedAttestationProvider(); final BlockImportResult result = on_block( transaction, block, preState, stateTransition, forkChoiceStrategy, beaconState -> transaction.putStateRoot( beaconState.hash_tree_root(), new SlotAndBlockRoot( beaconState.getSlot(), beaconState.getLatest_block_header().hash_tree_root())), indexedAttestationProvider); if (!result.isSuccessful()) { return SafeFuture.completedFuture(result); } indexedAttestationProvider.getIndexedAttestations().stream() .filter( attestation -> forkChoiceStrategy.contains(attestation.getData().getBeacon_block_root())) .forEach( indexedAttestation -> forkChoiceStrategy.onAttestation(transaction, indexedAttestation)); return transaction .commit() .thenRun(() -> updateForkChoiceForImportedBlock(block, forkChoiceStrategy, result)) .thenApply(__ -> result); }); } ForkChoice(
      final ForkChoiceExecutor forkChoiceExecutor,
      final RecentChainData recentChainData,
      final StateTransition stateTransition); void processHead(); void processHead(UInt64 nodeSlot, boolean syncing); SafeFuture<BlockImportResult> onBlock(
      final SignedBeaconBlock block, Optional<BeaconState> preState); SafeFuture<AttestationProcessingResult> onAttestation(
      final ValidateableAttestation attestation); void save(); void applyIndexedAttestations(final List<ValidateableAttestation> attestations);  }### Answer:
@Test void onBlock_shouldImmediatelyMakeChildOfCurrentHeadTheNewHead() { final SignedBlockAndState blockAndState = chainBuilder.generateBlockAtSlot(ONE); final SafeFuture<BlockImportResult> importResult = forkChoice.onBlock(blockAndState.getBlock(), Optional.of(genesis.getState())); assertBlockImportedSuccessfully(importResult); assertThat(recentChainData.getHeadBlock()).contains(blockAndState.getBlock()); assertThat(recentChainData.getHeadSlot()).isEqualTo(blockAndState.getSlot()); }
@Test void onBlock_shouldNotImmediatelyMakeChildOfCurrentHeadTheNewHeadWhenItIsTooFarBehind() { storageSystem .chainUpdater() .setTime(genesis.getState().getGenesis_time().plus(34 * SECONDS_PER_SLOT)); final SignedBlockAndState blockAndState = chainBuilder.generateBlockAtSlot(ONE); final SafeFuture<BlockImportResult> importResult = forkChoice.onBlock(blockAndState.getBlock(), Optional.of(genesis.getState())); assertBlockImportedSuccessfully(importResult); assertThat(recentChainData.getHeadBlock()).contains(genesis.getBlock()); assertThat(recentChainData.getHeadSlot()).isEqualTo(genesis.getSlot()); }