@Override
    public void truncate(SequenceNumber to) {
        LOG.debug("truncate {} to sqn {} (excl.)", logId, to);
        checkArgument(to.compareTo(activeSequenceNumber) <= 0);
        lowestSequenceNumber = to;
        notUploaded.headMap(lowestSequenceNumber, false).clear();

        Map<SequenceNumber, UploadResult> toDiscard = uploaded.headMap(to);
        notifyStateNotUsed(toDiscard);
        toDiscard.clear();
    }
@Test
    void testTruncate() {
        assertThatThrownBy(
                        () ->
                                withWriter(
                                        (writer, uploader) -> {
                                            SequenceNumber sqn = append(writer, getBytes());
                                            writer.truncate(sqn.next());
                                            writer.persist(sqn, 1L);
                                        }))
                .isInstanceOf(IllegalArgumentException.class);
    }