async fn assert_leaf_indices(
    conn: &mut Connection<'_, Core>,
    tree_reader: AsyncTreeReader,
    current_tree_info: &MerkleTreeInfo,
) {
    let all_initial_writes = conn
        .storage_logs_dedup_dal()
        .dump_all_initial_writes_for_tests()
        .await;
    let max_l1_batch = all_initial_writes
        .iter()
        .map(|write| write.l1_batch_number)
        .max()
        .expect("no initial writes");
    let keys_to_indices: HashMap<_, _> = all_initial_writes
        .into_iter()
        .map(|write| (write.hashed_key, write.index))
        .collect();
    let keys: Vec<_> = keys_to_indices.keys().copied().collect();

    let proof = tree_reader
        .prove(max_l1_batch.0.into(), keys.clone())
        .await
        .unwrap();
    assert!(proof.operations.is_empty());
    for (op, key) in proof.read_operations.iter().zip(&keys) {
        let index = keys_to_indices[key];
        assert_eq!(*op, TreeOperation::Hit { index });
    }

    let tree_output = BatchOutput {
        root_hash: current_tree_info.root_hash,
        leaf_count: current_tree_info.leaf_count,
    };
    proof
        .verify_reads(
            &Blake2Hasher,
            <DefaultTreeParams>::TREE_DEPTH,
            tree_output,
            &keys,
        )
        .unwrap();
}
Checks that leaf indices are assigned identically in the tree and Postgres.
core/node/zk_os_tree_manager/src/tests.rs