public void sanityCheck() {
        ByteBuffer buffer = ByteBuffer.allocate(AbortedTxn.TOTAL_SIZE);
        for (AbortedTxnWithPosition txnWithPosition : iterable(() -> buffer)) {
            AbortedTxn abortedTxn = txnWithPosition.txn;
            if (abortedTxn.lastOffset() < startOffset)
                throw new CorruptIndexException("Last offset of aborted transaction " + abortedTxn + " in index "
                    + file.getAbsolutePath() + " is less than start offset " + startOffset);
        }
    }
@Test
    public void testSanityCheck() throws IOException {
        List<AbortedTxn> abortedTxns = Arrays.asList(
                new AbortedTxn(0L, 0, 10, 11),
                new AbortedTxn(1L, 5, 15, 13),
                new AbortedTxn(2L, 18, 35, 25),
                new AbortedTxn(3L, 32, 50, 40));
        abortedTxns.forEach(txn -> assertDoesNotThrow(() -> index.append(txn)));
        index.close();

        // open the index with a different starting offset to fake invalid data
        try (TransactionIndex reopenedIndex = new TransactionIndex(100L, file)) {
            assertThrows(CorruptIndexException.class, reopenedIndex::sanityCheck);
        }
    }