public OptionalLong firstUndecidedOffset() {
        Map.Entry<Long, TxnMetadata> firstEntry = ongoingTxns.firstEntry();
        return firstEntry != null ? OptionalLong.of(firstEntry.getValue().firstOffset.messageOffset) : OptionalLong.empty();
    }
@Test
    public void testOldEpochForControlRecord() {
        short epoch = 5;

        assertFalse(stateManager.firstUndecidedOffset().isPresent());

        appendClientEntry(stateManager, producerId, epoch, defaultSequence, 99, true);
        assertThrows(InvalidProducerEpochException.class,
                () -> appendEndTxnMarker(stateManager, producerId, (short) 3,
                        ControlRecordType.COMMIT, 100));
    }