### Question:
StateRootRecorder { public void acceptNextState(final BeaconState state) { if (slot.plus(slotsPerHistoricalRoot).compareTo(state.getSlot()) < 0) { final UInt64 floor = state.getSlot().minus(slotsPerHistoricalRoot); LOG.warn("Missing state root mappings from slot {} to {}", slot, floor); slot = floor; } while (slot.compareTo(state.getSlot()) < 0) { stateRootConsumer.accept( state.getState_roots().get(slot.mod(slotsPerHistoricalRoot).intValue()), slot); slot = slot.plus(UInt64.ONE); } stateRootConsumer.accept(state.hash_tree_root(), state.getSlot()); } StateRootRecorder(final UInt64 slot, final BiConsumer<Bytes32, UInt64> stateRootConsumer); void acceptNextState(final BeaconState state);  }### Answer:
@Test public void shouldHandleSingleStep() { final StateRootRecorder stateRootRecorder = new StateRootRecorder(slot, (stateRoot, slot) -> stateRoots.put(slot, stateRoot)); stateRootRecorder.acceptNextState(state); assertThat(stateRoots).containsOnlyKeys(slot); }
@Test public void shouldHandleMultipleSteps() { final StateRootRecorder stateRootRecorder = new StateRootRecorder(slot.minus(2), (stateRoot, slot) -> stateRoots.put(slot, stateRoot)); stateRootRecorder.acceptNextState(state); assertThat(stateRoots).containsOnlyKeys(slot.minus(2), slot.minus(ONE), slot); }
@Test public void shouldLimitToSlotsPerHistoricalRoot() { final UInt64 history = UInt64.valueOf(SLOTS_PER_HISTORICAL_ROOT).plus(10); final StateRootRecorder stateRootRecorder = new StateRootRecorder( slot.minus(history), (stateRoot, slot) -> stateRoots.put(slot, stateRoot)); stateRootRecorder.acceptNextState(state); assertThat(stateRoots.size()).isEqualTo(SLOTS_PER_HISTORICAL_ROOT + 1); }