Repository: tikv/tikv
File: components/compact-log-backup/src/compaction/exec.rs (Rust)

Code before:
    #[tokio::test]
    async fn test_non_write_cf() {
        use WriteType::*;
        let items = vec![
            vec![
                simple_write(b"key1", Put, 60),
                simple_write(b"key1", Put, 60),
            ],
            vec![
                simple_write(b"key1", Put, 60),
                simple_write(b"key1", Delete, 61),
            ],
            vec![
                simple_write(b"key1", Delete, 61),
                simple_write(b"key1", Delete, 61),
            ],
        ];
        let res = process_input_for_test(items, CF_DEFAULT).await;
        assert_eq!(
            res,
            &[
                simple_write(b"key1", Delete, 61),
                simple_write(b"key1", Put, 60),
            ]
        );
    }

    #[tokio::test]
    #[should_panic]
    async fn test_non_write_cf_fail() {
        use WriteType::*;
        let items = vec![
            vec![simple_write(b"key1", Put, 60)],
            vec![simple_write(b"key1", Delete, 60)],
        ];
        process_input_for_test(items, CF_DEFAULT).await;
    }

    #[tokio::test]
    async fn test_many_rollback() {
        use WriteType::*;
        let items = vec![
            vec![
                simple_write(b"key1", Rollback, 60),
                protected_rollback(b"key1", 60),
            ],
            vec![
                put_with_collapsed_rollback(b"key1", 60),
                simple_write(b"key1", Put, 62),
            ],
        ];

Review comment (bug):
The test_non_write_cf test expects that identical records in CF_DEFAULT will be deduplicated without calling the resolve function. However, the resolve function panics if c.cf != CF_WRITE. This test passes only because all the duplicate records are identical (e.g., simple_write(b"key1", Put, 60) appears three times), so they pass the equality check at line 137 and return early. The test doesn't validate that the panic path works correctly for non-Write CF when records differ, which is already covered by test_non_write_cf_fail. Consider adding a comment to clarify this behavior or restructuring the test to be more explicit about what it's testing.

Code after:
        ];
        process_input_for_test(items, CF_WRITE).await;
    }

    #[tokio::test]
    async fn test_non_write_cf_success() {
        use WriteType::*;
        let items = vec![
            vec![
                simple_write(b"key1", Put, 60),
                simple_write(b"key1", Put, 60),
            ],
            vec![
                simple_write(b"key1", Put, 60),
                simple_write(b"key1", Delete, 61),
            ],
            vec![
                simple_write(b"key1", Delete, 61),
                simple_write(b"key1", Delete, 61),
            ],
        ];
        let res = process_input_for_test(items, CF_DEFAULT).await;
        assert_eq!(
            res,
            &[
                simple_write(b"key1", Delete, 61),
                simple_write(b"key1", Put, 60),
            ]
        );
    }

    #[tokio::test]
    #[should_panic]
    async fn test_non_write_cf_fail() {
        use WriteType::*;
        let items = vec![
            vec![simple_write(b"key1", Put, 60)],
            vec![simple_write(b"key1", Delete, 60)],
        ];
        process_input_for_test(items, CF_DEFAULT).await;
    }

    #[tokio::test]
    async fn test_many_rollback() {
        use WriteType::*;
        let items = vec![
            vec![
                simple_write(b"key1", Rollback, 60),
                protected_rollback(b"key1", 60),
            ],
            vec![